# Create Payment Session

Partner and Merchant will use their own API credentials as usual.&#x20;

## Credentials and Authentication

Using the authentication parameter below:

| username (Merchant API UID)        | 2aaa1633-e63f-4371-9b85-91d936aa56a1 |
| ---------------------------------- | ------------------------------------ |
| password (Merchant API Auth Token) | ZyUfF8EmyabcMWPcaocX                 |

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&#x20;

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

## API Credentials

![](https://1585239032-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHFsN346MN-4Eibh12Q%2F-MKStHpYipOFmmU843tY%2F-MKSwjrme80ReF3XzCbw%2FScreenshot%202020-10-25%20at%2011.59.36%20AM.png?alt=media\&token=d9016ca5-ad12-4eaa-8b42-d490e6fb39e1)

## Partner UID

Every partner will be issued one or more partner UID (partner\_uid). SecurePay will identify partner accounts by using this identifier. &#x20;

## 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>**)**

<figure><img src="https://1585239032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHFsN346MN-4Eibh12Q%2Fuploads%2FPodp6vWqWYrwNAhA3DFx%2FScreenshot%202022-09-28%20at%2010.45.26%20AM.png?alt=media&#x26;token=ab592f79-6065-4e36-8503-46a896f29002" alt=""><figcaption><p>Generated page</p></figcaption></figure>

| Parameter            | Description                                                                                                                                                                                                                                                                                         | Condition  | Example                                                                                         |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------- |
| order\_number        | Unique order number generated by merchant end for reference.                                                                                                                                                                                                                                        | Optional   | 20200425132755                                                                                  |
| buyer\_name          | Valid buyer full name in one line.                                                                                                                                                                                                                                                                  | Optional   | AHMAD AMSYAR MOHD ALI                                                                           |
| buyer\_email         | Valid buyer email address for status update                                                                                                                                                                                                                                                         | Optional   | <amsyar@gmail.com>                                                                              |
| buyer\_phone         | Valid buyer phone number e.g: +60123121989                                                                                                                                                                                                                                                          | Optional   | +60123121678                                                                                    |
| transaction\_amount  | Amount format: 100.20 , 1000.00, 7000.30                                                                                                                                                                                                                                                            | Compulsory | 1540.40                                                                                         |
| product\_description | <p>Meaningful Product Description e.g.</p><ul><li>Payment for order number 123</li><li>Payment for vintage table part #89782</li></ul>                                                                                                                                                              | Optional   | Payment for order no 20200425132755                                                             |
| callback\_url        | Server to server. Securepay platform will post the payment status.                                                                                                                                                                                                                                  | Optional   |                                                                                                 |
| redirect\_url        | Browser to browser, Securepay platform will post to the endpoint browser.                                                                                                                                                                                                                           | Optional   |                                                                                                 |
| partner\_uid         | Partner UID value                                                                                                                                                                                                                                                                                   | optional   | c52853e0-24d6 .....                                                                             |
| currency             | SecurePay platform will convert the transaction amount into Malaysian Ringgit (RM/MYR). You need to pass the original currency value e.g: transaction\_amount is 2 and currency is USD. So the conversion will be generated at the current rate e.g: 9.22 MYR. At this momment we only support USD. | optional   | USD                                                                                             |
| cancel\_url          | SecurePay page for bank selection. If set the cancel URL. Button cancel will appear.                                                                                                                                                                                                                | optional   | <p>e.g: </p><p><https://yourdom.com/securepay>\_<em>cancel?order\_</em>number=123123</p><p></p> |
| timeout\_url         | SecurePay page for bank selection. if set the timeout URL. The page will timeout within 3 minutes                                                                                                                                                                                                   | optional   | <p>e.g: </p><p><https://yourdom.com/securepay_timeout><em>?order\_</em>number=123123</p>        |

### 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>)

<figure><img src="https://1585239032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHFsN346MN-4Eibh12Q%2Fuploads%2FqnyUrmei0tUVaWPWeuoy%2FScreenshot%202022-09-28%20at%2010.51.23%20AM.png?alt=media&#x26;token=8cb26d55-f2ed-4cdd-88a4-ae282535566f" alt=""><figcaption></figcaption></figure>

### 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>)

<figure><img src="https://1585239032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHFsN346MN-4Eibh12Q%2Fuploads%2F0uolcTobEnYZmONPpklC%2FScreenshot%202022-09-28%20at%2010.58.35%20AM.png?alt=media&#x26;token=9f39c82c-4373-4f30-a8a3-f25bf4738b80" alt=""><figcaption></figcaption></figure>
