integration krnwa vidiya example ekk tiynwanm dendko
Best posts made by Kasun Anuradha
-
DirectPay Payment geteway to Laravel integrate krpu kenk inwad ? Need help
Latest posts made by Kasun Anuradha
-
RE: DirectPay Payment geteway to Laravel integrate krpu kenk inwad ? Need help
ou brother hri giya Thank you..!
-
RE: DirectPay Payment geteway to Laravel integrate krpu kenk inwad ? Need help
$secret = "vs6568s7v2aklsdv687a3dn8a6q92z"; secret key ek ila gannda one eyalgen
-
RE: DirectPay Payment geteway to Laravel integrate krpu kenk inwad ? Need help
3.2. Create payment session
Gateway URL
Sandbox = https://test-gateway.directpay.lk/api/v3/create-session
Live = https://gateway.directpay.lk/api/v3/create-session3.2.2.
Sample Request
Note: Example code for each step is provided using PHP.
$checkout_url =
"https://test-gateway.directpay.lk/api/v3/create-session";
$requestPayload = [
"merchant_id" => "xxxxxx",
"amount" => "140.00",
"source" => "custom-plugin",
"type" => "ONE_TIME",
"order_id" => "CP123456789",
"currency" => "LKR",
"response_url" => "https://test.com/response-endpoint",
"return_url" => "https://test.com/return",
"first_name" => "Sam",
"last_name" => "Perera",
"email" => "[email protected]",
"phone" => "071xxxxxxx",
"description" => "test-payment",
"logo" => "",
];
$jsonEncodedPayload = json_encode($requestPayload);
$base64EncodedPayload = base64_encode($jsonEncodedPayload);
$secret = "vs6568s7v2aklsdv687a3dn8a6q92z";
$generatedHash = hash_hmac('sha256', $base64EncodedPayload, $secret);
$signature = "hmac " . $generatedHash;
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $checkout_url,
10CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $base64EncodedPayload,
CURLOPT_HTTPHEADER => [
"Content-Type: text/plain",
"Authorization: $signature",
],
));
$response = curl_exec($ch);
curl_close($ch);Sample Response
Success Response
{
"status": 200,
"data": {
"link": "https://test-gateway.directpay.lk/52e28db633eb3838",
"token": "52e28db633eb3838",
"sms_status": null,
"email_status": null
}
}Fail Response
{
"status": 400,
"data": {
"title": "Invalid Signature: ",
"message": "Provided signature is invalid",
"code": "invalidSignature"
}
} -
DirectPay Payment geteway to Laravel integrate krpu kenk inwad ? Need help
integration krnwa vidiya example ekk tiynwanm dendko