Payment methods

How is adaptation of payment methods taking place?

In the ocionic application, payment methods are divided into 2 types: standard and acquiring. Next, you will see documentation on the adaptation of each of the types.

Usual payment methods:

To adapt this payment method, you need to duplicate the method model to the OpenCart folder (don't forget to rename the class):

/catalog/model/ionic/payment/*.php

The next stage will be the adaptation of the controller. To do this, create the appropriate controller in the OpenCart folder:

/catalog/controller/api/ionic/payment/*.php

The application will call the confirm function, so if it doesn't exist, create it. In addition to standard logic (changing order status, etc.), this function should output a JSON array:

{
"order_message": {
"type": "success",
"message": "Thank you, your order has been placed!"
}
}

Acquiring payment methods:

To adapt this payment method, you need to duplicate the method model to the OpenCart folder (don't forget to rename the class):

/catalog/model/ionic/payment/*.php

Attention! After that, you need to add another "is_acquiring" index to the payment method model! An example of one of these methods:

$method_data = array(
'code' => 'stripe',
'is_acquiring' => true,
'title' => 'Pay now by bank card',
'terms' => '',
'sort_order' => 1
);

Next, create a new controller:

/catalog/controller/api/ionic/payment/*.php
Principle of acquiring in the application:

The logic of acquiring in the application works with the help of iframe and takes place in several stages:

  1. When clicking on "pay" - the program creates an order with order_status_id = 0 and receives an order_id in response, after which the user opens a modal window with an iframe at the address:

    https://your.site/index.php?route=api/ionic/payment/your_payment_method/confirm&order_id={order_id}

    Therefore, you should create a confirm function in your controller that initializes the payment page of the individual order (or redirects to the bank-side payment page)

  2. When the modal window is closed - the program will automatically send a request regarding the endpoint

    https://your.site/index.php?route=api/ionic/payment/your_payment_method/check&order_id={order_id}

    Therefore, you should create a check function in your controller that checks the status of the order and generates a JSON response:

    Successful payment
    {
    "order_message": {
    "type": "success",
    "message": "Thank you, your order has been placed!"
    }
    }
    Payment failed
    {
    "toast": {
    "color": "danger",
    "duration": 2000,
    "side": "end",
    "text": "Payment did not go through"
    }
    }

Write a review

Write a review


Ask a question

Ask a question