Create Payment Session

Partner and Merchant will use their own API credentials as usual.

Credentials and Authentication

Using the authentication parameter below:

To create a session. the merchant needs to use basic authentication

To send basic auth credentials with Curl, use the "-u login: password" command-line option. Curl automatically converts the login: password pair into a Base64-encoded string and adds the "Authorization: Basic [token]" header to the request. In this Curl request with Basic Auth Credentials example, we send a request with basic authorization credentials

curl https://securepay.my/echo -u "login:password"

API Credentials

Partner UID

Every partner will be issued one or more partner UID (partner_uid). SecurePay will identify partner accounts by using this identifier.

Request Parameters

Please use POST method. The only compulsory parameter is the transaction_amount however merchants usually needs to supply order number in order to keep track record on their side. Your POST request will be returned in JSON format (later you can access payment_url)

Curl Request

curl -X POST https://sandbox.securepay.my/api/apis/payments -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX -d 'transaction_amount=200&order_number=231212&cancel_url=https://test.com'

Result

{"payment_url":"https://sandbox.securepay.my/api/apis/GSHJD1664332374/payment_session","data":{"buyer_name":null,"buyer_email":null,"buyer_phone":null,"transaction_amount":"200.00","order_number":"231212","product_description":"Payment for order no. 231212","slug":"GSHJD1664332374","callback_url":null,"redirect_url":null,"cancel_url":"https://test.com","timeout_url":null,"currency":"MYR","currency_amount":"200.00","partner_uid":null,"other_params":null,"created_at":"2022-09-28T10:32:54.087+08:00","updated_at":"2022-09-28T10:32:54.087+08:00"}

The payment form can be accessed through payment_url https://sandbox.securepay.my/api/apis/GSHJD1664332374/payment_session

Payment Form (https://sandbox.securepay.my/api/apis/GSHJD1664332374/payment_session)

Set buyer_name,buyer_email,buyer_phone,callback_url and redirect_url

Request

curl -X POST https://sandbox.securepay.my/api/apis/payments -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX -d 'transaction_amount=200&order_number=231213&cancel_url=https://test.com&buyer_name=Amir Haris&buyer_email=amir@test.com&buyer_phone=01239997978&callback_url=https://test.com/callback&redirect_url=https://test.com/redirect'

Result

{"payment_url":"https://sandbox.securepay.my/api/apis/RLIXQ1664333462/payment_session","data":{"buyer_name":"Amir Haris","buyer_email":"amir@test.com","buyer_phone":"01239997978","transaction_amount":"200.00","order_number":"231213","product_description":"Payment for order no. 231213","slug":"RLIXQ1664333462","callback_url":"https://test.com/callback","redirect_url":"https://test.com/redirect","cancel_url":"https://test.com","timeout_url":null,"currency":"MYR","currency_amount":"200.00","partner_uid":null,"other_params":null,"created_at":"2022-09-28T10:51:02.267+08:00","updated_at":"2022-09-28T10:51:02.267+08:00"}

Generated Payment Form (https://sandbox.securepay.my/api/apis/RLIXQ1664333462/payment_session)

Set currency and product_description

Request

curl -X POST https://sandbox.securepay.my/api/apis/payments -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX -d 'transaction_amount=200&order_number=231214&cancel_url=https://test.com&buyer_name=Amir Haris&buyer_email=amir@test.com&buyer_phone=01239997978&callback_url=https://test.com/callback&redirect_url=https://test.com/redirect&currency=USD&product_description=Electronic Picture Frame with order number 231214'

Result

{"payment_url":"https://sandbox.securepay.my/api/apis/MKJUP1664333854/payment_session","data":{"buyer_name":"Amir Haris","buyer_email":"amir@test.com","buyer_phone":"01239997978","transaction_amount":"922.15","order_number":"231214","product_description":"Electronic Picture Frame with order number 231214","slug":"MKJUP1664333854","callback_url":"https://test.com/callback","redirect_url":"https://test.com/redirect","cancel_url":"https://test.com","timeout_url":null,"currency":"USD","currency_amount":"200.00","partner_uid":null,"other_params":null,"created_at":"2022-09-28T10:57:34.874+08:00","updated_at":"2022-09-28T10:57:34.874+08:00"}

Generated Payment Form (https://sandbox.securepay.my/api/apis/MKJUP1664333854/payment_session)

Last updated