# Misc

WARNING

Not all REST API endpoints are available to all users. If you need access to functionality like charge creation, please contact us through the dashboard(opens new window)

A set of endpoints which could help you integrate with XanPay REST API.

# Supported methods

Returns the list of supported payment methods with their currencies.

Endpoint

GET /methods

Request Example

curl 
-H "Content-Type: application/json"
-u {API_KEY}:{API_SECRET}
"https://api.xanpay.com/methods"

Response

[
    {
        "country": "SG",
        "currency": "SGD",
        "methods": [
            {
                "method": "paynow",
                "max": 500,
                "name": "Paynow",
                "icon": "cdn path"
            },
        ...
        ]      
    },
    ...
]

# FX Conversion

Executes conversion between currencies based on XanPay rates.

Endpoint

GET /forex

Url parameters

Parameter Default Description
sourceCurrency none Source currency
sourceAmount none Amount of being converted
destinationCurrency none Final currency

Request Example

curl 
-H "Content-Type: application/json"
-u {API_KEY}:{API_SECRET}
"https://api.xanpay.com/forex?sourceCurrency=HKD&sourceAmount=150&destinationCurrency=SGD"

Response

{
   "amount": 26.25,
   "rate": 0.18    
}

Returns generated checkout link based on params.

Endpoint

POST /checkout-link

Payload attributes

Parameter Required Description
amount Required Amount to be charged
currency Required Currency in which you set the amount.
apiKey Required A unique key identifying a partner generated in dashboard
orders Optional A list of orders (see below)
paymentMethods Optional An object of [payment methods](#Payment methods) (see below)
notifyUrl Optional The specified url will be notified as POST request when charge is completed
notifyPayload Optional Any payload you want to include in request after successful completed charge. Will be encoded in base64
redirectUrl Optional Enables a button that takes the customer back to the specified url

# Order object

You can provide a list of orders for each charge, they will be displayed in the final invoice and will be sent in webhook payload. About webhook and callbacks

Parameter Required Description
id Required Merchant's order id
name Required Order's name
quantity Required Quantity
amount Required Amount for the order

# Payment methods

You can specify payment methods available for each country in options.

      const paymentMethods = {
          'TH': ['prompt-pay', 'alipay-hk'],
          'HK': ['fps'],
      };

Countries and payment methods are available in XanPay API

Request Example

curl 
  -X POST https://api.xanpay.com/checkout-link
  -u {API_KEY}:{API_SECRET}
  -d '{
	"amount": "1000",
	"currency": "SGD",
	"apiKey": "0222598c12e3b52dbbfa777f17688a8a",
	"paymentMethods": {
		"SG": ["paynow"]
	},
	"redirectUrl": "www://redirect.com",
	"notifyUrl": "www://notify.com",
	"notifyPayload": "somePayload",
	"orders": [{
		"id": "58109ds9a01",
		"name": "IPhone 12",
		"quantity": 1,
		"amount": 1000
	}]
  }'

Response

{
    "checkoutLink": "https://checkout.xanpay.com?apiKey=0222598c12e3b52dbbfa777f17688a8a&amount=1000&currency=SGD&orders=W3siaWQiOiI1ODEwOWRzOWEwMSIsIm5hbWUiOiJJUGhvbmUgMTIiLCJxdWFudGl0eSI6MSwiYW1vdW50IjoxMDAwfV0=&redirectUrl=www%3A%2F%2Fredirect.com&notifyUrl=www://notify.com&notifyPayload=somePayload&paymentMethods=eyJTRyI6WyJwYXlub3ciXX0=&hash=PM2FcirwD+nH+UrJqwBPpO/1qwc6lz9Q3KOodFrotuI="
}