Payment Validation API
After knowing that the post keys are valid and no moletion done with the request, now it is the time to validate your transaction for amount and transaction. It will only treated as valid if amount and transaction status are valid at FastPay End
So, Let's call the API and the example given below
API URL: https://dev.fast-pay.cash/merchant/payment/validation
Method: POST
$post_data = array();
$post_data['merchant_mobile_no']='merchant_mobile_no';
$post_data['store_password']="your store id";
$post_data['order_id']="your order id";
$requested_url = "https://dev.fast-pay.cash/merchant/payment/validation";
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $requested_url );
curl_setopt($handle, CURLOPT_TIMEOUT, 10);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($handle, CURLOPT_POST, 1 );
curl_setopt($handle, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($code == 200 && !( curl_errno($handle)))
{
# TO CONVERT AS ARRAY
# $result = json_decode($result, true);
# TO CONVERT AS OBJECT
$result = json_decode($result);
# TRANSACTION INFO
$messages = $result->messages;
$code = $result->code; #if $code is not 200 then something is wrong with your request.
$data = $result->data;
} else {
echo "Failed to connect with FastPay";
}
Response:
{
"messages":"Please find your transaction details:",
"data":
{
'transaction_id':'123456',
'order_id':'asdf12345',
'bill_amount':'10000',
'customer_account_no':'+9649876543210',
'status':'Success',
'received_at': '2017-07-27 12:55:45'
}
"code":"200"
}
Security Check Points:
- Track your order by transaction ID and check it in your database for existence
- Must validate amount and incoming amount from your Database
- Check for the status - Success, Failed, Cancelled to update your order status
Update your transaction
So, Your order and amount validated and it is ready for update in your database.
If status is Valid and validation status Valid then update your database according to the status. and wait for your user to your website to show him/her the success, fail, and cancel page.