Test Hosted Payment Page API

After you set up accepting payments in the Publisher Portal, you can quickly test a payment flow for a payment method.

This tutorial only shows how to test for a specific payment method. If you are interested in our Payment Selection Page, you can follow this guide.

What you'll learn

  • Initiating a payment request.

  • What your customer will experience upon payment request.

  • What your customer will experience upon a successful payment notification.


Step 1: Initiate the payment request

  1. Initiate the payment request by calling the /init endpoint to collect your payment transaction ID. Use the curl below and populate it with:

Other parameters have been populated with dummy data for testing purposes below. They can be changed and populated properly as part of your integration. More details on the parameters of the /init endpoint can be found here.

{
    "initRequest": {
        "country": [SELECTED_COUNTRY],
        "payType": [SELECTED_PAYMENT_CHANNEL_ID],
        "apiKey": [COUNTRY_API_KEY],
        "orderId": "12321312321314",
        "currency": [SELECTED_CURRENCY],
        "items": [
            {
                "code": "1",
                "price": 50.00,
                "name": "Test Item"
            }
        ],
        "profile": {
            "entry": [
                {
                    "key": "user_id",
                    "value": "105"
                }
            ]
        }
    }
}

Below is an example using a dummy sandbox API Key for Singapore, with Singapore Dollar (SGD) as a currency and Card Payments as a payment method.

{
    "initRequest": {
        "country": 702,
        "payType": 427,
        "apiKey": "32774abe1cd7d8bae650ea48265e",
        "orderId": "12321312321314",
        "currency": 702,
        "items": [
            {
                "code": "1",
                "price": 50.00,
                "name": "Test Item"
            }
        ],
        "profile": {
            "entry": [
                {
                    "key": "user_id",
                    "value": "105"
                }
            ]
        }
    }
}'
  1. The following response will be returned:

{
   "initResult": {
       "resultCode": 0,
       "txnId": 7122167282516076304
   }
}

Step 2: Redirect your user to the payment page to complete payment

  1. Utilize the received txnId from Step 1 to redirect your user to the following URL:

Below is an example of what it would look like for the transaction initiated above for Card Payments in Singapore:

Complete a test transaction with Card Payments in Singapore and use the following test card below.


Step 3: Receive the successful payment notification

  1. You will receive a notification on the Complete Notification URL, including the following fields as query parameters:

  1. Respond to this notification with a success message ResultCode=0 or a failure message (including an appropriate error code).

If you want to try receiving an error response, simply replace the error code digit with any of the available error codes, which you can access here.


Step 4: Check the status of a successful payment using the InquiryPaymentResult API call

  1. Use the InquiryPaymentResult API call below to inquire about the payment status of your transaction:

{
    "inquiryPaymentRequest":
    {
        "apiKey" : "32774abe1cd7d8bae650ea48265e",
        "txnId" : "7144594637002072212",
        "needStatusFinal": "true"

    }
}'
  1. The result will appear as follows:

{
    "paymentResult": {
        "orderId": 12321312321314,
        "profile": {
            "entry": [
                {
                    "key": "PaymentType",
                    "value": 427
                },
                {
                    "key": "isStatusFinal",
                    "value": true
                },
                {
                    "key": "status",
                    "value": "success"
                }
            ]
        },
        "resultCode": 0,
        "resultDesc": "",
        "totalPrice": 50,
        "txnId": 7144594637002072212
    }
}

Next steps

Last updated