cakasim/payone-symfony-bundle
Installation Add the bundle via Composer (if available in a fork or alternative source):
composer require cakasim/payone-symfony-bundle
(Note: Since the package is archived, verify compatibility with your Symfony version.)
Enable the Bundle
Register in config/bundles.php:
return [
// ...
Cakasim\PayoneBundle\PayoneBundle::class => ['all' => true],
];
Configuration
Define PAYONE API credentials in config/packages/payone.yaml:
payone:
merchant_id: 'YOUR_MERCHANT_ID'
secret_key: 'YOUR_SECRET_KEY'
endpoint: '%env(PAYONE_ENDPOINT)%' # e.g., 'https://secure.payone.com/api/v1'
First Use Case: Payment Request Use the service to create a payment request in a controller:
use Cakasim\PayoneBundle\Service\PayoneService;
class PaymentController extends AbstractController
{
public function createPayment(PayoneService $payoneService): Response
{
$payment = $payoneService->createPayment([
'amount' => 10.00,
'currency' => 'EUR',
'order_id' => 'ORDER_123',
'description' => 'Test Purchase',
'method' => 'creditcard', // or 'directdebit', 'paypal', etc.
]);
return $this->redirect($payment->getRedirectUrl());
}
}
Initiate Payment
Use PayoneService to generate a payment request and redirect the user to PAYONE’s payment page:
$payment = $payoneService->createPayment($requestData);
return new RedirectResponse($payment->getRedirectUrl());
Handle Callback
Configure a route to handle PAYONE’s callback (e.g., /payone/callback):
#[Route('/payone/callback', name: 'payone_callback', methods: ['POST'])]
public function handleCallback(PayoneService $payoneService, Request $request): Response
{
$response = $payoneService->handleCallback($request->getContent());
if ($response->isSuccessful()) {
// Update order status, send confirmation email, etc.
}
return new JsonResponse(['status' => 'processed']);
}
Webhook Verification Validate webhook signatures (if supported) to ensure request authenticity:
$isValid = $payoneService->verifyWebhook($request->getContent(), $request->headers->get('X-Payone-Signature'));
$builder->add('payment_method', ChoiceType::class, [
'choices' => [
'creditcard' => 'Credit Card',
'directdebit' => 'Direct Debit',
],
]);
PayoneEvents::PAYMENT_CREATED) for async processing:
$dispatcher->addListener(PayoneEvents::PAYMENT_CREATED, function ($event) {
// Log or notify about new payment.
});
PayoneService with a sandbox endpoint (endpoint: 'https://sandbox.payone.com/api/v1') and mock responses.Deprecated/Archived Package
Callback Handling
Signature Verification
$expectedSignature = hash_hmac('sha256', $request->getContent(), $this->getConfig()['secret_key']);
if (!hash_equals($expectedSignature, $request->headers->get('X-Payone-Signature'))) {
throw new \RuntimeException('Invalid signature');
}
Error Handling
try {
$response = $payoneService->createPayment($data);
} catch (\Exception $e) {
\Log::error('PAYONE Error:', ['response' => $e->getMessage(), 'data' => $data]);
}
Custom Payment Methods Extend the bundle by adding new payment methods via a custom service:
class CustomPayoneService extends PayoneService
{
public function createCustomPayment(array $data): PaymentResponse
{
$data['method'] = 'custom_method';
return parent::createPayment($data);
}
}
Database Integration Save payment responses to your database:
$paymentRecord = new Payment();
$paymentRecord->orderId = $response->getOrderId();
$paymentRecord->status = $response->getStatus();
$paymentRecord->save();
Configuration Overrides
Override default config in config/packages/payone.yaml:
payone:
timeout: 30 # Default HTTP timeout in seconds
retry_attempts: 2 # Retry failed requests
PAYONE_DEBUG: true in .env to log raw API requests/responses.How can I help you explore Laravel packages today?