Mobile Integration Short
Mobile Integration Short
SBI payment
HTML page
1. Request
4. Response from SBI to web Service
Webservice
5. Request
Mobile App
6. Response
Server
Step 1: Mobile Application initiates the request to the web services with all the
required parameters for the SBI along with the customer entered amount
Step 2:
a) The request parameter gets stored on the server database.
b) The request parameter gets encrypted with the key.
c) From Webservice MID, the amount and encrypted value is sent to our internal
HTML page.
Step 3:
Displays the entered amount and the pay button is created. Clicking the pay button
redirects to the SBI payment page.
Step 4:
In the parameter sent to SBI contains the success and failure page. The response
comes to our webservice.
Step 5:
When the process happens between Step 2 to Step 4, the mobile application will send
a request to the web service to check if any response received from the SBI.
Step 6:
Once we receive a response from step 5, we will display the SBI response on the
mobile application.
Challenges
1. As there are a lot of interfaces there are chances of losing the connection.
2. If the user closes the application or receives no response from the API, the mobile
application will land on the pending page.
3. User will tap on each transaction present on the pending page, we call double api
provided by SBI to check the payment status. On Success/failure, we update the web
service database.
Sample Code
1. Webservice Code
<?php
//require_once('sbi_encrypt.php');
$input=$_GET['encypt'];
$mobile=$_GET['mobile'];
$tranmobile=$_GET['tranmobile'];
$merchantID ="";
$data=$merchantID."|".$input;
list($merchantID, $operating_mode, $merchantCountry,$merchantcurrency,$postingAmount,
$otherdetails,$successURL,$failURL,$aggregatorid,$merchantorderno,$merchantcustomerid,
$paymode,$accessmedium,$transactionsource)=explode('|', $data);
2. sbi_encrypt.php
<?php
$input=$_GET['order_id'];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => ' ',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>json_encode($request),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
//return $response;
echo ("<script language='JavaScript'>
window.location.href='sbi_page.php?order_id=$input';
</script>");
?>
3. sbi_page.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="bootstrap-5.1.3-dist/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="css/sbi.css">
</head>
<body>
<form name="ecom" method="post"
action="https://www.sbiepay.sbi/secure/AggregatorHostedListener">
<div class="mb-3">
</div>
<div class="mb-3">
</div>
<div class="mb-3 payButton">
<button type="submit" class="btn btn-primary">Pay</button>
</div>
</form>
</div>
<script type="text/javascript" src="bootstrap-5.1.3-dist/js/bootstrap.min.js"></script>
</body>
</html>
4. double api
<?php
$merchant_order_no=$_POST['merchantorder'];
$merchantID ="";
$url="https://www.sbiepay.sbi/payagg/statusQuery/getStatusQuery"; // double verification url
$queryRequest="|$merchantid| $merchant_order_no";
$queryRequest3=http_build_query(array('queryRequest' =>
$queryRequest,"aggregatorId"=>"SBIEPAY","merchantId"=>$merchantid));
//echo "$url,$queryRequest3";exit;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,1);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch,CURLOPT_POSTFIELDS, $queryRequest33);
$response = curl_exec ($ch);
if (curl_errno($ch)) {
echo $error_msg = curl_error($ch);
}
curl_close ($ch);
echo $response;
?>