senangPay API guide

A general guide for integrating with senangPay's APIs.

Welcome to the senangPay API guide! This guide aims to provide functionality for merchants to retrieve information from senangPay without the need to log in to the senangPay dashboard. This is useful for merchants that have their own system and do not wish to log in to both senangPay and their own systems to manage their business.

A. Query Order Status

This is to retrieve transactions result for order id as passed using Open API method.

1. URL: https://app.senangpay.my/apiv1/query_order_status

2. Method: GET

3. Parameters:

  • merchant_id
  • order_id
  • hash

4. Return format: JSON

5. In order to generate the hash, create a single string consisting of (according to sequence):

  • merchant_id
  • secret key
  • order_id

6. Please use md5 to hash the string. Here is a sample code in PHP:

The string to be hashed is 54316046480557421245-957123 which will generate the hash value:

  • 368c7a62e622a553107dc5b30849a5f2

7. If you choose SHA256, here is a sample code in PHP:

The string to be hashed is 54316046480557421245-957123 which will generate the hash value:

  • b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad

B. Query Transaction Status

This is to retrieve transaction result for a specific transaction reference

1. URL: https://app.senangpay.my/apiv1/query_transaction_status

2. Method: GET

3. Parameters:

  • merchant_id
  • transaction_reference
  • hash

4. Return format: JSON

5. In order to generate the hash, create a single string consisting of the value (according to sequence)

  • merchant_id
  • secret key
  • transaction_reference

6. Please use md5 to hash the string. Here is a sample code in PHP:

The string to be hashed is 54316046480557421245-957123 which will generate the hash value:

  • 368c7a62e622a553107dc5b30849a5f2

7. If you choose SHA256, here is a sample code in PHP:

The string to be hashed is 54316046480557421245-957123 which will generate the hash value:

  • b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad

C. Get Transaction List

This is to retrieve transaction result for a specific transaction reference

1. URL:

https://app.senangpay.my/apiv1/get_transaction_list

2. Method: GET

3. Parameters:

  • merchant_id
  • timestamp_start
  • timestamp_end
  • hash

4. Return format: JSON

5. In order to generate the hash, create a single string consisting of the value (according to sequence)

  • merchant_id
  • secret key
  • timestamp_start
  • timestamp_end

6. Please use md5 to hash the string. Here is a sample code in PHP:

The string to be hashed is 54316046480557421245-957123 which will generate the hash value:

  • 368c7a62e622a553107dc5b30849a5f2

7. If you choose SHA256, here is a sample code in PHP:

The string to be hashed is 54316046480557421245-957123 which will generate the hash value:

  • b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad

8. The value of timestamps must be greater than 0 and the end timestamp must be greater than the starting timestamp.

9.. Timestamps refer to UNIX timestamp.

 

Please note:

senangPay no longer offers MOTO transactions for new merchants. The following sections serve as a reference for legacy merchants using MOTO only.

D. API Endpoint for MOTO Transaction

Creating MOTO Payment

 

Item Detail
API Endpoint http://app.senangpay.my/apiv1/pay_cc

1.1 Authorisation header

 

Type Basic
Username < your-merchant-id >
As listed in the profile settings page.
Password None, leave empty.

1.2 Request Paramater (all is mandatory)

 

Parameter Name Parameter value/description
order_id Your order id. Can be number or string. Other character is invalid.
E.g. 1234
name Your customer's name. Maximum length is 100.
E.g. Abu Bin Ali
phone Your customer's phone number.
E.g. 0123456789
email Your customer's e-mail.
E.g. ahmad@google.com
detail Your order details. Maximum length is 100.
E.g. Order for product id #4
amount Your order amount in integer format. Convert from decimals as necessary.
E.g. if the amount is RM 2.00, you need to send 200.
cc_number Your customer's credit card number.
cc_exp Your customer's credit card expiration date in MMYY format.
E.g. if the card expires on January 2017, you need to send 0117
cc_cvv Your customer's credit card CVV number.
E.g. 123
hash

