Manual Integration API (Open API)
If have your own e-commerce site and require manual integration, follow the steps below for further details.
Information required
To get started, please gather the following details from your senangPay dashboard:
Go to Menu > Settings > Profile
1. Merchant ID and Secret Key: Find these in the Shopping Cart Integration Link section.
2. Return URL: Specify the Return URL where senangPay will redirect buyers after payment processing.
3. Callback URL:
Provide the Callback URL, which serves as an alternative notification method if there is an issue with the transaction flow.
For more information on the Callback URL, please read here.
Ensure you have the below details ready to facilitate a smooth integration.
What parameters to send to senangPay.
Below are the details of the elements in the table:
detail
Description displayed during payment (maximum 500 characters). Underscores (_) convert to spaces.
Example:
Shopping_cart_id_30
Allowed characters: A-Z, a-z, 0-9, period (.), comma (,), dash (-), underscore (_).
amount
The charge amount, formatted to 2 decimal places.
Example:
25.50
.
order_id
Identifies the shopping cart on return after payment (maximum 100 characters).
Example:
3432D4
Allowed characters: A-Z, a-z, 0-9, dash (-).
hash
Ensures data integrity between the merchant’s cart and senangPay. Refer to the "How to generate the secure hash" section.
name
Adds the customer's name automatically. It's optional and can be edited.
email
Populates the customer's e-mail for them. Optional and can be modified.
phone
Inserts the customer's phone number. Optional and adjustable by the customer.
timeout
(optional)
Sets the payment timeout in seconds
Example : 8 minutes = 480 seconds
If not completed within this time, the payment will expire and redirect to the return URL. Minimum is 60 seconds; any amount below this defaults to 60 seconds. No timeout if omitted.
This endpoint creates a payment request to senangPay with the required details.
Retrievable in the senangPay Dashboard
14222653788472
Manual API request parameters.
Shopping cart id 30
25.5
Unique identifier for the order
ORD12345
a8167dd09f01ebed0b18e67b2cc2424a0d058ccc83d94803482ecdeed
Amir
[email protected]
123456789
in seconds
480
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox.senangpay.my/payment/{merchantID}',
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 => 'detail=Shopping_cart_id_30&amount=2.00&order_id=ORD12345&hash=c1454b758441c9990404162aa46d812ef55cf3917a57be493493eceeac95aa9f&name=Amir&email=amir%40email.com&phone=123456789',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
Redirects to senangPay's payment page.
No content
*The "Test it" option is available when using Firefox or Safari to test the API.
Handling 'Return' and 'Callback' from senangPay
1. The parameters will be send using the GET method.
2. The parameters are sent to URL as configured in the return URL. Refer above.
The table below lists the details of the elements:
status_id
This is to indicate the status of the payment. It only has three values: 2 for pending authorisation, 1 for successful and 0 for failed.
order_id
This is the order that is sent to senangPay. This is to identify the shopping cart transaction.
msg
This is the message to describe the payment status. The maximum length is 100 characters. Take note that the message may contain underscores. You can replace the underscore as a space when displaying the message to your customers. Example: Payment_was_successful.
transaction_id
This is the transaction ID used by senangPay. You can use this ID to track the transaction in senangPay. The maximum length is 100 characters. Example: 14363538840
hash
This is the data to ensure that data integrity has passed from senangPay to the merchant’s shopping cart. Refer to this section for more info.
3. Callback: The parameter will be sent via POST method.
Last updated