Bill Payment

Enable your customers to pay for purchases over-the-counter using Bill Payment. This payment method generates a unique barcode at checkout which your customer can take to supported Tesco Lotus branches to pay at their convenience. This guide walks you through the payment flow and details on how to implement.

Tesco Lotus charges a transaction fee of ฿10 to the customer at the payment point.

How To Enable

To enable Bill Payment, send an email requesting this feature to support@omise.co. You will need to review and accept new terms and conditions.

  • Supported Countries: Thailand
  • Minimum API version: 2017-11-02

Payment Flow

Customers paying via Bill Payment go through a offline payment flow. This means that once the charge is created, it must be authorized by the customer at a physical location.

The following screenshots illustrate this flow. First, the customer selects the payment method Tesco Lotus.

Bill payment flow

This creates a unique barcode which the customer can present at a Tesco Lotus payment counter to complete the charge. The barcode will expire in 24 hours.

Upon payment, Omise will send a webhook event (if enabled) indicating that the charge is complete.

Bill payment flow 2

Implementation

To create a Bill Payment charge, make the following API requests.

  1. Create a new payment source using Omise.js or one of the mobile SDKs (iOS and Android)
  2. Create a new charge using the identifier of the source created in Step 1.
  3. After receiving the charge completion webhook event, retrieve the charge to verify its status (optional, but recommended).

