This documentation is for a version that has reached its End Of Life. Such versions are no longer supported and don't receive security updates. Consider updating to a newer version.
If your application needs payment methods of other type than the default offline one, or ones offered by Payum, you can create custom payment method types.
Code samples below show how this could be done if your organization wants to use PayPal independently.
Gateway integration requirement
Ibexa DXP doesn't come with gateway redirects. Whether you're an integrator or an end customer, it's your responsibility to implement payment gateway integration.
Make sure that getName() returns a human-readable name of the payment method type, the way you want it to appear on the list of available payment method types.
As an alternative, instead of creating a custom class, you can use a built-in type factory to define the payment method type in the service definition file:
You might want to make sure that data provided by the user is validated.
To do that, create an options validator that checks user input against the constraints and dispatches an error when needed.
1 2 3 4 5 6 7 8 9101112131415161718192021222324
<?phpdeclare(strict_types=1);namespaceApp\Form\Type;useIbexa\Contracts\Core\Options\OptionsBag;useIbexa\Contracts\Payment\PaymentMethod\Type\OptionsValidatorError;useIbexa\Contracts\Payment\PaymentMethod\Type\OptionsValidatorInterface;finalclassUrlOptionValidatorimplementsOptionsValidatorInterface{publicfunctionvalidateOptions(OptionsBag$options):array{$errors=[];if(empty($options->get('base_url'))){$errors[]=newOptionsValidatorError('base_url','Base URL cannot be blank');}// Add gateway implementation herereturn$errors;}}
When you create a payment, you can attach custom data to it, for example, you can pass an invoice number or a proprietary transaction identifier.
You add custom data by using the setContext method:
1 2 3 4 5 6 7 8 91011
// Create a new payment$context=['transaction_id'=>'5e5fe187-c865-49£2-b407-a946fd7b5be0',];$paymentCreateStruct=newPaymentCreateStruct($this->paymentMethodService->getPaymentMethodByIdentifier('bank_transfer_EUR'),$this->orderService->getOrder(135),newMoney\Money(100,newMoney\Currency('EUR')));$paymentCreateStruct->setContext(newArrayMap($context));