One-Time Payment

1. Create a Payment

To start accepting payments on your website, app or platform, create a Payment object with the order details.

A Payment object captures the life cycle of a payment, keeping track of the history of payment attempts and the flow of the payment's statuses. Below is an example of calling a One-Time PayNow QR API.

curl https://sandbox.xfers.io/api/v4/payments \
 --header 'content-type: application/vnd.api+json' \
 -u test_api_key:secret_key \
 -d '
{
  "data": {
    "attributes": {
      "amount": "0.1",
      "referenceId": "pennytest_1",
      "paymentMethodType": "paynow",
      "expiredAt": "2020-12-03T20:03:53+07:00",
      "paymentMethodOptions": {
        "merchantPrefix": "PHOHANOI"
      }
    }
  }
}

2. Show payment instructions to your customers if any

This is a sample response you will get.

# Sample Response

{
    "data": {
        "id": "contract_e5855b3297304ec78b904bdb08ae1685",
        "type": "payment",
        "attributes": {
            "status": "pending",
            "amount": "0.1",
            "createdAt": "2020-12-03T17:19:15+08:00",
            "description": null,
            "expiredAt": "2020-12-03T20:03:53+07:00",
            "referenceId": "pennytest_1",
            "fees": "0.0",
            "paymentMethod": {
                "id": "paynow_5e9f826617f35e45ea3a1e5464ee28b4",
                "type": "paynow",
                "qrCodeDisplayImage": "iVBORw0KGgoAAAANSUhEUgAAAMMAAADDCAYAAAA/f6WqAAAABGdBTUEAALGPC/.../wNy78pYJ3AiFQAAAABJRU5ErkJggg=="
            }
        }
    }
}

3. Get notified when payment has been made successfully

Once a payment has been made successfully, we will notify you with a callback. The payment's status will now be paid.

# Sample Callback for one-time Paynow QR

{
  "data": {
    "id": "contract_e5855b3297304ec78b904bdb08ae1685",
    "type": "payment",
    "attributes": {
      "status": "paid",
      "amount": "0.1",
      "createdAt": "2020-12-03T17:19:15+08:00",
      "description": null,
      "expiredAt": "2020-12-03T20:03:53+07:00",
      "referenceId": "pennytest_1",
      "fees": "0.0",
      "paymentMethod": {
        "id": "paynow_5e9f826617f35e45ea3a1e5464ee28b4",
        "type": "paynow",
        "qrCodeDisplayImage": "iVBORw0KGgoAAAANSUhEUgAAAMMAAADDCAYAAAA/f6WqAAAABGdBTUEAALGPC//wNy78pYJ3AiFQAAAABJRU5ErkJggg=="
      }
    }
  }
}
# Sample Callback for one-time Virtual Account

{
  "data":{
    "id":"contract_1279afd994c744d2888204805396eb4f",
      "type":"payment",
      "attributes":{
        "status":"paid",
        "amount":"101.0",
        "createdAt":"2022-02-10T14:50:16+08:00",
        "description":"This is the first order",
        "expiredAt":"2022-06-20T17:48:42+07:00",
        "referenceId":"ORDER_0009jlsdjfdfgs",
        "fees":"0.0",
        "paymentMethod":{
          "id":"va_12ef56604fc143db504c4e611a40e373",
          "type":"virtual_bank_account",
          "referenceId":"ORDER_0009jlsdjfdfgs",
          "instructions":{"bankShortCode":"CIMB","accountNo":"8848095729011529"}
    }
   }
  }
}

Present the payment results to your customer, and you may now fulfil your order.

4. Get notified when funds are available for withdrawal or transfer

In most cases, funds may not be immediately available for withdrawal or transfer. We will notify you with a callback when funds have been made available. The payment's status will then be set to completed.


Did this page help you?