CollectionsHosted PaymentsPayments

Create a Hosted Payment

POST
/v1/hosted-payments

Authorization

authorization
AuthorizationBearer <token>

Set Your Secret API Key

In: header

Header Parameters

Idempotency-Key?string

A unique value, eg. a UUID.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

amount*number

A positive integer value in the specified currency's smallest unit. e.g. $10 would be represented as 1000 (cents).

Range1 <= value <= 20000000
channel*string

Channel the customer pays from. Not applicable for FPX payments.

Value in

  • "APP_IOS"
  • "APP_ANDROID"
  • "WEB_BROWSER_DESKTOP"
  • "WEB_BROWSER_MOBILE"
currency*string

Three-letter ISO 4217 currency code in full uppercase.

Match^SGD$
hostedPaymentMethodId?string

Token from a previously tokenized Hosted Payment to use for creating this payment without requiring your customer to key in their payment method information again.

The token can be found in this field of a previous successful Hosted Payment that was created with tokenization=true.

Use these values to simulate specific success and failure scenarios:

  • hpm_TESTMODESUCCEEDED: successful payment
  • hpm_TESTMODEFAILED_PAYLAHWALLETDELINKED: customer has unlinked their PayLah! wallet.
  • hpm_TESTMODEPENDING_INSUFFICIENTFUNDSPENDINGTOPUP: there is insufficient balance in the customer's PayLah! wallet, and they have been prompted to top up.
method*string

Payment method.

Value in

  • "PAYLAH"
  • "PAYNOW"
  • "FPX_ONLINEBANKING"
referenceId?string

A string to reference (e.g. your order ID, a payment ID, etc.) which can be used to reconcile the hosted payment with your own systems. This cannot exceed 255 characters.

Length0 <= length <= 255
returnUrl?string

For a web browser based channel, use a HTTPS URL. For a native mobile based channel, use an App Deep Link URL. This should not be set if hostedPaymentMethodId is provided in the request.

Match^[A-Za-z][A-Za-z0-9+\-\.]+:\/\/[^:\?\/]+(:[0-9]+)?((\/[^\/\?]*)*\/?(\?[^\?\/]*)?)?$
Length0 <= length <= 2048
tokenization?boolean

Only applicable to method=PAYLAH. Set to true to tokenize your customer's payment method information, allowing you to collect future payments from this customer using Hosted Payments without requiring them to key in their payment method information again.

You can find the token in the hostedPaymentMethodId field, after your customer has successfully completed this payment.

Tokenization is also sometimes known as binding or linking your digital wallet.

Response Body

*/*

curl -X POST "https://example.com/v1/hosted-payments" \  -H "Content-Type: application/json" \  -d '{    "amount": 1,    "channel": "APP_IOS",    "currency": "string",    "method": "PAYLAH"  }'
{  "amount": 0,  "channel": "string",  "createdAt": "string",  "currency": "string",  "customerProxy": "string",  "expiredAt": "string",  "hostedPaymentMethodId": "string",  "id": "string",  "method": "string",  "payer": {    "email": "string",    "firstName": "string",    "fullName": "string",    "lastName": "string",    "payerBank": "string",    "phone": "string",    "returnedName": "string"  },  "paymentInformation": [    {      "itemName": "string",      "itemReference": "string",      "numberOfUnits": 0,      "totalTaxAmount": 0,      "unitAmount": 0    }  ],  "redirectUrl": "string",  "referenceId": "string",  "resultCode": "string",  "returnUrl": "string",  "status": "string",  "tokenization": true,  "transactionReference": "string",  "underlyingErrorCode": "string",  "underlyingErrorMessage": "string",  "updatedAt": "string"}