You are new to payment gateway integration and you wish to know on how to integrate with payment gateway. In this article, we will walkthrough the very basic things you need to know to integrate with CHIP Payment Gateway.
First of all, CHIP payment gateway do provide an API. The data will be communicated with format of JSON. So, if you do have a look at CHIP API Documentation, you will see a long page telling about CHIP API.
Fret not, you only have to look for POST /purchases/ section for basic integration. Basically, you can expect that you will be able to integrate with your system and receive the notification response after payment is succeed. To put it simply, the user experience is as follows:
Your website –> CHIP –> Your website
You need to have the customer information and product price that you sell before calling POST /purchases/ API. However, in this article, we will hard code those information as follows:
- Client Full Name: Wan
- Client Email Address: [email protected]
- Product Price: RM 1
<?php $secret_key = 'KKmYRId-r4TSflN1Hk-ZmvT-ZRcRF8RoB7NxOI_7FLOzZoNvhXVJvL6FyJZ6mJ9TbiqDK6PfoGUUqrOrFx1o9w=='; $brand_id = '039ffd7f-c6f4-4e91-b874-7a49ad70b6e6'; $host = 'https://gate.chip-in.asia/api/v1/purchases/'; $params = array( 'success_redirect' => 'https://domain.com/successful_redirection', 'failure_redirect' => 'https://domain.com/failed_redirection', 'cancel_redirect' => 'https://domain.com/cancel_redirection', 'success_callback' => 'https://domain.com/successful_callback', 'purchase' => [ "products" => [ [ 'name' => 'Order #1', 'price' => '100', // RM 1 ], ], ], 'brand_id' => $brand_id, 'client' => [ 'email' => '[email protected]', 'full_name' => 'Wan' ], ); $process = curl_init( $host ); curl_setopt($process, CURLOPT_HEADER , 0); curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , "Authorization: Bearer $secret_key" )); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); curl_setopt($process, CURLOPT_POSTFIELDS, json_encode($params) ); $return = curl_exec($process); curl_close($process); $purchases = json_decode($return, true); header('Location: ' . $purchases['checkout_url']);
Alternatively, you can refer to CHIP GitHub repository for code example.
So, upon execution, the user will be redirect to CHIP payment page where the payer will be able to choose the available payment method for your account.
Upon payment completion, the user will be redirected success_redirect URL that we have set and you can call GET /purchases/ API to verify the payment status.
If you require 1-to-1 session on how to integrate with CHIP API, you can contact me at [email protected] for arrangement. My rate is RM 75/hour.