HOW TO add a new payment gateway?

Discuss everything related to ApPHP Durecty CMF. All versions. Any questions related to the Directy CMF developing or using should be posted to this forum.

Moderators: ne_moj, alexmst, zewa, vadimako, ne_moj, alexmst, zewa, vadimako

ne_moj
Master
Master
Posts: 243
Joined: Jan 1st, '16, 14:11

HOW TO add a new payment gateway?

Postby ne_moj » Aug 30th, '17, 07:11

Step-by-step instructions for adding a new payment system for scripts based on ApPHP MVC Framework & CMF (Shopping Cart, uBusinessDirectory and etc.)

1) Add the desired payment system to Backend (page http://your_site/paymentProviders/add)
2) Edit the file "protected/libraries/ipgw/PaymentProvider.php" (you need to add an additional entry to the $_paymentClasses property)
Example code:

Code: Select all

    /** @var array */
    private static $_paymentClasses = array(
        'online_order'          => array('class'=>'OnlineOrder', 'file'=>'OnlineOrder.php'),
        'online_credit_card'    => array('class'=>'OnlineCreditCard', 'file'=>'OnlineCreditCard.php'),
        'wire_transfer'         => array('class'=>'WireTransfer', 'file'=>'WireTransfer.php'),
        'paypal'                => array('class'=>'PayPal', 'file'=>'PayPal.php'),
        'new_payment'           => array('class'=>'NewPayment', 'file'=>'NewPayment.php'),
    );


3) Add a new file to the directory "protected/libraries/ipgw/providers/"
Example:
"protected/libraries/ipgw/providers/NewPayment.php"
Code:

Code: Select all

class NewPayment extends PaymentGateway
{
    /**
     * Draws payment form
     * @param array $params
     * @return html
     */
    public function drawPaymentForm($params = array())
    {
        $output = '';

        // Prepare payment form

        return $output;
    }

    /**
     * Handles payment
     * @param array $params
     * @return array
     */
    public function handlePayment($params)
    {
        $return = array('error' => 0, 'message' => '', 'order' => array());

        // Prepare input data

        return $return;
    }
}


The implementation of a similar class can be seen in the file protected/libraries/ipgw/providers/PayPal.php (payment through PayPal)

Return to “ApPHP Directy CMF {developers/users}”