Step-by-Step Guide: Integrating HitPay Payment Gateway in Your Website!
STEP 1:
composer require guzzlehttp/guzzle
STEP 2:
//Generate Payment URL
$response = $client->request('POST', 'https://api.sandbox.hit-pay.com/v1/payment-requests', [
'body' => '{"amount":120,"currency":"SGD","name":"AMIT","redirect_url":"https://codewithcode.com/"}',
'headers' => [
'X-BUSINESS-API-KEY' => 'yourKEY',
'X-Requested-With' => 'XMLHttpRequest',
'accept' => 'application/json',
'content-type' => 'application/json',
],
]);
$response = $response->getBody();
$data = json_decode($response, true);
// Extract the desired values
$id = $data['id'];
$url = $data['url'];
$amount = $data['amount'];
$status = $data['status'];
header("Location: $url");
Payment Request Response Wityh Payment Gateway URL
ID: 99bf69cc-9bf4-44ee-b1c4-8aceee65e5b6 URL: https://securecheckout.sandbox.hit-pay.com/payment-request/@registered-acra-company-name/99bf69cc-9bf4-44ee-b1c4-8aceee65e5b6/checkout Amount: 120.00 Status: pending
If you want any help from my side please Email me on [email protected] OR WhatsApp Me On 6267465901
STEP 3:
// Check Payment Status
$response = $client->request('GET', 'https://api.sandbox.hit-pay.com/v1/payment-requests/99b7975a-ac81-435c-885e-55099e1266d0', [
'headers' => [
'X-BUSINESS-API-KEY' => 'YOURKEY',
'X-Requested-With' => 'XMLHttpRequest',
'accept' => 'application/json',
],
]);
echo $response->getBody();
Payment Status Response
{“id”:”99b7975a-ac81-435c-885e-55099e1266d0″,”name”:”AMIT”,”email”:”[email protected]”,”phone”:null,”amount”:”120.00″,”currency”:”SGD”,”status”:”completed”,”purpose”:null,”reference_number”:null,”payment_methods”:[“paynow_online”,”card”],”url”:”https:\/\/securecheckout.sandbox.hit-pay.com\/payment-request\/@registered-acra-company-name\/99b7975a-ac81-435c-885e-55099e1266d0\/checkout”,”redirect_url”:”https:\/\/codewithcode.com\/”,”webhook”:null,”send_sms”:true,”send_email”:false,”sms_status”:”pending”,”email_status”:”pending”,”allow_repeated_payments”:false,”expiry_date”:null,”address”:null,”line_items”:null,”created_at”:”2023-07-24T02:46:13″,”updated_at”:”2023-07-24T02:47:34″,”payments”:[{“id”:”99b7975b-4951-41fb-9740-9b5c004ad598″,”quantity”:1,”status”:”succeeded”,”buyer_name”:”AMIT”,”buyer_phone”:null,”buyer_email”:”[email protected]”,”currency”:”sgd”,”amount”:”120.00″,”refunded_amount”:”0.00″,”payment_type”:”card”,”fees”:”4.88″,”created_at”:”2023-07-24T02:46:14″,”updated_at”:”2023-07-24T02:47:34″}]}
#HitPayIntegration #PaymentGatewayTutorial #SecureOnlinePayments