Use your public key to create the Bill Payment source on the client (a customer's browser or mobile phone). Use your secret key to create the Bill Payment charge on the server.

If both the creation and charge of a source must happen server-side, you can create and charge the source in a single API request using your secret key.

Creating a Source

Bill Payment payments are implemented as sources. When the customer confirms that they wish to pay with this payment method, create a new source specifying the type, amount, and currency.

The following examples demonstrate the creation of a new Bill Payment source for ฿4,000. Replace the omise_public_key and $OMISE_PUBLIC_KEY variables with your test public key found on the dashboard: https://dashboard.omise.co/test/keys

Using Omise.js, the type parameter is supplied as the first argument to the createSource method.

Omise.setPublicKey(omise_public_key);

Omise.createSource('bill_payment_tesco_lotus', {
  "amount": 400000,
  "currency": "THB"
}, function(statusCode, response) {
  console.log(response)
});

For testing, you can create the same request using curl.

curl https://api.omise.co/sources \
  -u $OMISE_PUBLIC_KEY: \
  -d "amount=400000" \
  -d "currency=THB" \
  -d "type=bill_payment_tesco_lotus"
{
  "object": "source",
  "id": "src_test_5h2focuw7iqs2ztt7gt",
  "livemode": false,
  "location": "/sources/src_test_5h2focuw7iqs2ztt7gt",
  "created_at": "2019-08-30T04:57:52Z",
  "type": "bill_payment_tesco_lotus",
  "flow": "offline",
  "amount": 400000,
  "currency": "THB",
  "mobile_number": null,
  "phone_number": null,
  "references": null,
  "name": null,
  "email": null,
  "barcode": null,
  "store_id": null,
  "store_name": null,
  "terminal_id": null,
  "installment_term": null,
  "zero_interest_installments": null
}

The id attribute is the source identifier (begins with src).

Creating a Charge

Create a charge specifying the parameters source, amount, and currency.

  • source specifies the source identifier.
  • amount and currency must match amount and currency of the source.

The following example demonstrates how to create a new charge using curl. Replace $OMISE_SECRET_KEY with your test secret key found on the dashboard: https://dashboard.omise.co/test/keys. Replace $SOURCE_ID with the id of the source.

curl https://api.omise.co/charges \
  -u $OMISE_SECRET_KEY: \
  -d "amount=400000" \
  -d "currency=THB" \
  -d "source=$SOURCE_ID"
{
  "object": "charge",
  "id": "chrg_test_5h2focx59d2q6d3orqs",
  "livemode": false,
  "location": "/charges/chrg_test_5h2focx59d2q6d3orqs",
  "created_at": "2019-08-30T04:57:52Z",
  "amount": 400000,
  "currency": "THB",
  "funding_amount": 400000,
  "funding_currency": "THB",
  "fee": 14600,
  "fee_vat": 1022,
  "interest": 0,
  "interest_vat": 0,
  "net": 384378,
  "description": null,
  "metadata": {},
  "status": "pending",
  "capture": true,
  "authorized": false,
  "schedule": null,
  "reversed": false,
  "reversed_at": null,
  "expires_at": "2019-08-31T04:57:52Z",
  "expired": false,
  "expired_at": null,
  "voided": false,
  "paid": false,
  "paid_at": null,
  "transaction": null,
  "refunded_amount": 0,
  "refunds": {
    "object": "list",
    "from": "1970-01-01T00:00:00Z",
    "to": "2019-08-30T04:57:53Z",
    "offset": 0,
    "limit": 20,
    "total": 0,
    "order": "chronological",
    "location": "/charges/chrg_test_5h2focx59d2q6d3orqs/refunds",
    "data": []
  },
  "link": null,
  "return_uri": null,
  "failure_code": null,
  "failure_message": null,
  "card": null,
  "customer": null,
  "ip": null,
  "dispute": null,
  "source": {
    "object": "source",
    "id": "src_test_5h2focm7chdhr6yvbww",
    "livemode": false,
    "location": "/sources/src_test_5h2focm7chdhr6yvbww",
    "created_at": "2019-08-30T04:57:51Z",
    "type": "bill_payment_tesco_lotus",
    "flow": "offline",
    "amount": 400000,
    "currency": "THB",
    "mobile_number": null,
    "phone_number": null,
    "references": {
      "expires_at": "2019-08-31T04:57:52Z",
      "device_id": null,
      "customer_amount": null,
      "customer_currency": null,
      "customer_exchange_rate": null,
      "omise_tax_id": "0105556091152",
      "reference_number_1": "639112814796046172",
      "reference_number_2": "966896868921810613",
      "barcode": "https://api.omise.co/charges/chrg_test_5h2focx59d2q6d3orqs/documents/docu_test_5h2focylsy3ocvt2gcg/downloads/DC6E45B2D5FBA278",
      "payment_code": null,
      "va_code": null
    },
    "name": null,
    "email": null,
    "barcode": null,
    "store_id": null,
    "store_name": null,
    "terminal_id": null,
    "installment_term": null,
    "zero_interest_installments": null
  },
  "platform_fee": {
    "percentage": null,
    "fixed": null,
    "amount": null
  },
  "disputable": false,
  "capturable": false,
  "reversible": false,
  "refundable": false,
  "authorize_uri": null
}

Creating a Source and Charge

Alternatively, you can create and charge a source in a single API request.

curl https://api.omise.co/charges \
  -u $OMISE_SECRET_KEY: \
  -d "amount=400000" \
  -d "currency=THB" \
  -d "source[type]=bill_payment_tesco_lotus"

Completing the Charge

At this point, you have created a new charge with its status set to pending. Possible values for charge status are pending, successful, failed, and expired. The following sections detail how to authorize a charge, receive its completion webhook event, and update its status.

Authorizing the Charge

To complete the charge, the customer must present the barcode image generated by the API at a Tesco Lotus payment counter. Within the charge response, find this information within the references object within source.

{
  "expires_at": "2019-08-31T04:57:51Z",
  "device_id": null,
  "customer_amount": null,
  "customer_currency": null,
  "customer_exchange_rate": null,
  "omise_tax_id": "0105556091152",
  "reference_number_1": "451796317689536543",
  "reference_number_2": "466915816968075536",
  "barcode": "https://api.omise.co/charges/chrg_test_5h2focodmj1s8zl8eol/documents/docu_test_5h2focqjv9x8my43bo3/downloads/10F27B0A74269A54",
  "payment_code": null,
  "va_code": null
}
  • barcode: Barcode image to display to the customer in SVG format.
  • expires_at: Charge expiration. Customer must use the barcode to pay at Tesco Lotus by this time.
  • omise_tax_id, reference_number_1, reference_number_2: Payment information encoded within the barcode.

Present the barcode in accordance with the Thailand Payment Barcode Standard. The height of the barcode must be no less than 1 centimeter. Below the barcode, present the payment information encoded within the barcode in the following format (including the leading pipe (|) character and the 00):

| omise_tax_id 00 reference_number_1 reference_number_2 charge.amount

Receiving the Charge Completion Event

The best way to be notified of the completion of a charge is using webhook events. Set up a location on your server to receive webhook events, and add this location as a webhook endpoint on the dashboard at https://dashboard.omise.co/test/webhooks. Once a charge is completed, a POST request will be sent to this endpoint with the charge response embedded.

The key attribute for the event object contains charge.complete and the data attribute contains the charge object. See Events API for event object structure.

Checking the Charge Status

After receiving this event, or after you have manually marked the charge, check the charge status again.

If the value of status has updated to successful, you got paid. If the value of status has updated to failed, check the failure_code and failure_message in the charge object for an explanation.

Possible failure codes are listed below.

Failure Code Description
timeout Payer did not take action before charge expiration.

Voids and Refunds

Bill Payment charges cannot be voided or refunded through Omise. Please contact Tesco Lotus customer service.

Limits

  • Minimum: 2000 (฿20)
  • Maximum: 4900000 (฿49,000)

Next Steps