Payment Gateway Integration

Payment Gateway Integration

A payment gateway can be integrated programmatically, by following steps given below:

1. In /app/plugins/paid_listings/payment_handlers, create file with name like payment_gateway.php, here "payment_gateway , should be the name of your payment gateway for example paypal.php (attached with the topic). In this newly created file create a class with name like PaymentGatewayPaymentHandler, for example paypal.php will have a class with name PaypalPaymentHandler and two_checkout.php should have class with name TwoCheckoutHandler.

2. This class should extend class AbstractPaymentHandler. AbstractPaymentHandler defines a abstract method process, with signature:

 function process(AppController $controller,$orderId) 

This where you can handle your payment gateway integration. For example you can redirect user to your payment gateway or redirect to a url in the script where you a custom payment form. Upon successful completion of order you will need call Order::setAsCompleted($orderId) and Transaction::createTransaction($PaymentHandlerObject,$order,Transaction::SUCCESSFUL,$_POST)

You can download payments_controller.php (attached with the topic) file to understand the integration process in details.