Initiate API Payment
Endpoint: https://jhpay.online/express/initiateMethod: GET
Just request to that endpoint with all parameter listed below:
Parameter | Details |
---|---|
amount | Your Amount , Must be rounded at 2 precision. |
currency | Currency Code, Must be in Upper Case. Supported Currency : AED AFN AMD AUD AZN CAD CNY EUR GBP GEL INR IRR KGS KWD KZT MDL MYR NOK PKR PLN RUB SAR SGD TJS TRY UAH USD USDT UZS
|
details | Details of the Transaction. string not more than 100 char. |
custom | Custom Code/Transaction Number for Identify at your end. string not more than 16 char. |
ipn_url | URL of your IPN Listener |
success_url | Redirect url after successful Payment |
cancel_url | Redirect url after Cancel the Payment |
public_key | Your API Public Key |
name | Name of the Client. string not more than 100 char. |
Email of the Client. string not more than 100 char. |
** All Parameters are required!
Example PHP Code to Request
// create array With Parameters $parameters = array( 'amount' => '10.33', 'currency' => 'RUB', 'details' => 'Purchase Software', 'custom' => 'ABCD1234', 'ipn_url' => 'http://www.abc.com/ipn.php', 'success_url' => 'http://www.abc.com/success.php', 'cancel_url' => 'http://www.abc.com/cancelled.php', 'public_key' => 'ABCDEFGH123456789', 'name' => 'Mr. Salim Aliev', 'email' => '[email protected]' ); // Generate The Url $endpoint = 'https://jhpay.online/express/initiate'; $call = $endpoint . "?" . http_build_query($parameters); // Send Request $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $add); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); $response = curl_exec($ch); curl_close($ch); // $response contain the response from server
Response (Error)
{ "error": "error", "message": { "amount": [ "The amount format is invalid." ], "details": [ "The details field is required." ] } }
Response (Success)
{ "error": "ok", "message": "Payment Initiated. Redirect to url", "url": "https://jhpay.online/express/payment/UNIQUE_CODE" }
Get Payment
After Successful response from last step, Redirect the User to the URL you get as response. User can transact over our system and we will notify on your IPN after Successful payment. Remember, we send response to IPN only once per successful Transaction.
IPN and Validate The Payment
Endpoint: Your IPN URLMethod: POST
You will get below parameter on your IPN:
Parameter | Details |
---|---|
amount | Your Requested Amount |
currency | Currency Code, as You passed on first step. |
custom | Custom String for Identify the payment, as You passed on first step. |
trx_num | Transaction Number on our platform. |
signature | A Hash to Verify the Payment. See code on right side to get more on it. |
Example PHP Code to validate The Payment
$amount = $_POST['amount']; $currency = $_POST['currency']; $custom = $_POST['custom']; $trx_num = $_POST['trx_num']; $sentSign = $_POST['signature']; // with the 'custom' you can find your original amount and currency. just cross check yourself. if that check is pass, proceed to next step. // Generate your signature $string = $amount.$currency.$custom.$trx_num; $secret = 'YOUR_SECRET_KEY'; $mySign = strtoupper(hash_hmac('sha256', $string , $secret)); if($sentSign == $mySign){ // if sentSign and your generated signature match, The Payment is verified. Never Share 'SECRET KEY' with anyone else. }