Navigate back to the homepage

MIGS VPC Payment integration in php

September 14th, 2020 · 1 min read
MIGS VPC Payment integration in php

Hello Friends.

Welcome to Infinitbility!

we are going to integrate MIGS ( MasterCard Payment Gateway Service ) Or Also known as VPC ( Virtual Payment Client ) using PHP.

MasterCards Virtual Payment Client enables merchants to use payment enabled websites, e- commerce or other applications by providing a low effort integration solution. It is suitable for most website hosting environments as merchants can integrate payment capabilities into their application without installing or configuring any payments software.

  • from MIGS Documentation


if want read and understand deeply MIGS Payment integration then I have some documentation from MIGS

  • Virtual Payment Client Reference Guide


Given By the bank for payment credentials



create a PHP file copy the below code and replace with your credentials

For VPC_URL try both or it depends on your country and credentials.

3# credentials
4$url = VPC_URL; // or
5$merchantId = MERCHANT_ID; //value get from your bank
6$accessCode = ACCESS_CODE; //value get from your bank
7$SECURE_SECRET = SECURE_SECRET; //value get from your bank
8$baseURL = "localhost/migs";
10# amount
11$amount = floatval($_POST['amount']) *100;
13$unqueId = uniqid();
15$md5hash = $accessCode;
16$md5hash1 = '';
17$params['vpc_AccessCode'] = $accessCode;
18$params['vpc_Amount'] = $amount;
19$params['vpc_Command'] = 'pay';
20$params['vpc_Currency'] = 'INR';
21$params['vpc_Locale'] = 'en';
22$params['vpc_MerchTxnRef'] = $unqueId; // need all time unique
23$params['vpc_Merchant'] = $merchantId;
24$params['vpc_OrderInfo'] = 'Infinitbility unique - '.$unqueId; // need all time unique
25$params['vpc_ReturnURL'] = $baseURL.'/Response.php';
26$params['vpc_TicketNo'] = '';
27$params['vpc_TxSourceSubType'] = '';
28$params['vpc_Version'] = 1;
29$params['vpc_SecureHashType'] = 'SHA256';
32foreach($params as $key => $val )
34 if ( strlen($val) > 0 )
35 {
36 $qstr[] = urlencode($key)."=".urlencode($val);
37 $md5hash .= $val;
38 if ((strlen($val) > 0) && ((substr($key, 0,4)=="vpc_") || (substr($key,0,5) =="user_")))
39 {
40 if(in_array($key, array('vpc_SecureHash', 'vpc_SecureHashType')) )
41 continue;
42 $md5hash1 .= $key . "=" . $val . "&";
43 }
44 }
46$md5hash1 = rtrim($md5hash1, '&');
47$vpc_url = $url.'?'.implode("&", $qstr);
48$vpc_url .= "&vpc_SecureHash=".strtoupper(hash_hmac('SHA256', $md5hash1, pack('H*', $SECURE_SECRET)));
50header("Location: " . $vpc_url);

return Response

1"migs_transaction_number"&vpc_MerchTxnRef="random_unique_value(we post to migs)"&vpc_TxnResponseCode=value&vpc_Message="value"
2 if vpc_TxnResponseCode = 0 -- success ,vpc_Message = approved -- paymet is success , All other unsuccessfull payment

if you get help, please share post on your social network

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

More articles from Infinitbility

Manage dark mode without installing any package in react native

Manage dark mode without installing any package in react native

In this article, we discuss how to manage dark mode without installing any package to react native with example.

September 4th, 2020 · 1 min read
Always Use https url using Cloudflare

Always Use https url using Cloudflare

In this article, we can create page rules for force sites http to https using cloudflare.

September 3rd, 2020 · 1 min read
© 2020–2021 Infinitbility
Link to $ to $ to $ to $ to $ to $mailto:[email protected]