Developing custom payment gateways |
Creating a custom payment gateway
Here's a general overview of the process of integrating a custom payment gateway:
- Payment method display name – Friendly name (localizable string or simple text) displayed to the users. - Payment method code name – Unique identifier which must be unique within all of the site payment methods. - Enabled – Indicates whether payment method could be used for payment. - Payment gateway URL – External payment gateway url or relative path to your document controlled by the Kentico CMS which represents your custom payment processor. It can be parameterized; it means you can use data macros to get any value from shopping cart to your url. The following example shows how you can insert finished order ID to the payment url, however, you can get any value from shopping cart using data macros whose names correspond to the table COM_ShoppingCart column names: http://www.SomePaymentGateway.com?orderid={%ShoppingCartOrderId%} - Payment gateway assembly name – Name of a library which includes your payment gateway class inside. - Payment gateway class name – Name of a class which represents your custom payment gateway processor. - Order status when payment succeeds – Order status which is set to the existing order when its payment succeeds. - Order status when payment fails – Order status which is set to the existing order when its payment fails.
Please note: The offered payment methods depend on the chosen shipping option. If there is no enabled shipping option all payment methods are offered.
Creating a custom payment gateway form
Since the control is located in the site folder it is included in export package of your site.
Please note: Payment data, such as credit card numbers, credit card codes and others are not saved into the database because of security reasons.
Creating custom payment gateway class
Example The following example shows a custom payment processor implementation. It allows customers to pay for their orders using some external payment gateway similar to PayPal, let’s call it Custom Gateway. Customer is asked for his credit card number in the last step of checkout process. Credit card number is validated for emptiness and processed after the “Finish payment” button is clicked. If it succeeds payment process is performed – required payment data are attached to the payment url and customer is redirected to Custom Gateway. If payment process fails (payment gateway url is not defined) order payment result is updated and appropriate error message is displayed. Notice that order is saved before the customer is asked to pay for it, it happens immediately after the “Order now” button is clicked.
Please note:
Example of custom payment gateway definition.
Custom payment gateway form It is a simple form with one input field to enter customer credit card number, see image bellow.
CustomGatewayForm.ascx
CustomGatewayForm.ascx.cs
[C#]
Custom payment gateway class The following example uses assembly name CMS.CustomProvider and class CMS.CustomProvider.CustomGateway, however, you will need to use your own names.
CustomGateway.cs [C#]
|