Atome QR
Topics covered on this page
Accept online payments from Atome users through your website using the Atome QR payment method.
This guide walks you through the payment flow and details on how to implement.
How to enable
- Supported Countries: Singapore, Malaysia
- Minimum API version:
2017-11-02
To enable Atome QR, send an email requesting this feature to support@opn.ooo. You will need to review and accept new terms and conditions.
Payment flow
Customers paying via Atome QR go through an offline payment flow.
This means that once the charge is created, it can only be authorized offline
.
In this case, the customer must scan the generated QR code with the Atome app on their phone to complete the flow.
After the customer selects Atome QR as their preferred payment method, your site should generate the Atome QR code. The following screenshots demonstrate two flows: one using a desktop browser and one using a mobile browser. In both cases, once the QR code is visible, the customer must scan it to complete the payment.
Using a POS device
❶ The merchant shows the QR code on their POS device. ❷ The customer scans the code using their Atome app. ❸ The customer confirms the purchase through the app. ❹ Once you receive a webhook completion event, confirm the payment with the customer.
Implementation
To create a charge using Atome QR, make the following API requests.
- Create a new payment source (
type
:atome_qr
) using Omise.js or one of the mobile SDKs (iOS and Android) - Create a new charge using the identifier of the source created in Step 1.
- After receiving the charge completion webhook event, retrieve the charge to verify its status (optional, but recommended).
Use your public key to create the Atome QR source on the client (a customer's browser or mobile phone). Use your secret key to create the Atome QR 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
When the customer confirms that they wish to pay with this payment method, create a new source specifying the amount
, currency
, and type
.
Parameter | Type | Description |
---|---|---|
amount |
integer | (required) Amount in Subunits of source currency |
currency |
string | (required) Currency for source as three-letter ISO 4217 code (SGD for Singapore, MYR for Malaysia) |
type |
string | (required) Payment source type atome_qr |
phone_number |
string | (optional) Customer mobile number with a country code (example: +66876543210) |
items |
Item | (optional) Details of item |
shipping |
Address | (optional) Shipping address |
name |
string | (optional) Customer name |
email |
string | (optional) Customer email |
billing |
Address | (optional) Billing address |
The following examples demonstrate the creation of a new Atome QR source for ฿500. Replace the omise_public_key
and $OMISE_PUBLIC_KEY
variables with the test public key found on your dashboard.
Using Omise.js, the
type
parameter is supplied as the first argument to thecreateSource
method.
Omise.setPublicKey(omise_public_key);
Omise.createSource('atome_qr', {
"amount": 50000,
"currency": "SGD",
}, 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=50000" \
-d "currency=SGD" \
-d "type=atome_qr"
{
"object": "source",
"id": "src_5ug0fx8sn9xw75uf0h4",
"livemode": true,
"location": "/sources/src_5ug0fx8sn9xw75uf0h4",
"amount": 50000,
"barcode": null,
"bank": null,
"created_at": "2023-01-12T10:40:54Z",
"currency": "SGD",
"email": null,
"flow": "offline",
"installment_term": null,
"absorption_type": null,
"name": null,
"mobile_number": null,
"phone_number": null,
"platform_type": null,
"scannable_code": null,
"billing": null,
"shipping": null,
"items": [],
"references": null,
"store_id": null,
"store_name": null,
"terminal_id": null,
"type": "atome_qr",
"zero_interest_installments": null,
"charge_status": "unknown",
"receipt_amount": null,
"discounts": []
}
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
andcurrency
must matchamount
andcurrency
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 your dashboard.
Replace $SOURCE_ID
with the id
of the source.
curl https://api.omise.co/charges \
-u $OMISE_SECRET_KEY: \
-d "amount=50000" \
-d "currency=SGD" \
-d "source=$SOURCE_ID"
{
"object": "charge",
"id": "chrg_5ug0fxc8vlqb5zg9g4p",
"location": "/charges/chrg_5ug0fxc8vlqb5zg9g4p",
"amount": 50000,
"net": 48047,
"fee": 1825,
"fee_vat": 128,
"interest": 0,
"interest_vat": 0,
"funding_amount": 50000,
"refunded_amount": 0,
"transaction_fees": {
"fee_flat": "0.0",
"fee_rate": "3.65",
"vat_rate": "7.0"
},
"platform_fee": {
"fixed": null,
"amount": null,
"percentage": null
},
"currency": "SGD",
"funding_currency": "SGD",
"ip": null,
"refunds": {
"object": "list",
"data": [],
"limit": 20,
"offset": 0,
"total": 0,
"location": "/charges/chrg_5ug0fxc8vlqb5zg9g4p/refunds",
"order": "chronological",
"from": "1970-01-01T00:00:00Z",
"to": "2023-01-12T10:40:56Z"
},
"link": null,
"description": null,
"metadata": {},
"card": null,
"source": {
"object": "source",
"id": "src_5ug0fwqf13y0bnj48v1",
"livemode": true,
"location": "/sources/src_5ug0fwqf13y0bnj48v1",
"amount": 50000,
"barcode": null,
"bank": null,
"created_at": "2023-01-12T10:40:52Z",
"currency": "SGD",
"email": null,
"flow": "offline",
"installment_term": null,
"absorption_type": null,
"name": null,
"mobile_number": null,
"phone_number": null,
"platform_type": null,
"scannable_code": {
"object": "barcode",
"type": "qr",
"image": {
"object": "document",
"livemode": true,
"id": "docu_5ug0fxibl7d1ee5hqj8",
"deleted": false,
"filename": "qrcode.jpg",
"location": "/charges/chrg_5ug0fxc8vlqb5zg9g4p/documents/docu_5ug0fxibl7d1ee5hqj8",
"kind": "qr",
"download_uri": "https://api.omise.co/charges/chrg_5ug0fxc8vlqb5zg9g4p/documents/docu_5ug0fxibl7d1ee5hqj8/downloads/679C6686556F8F0A",
"created_at": "2023-01-12T10:40:55Z"
}
},
"billing": null,
"shipping": null,
"items": [],
"references": null,
"store_id": null,
"store_name": null,
"terminal_id": null,
"type": "atome_qr",
"zero_interest_installments": null,
"charge_status": "pending",
"receipt_amount": null,
"discounts": []
},
"schedule": null,
"customer": null,
"dispute": null,
"transaction": null,
"failure_code": null,
"failure_message": null,
"status": "pending",
"authorize_uri": null,
"return_uri": null,
"created_at": "2023-01-12T10:40:55Z",
"paid_at": null,
"expires_at": "2023-01-12T22:40:55Z",
"expired_at": null,
"reversed_at": null,
"zero_interest_installments": true,
"branch": null,
"terminal": null,
"device": null,
"authorized": false,
"capturable": false,
"capture": true,
"disputable": false,
"livemode": true,
"refundable": false,
"reversed": false,
"reversible": false,
"voided": false,
"paid": false,
"expired": false
}
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=50000" \
-d "currency=SGD" \
-d "source[type]=atome_qr"
Setting the QR code to expire
By default, the QR code expires 12 hours after creation.
You can assign different expiration periods to each QR code by entering a timestamp between 30 seconds and 12 hours from the current time in the expires_at
field of the Charge API. If the timestamp is entered correctly, the QR code will expire at the designated time instead of the default period.
After the charge is created, you can also manually call our Expire API to expire a pending charge.
curl https://api.omise.co/charges \
-u $OMISE_SECRET_KEY: \
-d "amount=50000" \
-d "currency=SGD" \
-d "source[type]=atome_qr" \
-d "expires_at=2020-12-17T00:00:00Z"
Completing the charge
At this point, you have created a new charge with its status
set to pending
.
Other possible values for charge status
are successful
, failed
, and expired
.
The following sections detail how to authorize a charge, receive its completion webhook event, and update its status.
This sequence diagram shows the entire flow.
Authorizing the charge
Present the customer with QR code generated at charge creation. To authorize the charge, the customer scans the QR code using their Atome app.
You can simulate the authorization phase in test mode. Go to the specific charge on the dashboard, click on Actions
and manually mark the charge as Successful
or Failed
.
Find the QR code nested within the charge object as follows:
charge:
source:
scannable_code:
image:
download_uri: QR code image to present to the customer
{
"object": "barcode",
"type": "qr",
"image": {
"object": "document",
"livemode": true,
"id": "docu_5ug0fwygvm72nwdimcn",
"deleted": false,
"filename": "qrcode.jpg",
"location": "/charges/chrg_5ug0fwu3inwr71cl37n/documents/docu_5ug0fwygvm72nwdimcn",
"kind": "qr",
"download_uri": "https://api.omise.co/charges/chrg_5ug0fwu3inwr71cl37n/documents/docu_5ug0fwygvm72nwdimcn/downloads/09AEF554B5700171",
"created_at": "2023-01-12T10:40:53Z"
}
}
Receiving the charge completion event
The best way for you 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.
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, retrieve the charge using its id
and confirm that its status
matches the status
of the charge contained in the event.
If the value of status
is successful
, you got paid.
If the value of status
is failed
, check the failure_code
and failure_message
in the charge object for an explanation.
Possible failure codes are listed below.
Failure Code | Description |
---|---|
payment_expired |
Payment expired. |
payment_rejected |
Payment rejected by issuer. |
failed_processing |
General payment processing failure. |
Voids and refunds
Atome QR charges can be partially or fully refunded within 60 days of the transaction date.
Limits
Singapore
- Minimum:
150
(SGD 1.50) - Maximum:
300000
(SGD 3,000.00)
Malaysia
- Minimum:
1000
(MYR 10.00) - Maximum:
500000
(MYR 5,000.00)