A string hashed with your secret key (from your profile settings page) in HMAC hashing algorithm with SHA256 in the following format:

< your merchant id >< name >< email >< phone >< detail >< order_id >< amount >

*without the <  > characters

1.3 Response Parameter

Parameter Name Parameter value/description
status Your transaction status. 1 if success. 0 if failed.
transaction_id Your transaction ID number.
order_id Your original order ID.
amount_paid Amount transacted from the credit card in integer format.
E.g. if the amount transacted is RM 2.00, it will output 200.
msg Transaction status message. If it was successful you will receive ‘Payment was successful’. If the transaction failed, you will receive the error message in this parameter for further checking.
hash

A string hashed with your secret key (from your profile settings page) in HMAC hashing algorithm with SHA256 in the following format:

< your merchant id >< status_id >< order_id >< transaction_id >< amount_paid >< msg >

*without the <  > character

2. Get MOTO Payment Details By Order ID

This endpoint is helpful for determining order status before attempting another payment if the previous payment creation was failed return a server error.

Item Details
API endpoint http://app.senangpay.my/apiv1/order/

 

2.1 Authorisation Header

Type Basic
Username < your-merchant-id >
As listed in the profile settings page.
Password None, leave empty.

 

2.2 URL Parameter

Parameter Name Parameter value/description
order_id Your order id. Can be number or string. Other character is invalid.
E.g. 1234 

2.3 Response Parameter

Parameter Name Parameter value / description
status Your transaction status. 1 if success. 0 if failed.
msg Query status message. If it was successful you will receive ‘Query was successful’. If the query failed in any way, you will receive the error message in this parameter for further checking.
data

An array of MOTO transactions that matches the given order ID, sorted by newest transaction first.

Please refer to MOTO Data Transaction Response section for type of data returned.

hash

A string hashed with your secret key (from your profile setting page) in HMAC hashing algorithm with SHA256 for validity of data returned by us in the following format:

< your merchant id >< order-id >

*without the <  > characters

3. Get MOTO Payment Details By Transaction Reference

Item Detail
API endpoint http://app.senangpay.my/apiv1/order/

 

3.1 Authorisation header

Type Basic
Username < your-merchant-id >
As listed in the profile settings page.
Password None, leave empty.

 

3.2 URL Parameter

Parameter Name Parameter value/description
transaction_reference The transaction reference number to check.

3.3 Response Parameter

Parameter Name Parameter value/description
status Your transaction status. 1 if successful, 0 if failed.
msg Query status message. If it was successful you will receive ‘Query was successful’. If the query failed in any way, you will receive the error message in this parameter for further checking.
data

A detail of the MOTO transaction that matches the given transaction reference.

Please refer to "MOTO Data Transaction Response" section for the type of data returned.

hash

A string hashed with your secret key (from your profile setting page) in HMAC hashing algorithm with SHA256 for validity of data returned by us in the following format:

< your merchant id >< transaction reference >

*without the <  > characters

4. MOTO Data Transaction Response

This is the MOTO transaction data, structured for response for any given endpoint querying for MOTO transaction details.

4.1 Response Parameter

Key Value details/description
transaction_reference The transaction reference number
buyer_contact

Buyer contact details object as sent when creating the original payment. Consist of the following key values:

KeyValue

  • name: Buyer’s name
  • email: Buyer’s e-mail
  • phone: Buyer’s phone
order_detail

Transaction details object of the MOTO transaction. Consist of the following key values:

KeyValue

  • grand_total: Transaction amount paid/needs to be paid in integer format. i.e. RM 2.00 will be returned as 200
payment_info

Payment info details object. Consist of the following key values:

KeyValue

  • transaction_date: Transaction date in hh:mm day month year i.e.
    08:07 19 May 2017
  • payment_mode: Will return only ‘Credit Card’ for now.
  • status: Payment status. Returned values will be one of:
    • paid
    • pending payment
    • failed
date_created

Transaction date in hh:mm day month year i.e.

08:07 19 May 2017