Atome QR

หัวข้อทั้งหมดในหน้านี้

เพิ่ม Atome QR เป็นตัวเลือกการรับชำระเงินสำหรับลูกค้าให้กับร้านค้าของคุณ โดยในคู่มือแนะนำการใช้งานนี้จะอธิบายขั้นตอนการชำระเงิน และรายละเอียดวิธีการเปิดรับชำระเงินผ่าน Atome QR

การเปิดรับชำระเงิน

  • ประเทศที่รองรับ: ไทย, สิงคโปร์, มาเลเซีย
  • API เวอร์ชันล่าสุดที่รองรับ: 2017-11-02

ร้านค้าที่ต้องการเปิดใช้ระบบ Atome QR กรุณาส่งอีเมลมาที่ support@omise.co ทางทีมงานโอมิเซะจะส่งข้อกำหนดและเงื่อนไขการใช้บริการให้ร้านค้าได้พิจารณาและลงลายมือชื่อก่อนเปิดใช้งานจริง

ขั้นตอนการชำระเงิน

ผู้ซื้อที่ต้องการชำระเงินผ่าน Atome QR จะต้องผ่านขั้นตอนการชำระเงินและทำการยืนยันรายการแบบออฟไลน์ โดยผู้ซื้อจะต้องทำการสแกนคิวอาร์โค้ดโดยใช้แอปพลิเคชัน Atome ของตนเองเพื่อยืนยันรายการ

เมื่อผู้ซื้อเลือก Atome QR เป็นช่องทางการชำระเงินแล้ว เว็บไซต์ของร้านค้าจะมีการแสดงคิวอาร์โค้ดเพื่อให้ผู้ซื้อสแกน ภาพด้านล่างนี้แสดงขั้นตอนการรับชำระเงิน 2 ประเภทคือ การชำระเงินผ่านเบราว์เซอร์บนคอมพิวเตอร์และการชำระเงินผ่านเบราว์เซอร์บนมือถือ เมื่อร้านค้าได้แสดงคิวอาร์โค้ดขึ้นมาแล้ว ผู้ซื้อจะต้องสแกนเพื่อชำระเงิน

การใช้งานผ่านเครื่อง POS

Atome QR

❶ ร้านค้าแสดงคิวอาร์โค้ดบนเครื่อง POS (ระบบขายหน้าร้าน) ของร้าน ❷ ผู้ซื้อสแกนคิวอาร์โค้ดโดยใช้แอปพลิเคชัน Atome ❸ ผู้ซื้อยืนยันการทำรายการผ่านแอปพลิเคชัน ❹ เมื่อร้านค้าได้รับการแจ้งเตือนการทำรายการสำเร็จแล้ว โปรดยืนยันการชำระเงินกับผู้ซื้อ

การติดตั้งใช้งาน

ในการสร้างรายการรับชำระเงินผ่าน Atome QR ให้ร้านค้าส่งคำสั่ง API ดังนี้

  1. สร้าง payment source (type: atome_qr) โดยใช้ Omise.js, omise-ios หรือ omise-android
  2. สร้าง charge โดยใช้ source จากขั้นตอนแรก
  3. เมื่อผู้ซื้อทำรายการสำเร็จและร้านค้าได้รับ webhook event หรือ charge.complete แล้ว เราแนะนำให้ตรวจสอบสถานะรายการด้วยตนเองอีกครั้งเพื่อความแม่นยำ

การสร้าง source เพื่อรับชำระเงินผ่าน Atome QR จะเกิดขึ้นในฝั่งของผู้ซื้อ (client-side) เช่น บนเว็บไซต์หรือโทรศัพท์มือถือของผู้ซื้อ โดยร้านค้าจะต้องใช้ public key

ส่วนการสร้างรายการ (charge) เพื่อรับชำระเงินผ่าน Atome QR จะเกิดขึ้นในฝั่งของร้านค้า (server-side) โดยร้านค้าจะต้องใช้ secret key

หมายเหตุ: หากมีความจำต้องสร้างทั้งรายการและ source ในฝั่งร้านค้า (server-side) สามารถทำพร้อมกันได้เลยโดยการส่งคำสั่ง API เพียงครั้งเดียว และใช้งาน secret key

การสร้าง source


เมื่อผู้ซื้อเลือกชำระเงินผ่านช่องทางนี้ ให้ร้านค้าสร้าง source ผ่าน source API โดยกำหนด amount, currency, items, phone_number, shipping, และ type

Parameter Type Description
amount integer (required) จำนวนเงิน
currency string (required) สกุลเงิน (THB สำหรับประเทศไทย, SGD สำหรับสิงคโปร์, MYR สำหรับมาเลเซีย)
type string (required) atome_qr
phone_number string (optional) เบอร์โทรศัพท์มือถือพร้อมรหัสประเทศของผู้ซื้อ (ยกตัวอย่างเช่น: +66876543210)
items Item (optional) รายละเอียดของสินค้า
shipping Address (optional) ที่อยู่จัดส่ง
name string (optional) ชื่อของผู้ซื้อ
email string (optional) อีเมลของผู้ซื้อ
billing Address (optional) ที่อยู่เรียกเก็บเงิน

ตัวอย่างด้านล่างนี้เป็นการสร้าง source สำหรับรายการ Atome QR จำนวน ฿500 ให้แทนค่าของ omise_public_key และ $OMISE_PUBLIC_KEY ด้วย test public key ของร้านค้าซึ่งสามารถคัดลอกได้จาก แดชบอร์ด

หากใช้ Omise.js parameter type เป็นตัวแปรที่จำเป็นของฟังก์ชัน createSource

Omise.setPublicKey(omise_public_key);

Omise.createSource('atome_qr', {
  "amount": 50000,
  "currency": "SGD",
}, function(statusCode, response) {
  console.log(response)
});

หากร้านค้าต้องการทดสอบให้สร้าง request โดยใช้ 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": []
}

ตัวแปรของ id คือ source identifier (เริ่มต้นด้วย src)

การสร้างรายการรับชำระเงิน

สร้างรายการรับชำระเงินโดยระบุ parameter source, amount และ currency

  • source จะเป็นตัวกำหนด source identifier
  • amount และ currency จะต้องมีค่าตรงกับ amount และ currency ของ source

ตัวอย่างด้านล่างนี้แสดงให้เห็นถึงการสร้างรายการรับชำระเงินขึ้นมาใหม่ โดยใช้ curl

ในการสร้างรายการให้ร้านค้าแทน $OMISE_SECRET_KEY ด้วย test secret key ของร้านค้าซึ่งสามารถคัดลอกได้จากแดชบอร์ด และแทน $SOURCE_ID ด้วย id ของ 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
}

การสร้าง source และรายการรับชำระเงิน

ร้านค้าสามารถสร้างทั้ง source และ รายการรับชำระเงิน (charge) ผ่านการเรียกใช้ API เพียงครั้งเดียว

curl https://api.omise.co/charges \
  -u $OMISE_SECRET_KEY: \
  -d "amount=50000" \
  -d "currency=SGD" \
  -d "source[type]=atome_qr"

การตั้งเวลาหมดอายุสำหรับคิวอาร์โค้ด

โดยทั่วไป คิวอาร์โค้ดจะหมดอายุภายใน 12 ชั่วโมงหลังจากการสร้างรายการ

ในกรณีที่ต้องการกำหนดระยะเวลาในการหมดอายุสำหรับแต่ละคิวอาร์โค้ด ร้านค้าสามารถระบุระยะเวลาหมดอายุ (timestamp) ที่ต้องการระหว่าง 30 วินาทีถึง 12 ชั่วโมง ลงใน field expires_at ของ Charge API หากกรอกข้อมูลถูกต้อง คิวอาร์โค้ดจะหมดอายุในระยะเวลาที่กำหนดไว้แทนระยะเวลาตั้งต้น

หลังจากสร้างรายการรับชำระเงิน ร้านค้าสามารถส่งคำขอผ่าน Expire API เพื่อกำหนดให้รายการชำระเงินที่ pending หมดอายุได้

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"

สร้างรายการสำเร็จ

เมื่อร้านค้าสร้างรายการรับชำระเงินขึ้นมาแล้ว จะพบว่าสถานะของรายการแสดงเป็น pending หรือ status==pending โดยสถานะของรายการรับชำระเงินสามารถเป็นได้ทั้ง successful, failed และ expired

ในส่วนต่อไปเราจะอธิบายวิธีอนุมัติรายการรับชำระเงิน การรับ event แจ้งเตือนเมื่อรายการเสร็จสิ้นผ่าน webhook และการตรวจสอบสถานะรายการ

ภาพด้านล่างนี้แสดงให้เห็นถึงขั้นตอนทั้งหมดในการรับชำระเงินแต่ละรายการ

sequenceDiagram participant customer participant omise.js participant merchant participant api.omise.co participant offline provider customer->>omise.js: Send payment details for purchase omise.js->>api.omise.co: Request source using payment details api.omise.co-->>omise.js: Return source omise.js->>merchant: Merchant gets returned source merchant->>api.omise.co: Request charge using source and purchase details api.omise.co-xmerchant: Send "charge.create" webhook api.omise.co-->>merchant: Return charge customer->>offline provider: Provide payment or charge authorization at offline provider offline provider-->>api.omise.co: Return the result of payment or charge authorization api.omise.co-xmerchant: Send "charge.complete" webhook merchant-xcustomer: Send charge result (e.g., via email)

การอนุมัติรายการรับชำระเงิน

ร้านค้าจะแสดงคิวอาร์โค้ดที่สร้างขึ้นให้กับผู้ซื้อ โดยในการอนุมัติรายการผู้ซื้อจะสแกนคิวอาร์โค้ดด้วยโทรศัพท์มือถือ

ร้านค้าสามารถทดสอบการอนุมัติรายการได้ในโหมดทดสอบ โดยไปยังรายการที่ต้องการบนแดชบอร์ด จากนั้นคลิก Actions จากนั้นเลือกเปลี่ยนสถานะของรายการเป็น สำเร็จ หรือ ไม่สำเร็จ

คิวอาร์โค้ดจะอยู่ใน charge object ตามตัวอย่างด้านล่างนี้

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"
  }
}

การรับ event แจ้งเตือนรายการสำเร็จ

ร้านค้าสามารถรับการแจ้งเตือนเมื่อมีการทำรายการเสร็จสิ้นโดยใช้งาน webhook events

ในการติดตั้ง ให้ร้านค้ากำหนดตำแหน่งบนเซิร์ฟเวอร์เพื่อรับ webhook events และเพิ่มตำแหน่งเดียวกันนี้เป็น webhook endpoint บนแดชบอร์ด

เมื่อมีรายการเสร็จสิ้น ระบบจะส่ง POST request ไปยัง endpoint นี้ พร้อมทั้งแนบสถานะการตอบกลับของรายการนั้นๆ ไปด้วย

ตัวแปรหลักหรือ key สำหรับ event object ประกอบไปด้วย charge.complete และตัวแปร data ที่มี charge object

อ่านเพิ่มเติมได้ที่ Events API

การตรวจสอบสถานะรายการ

เมื่อได้รับ event ของรายการที่เสร็จสิ้นแล้ว ร้านค้าสามารถตรวจสอบสถานะรายการหรือ status โดยใช้ Charge API

หากค่าของ charge.status เป็น successful หมายถึงว่ารายการรับชำระเงินสำเร็จ หากค่าของ charge.status เป็น failed หมายถึงว่ารายการรับชำระเงินนั้นไม่สำเร็จ ร้านค้าสามารถตรวจสอบ failure_code และ failure_message ได้ใน charge object เพื่ออ่านคำอธิบายเพิ่มเติม

สาเหตุขัดข้องที่อาจเกิดขึ้นได้มีดังนี้

รหัสข้อขัดข้อง รายละเอียด
payment_expired รายการรับชำระเงินหมดอายุ
payment_rejected รายการถูกปฏิเสธโดยผู้ออกบัตร
failed_processing ระบบทำรายการไม่สำเร็จ

การยกเลิกรายการและการคืนเงิน

รายการที่รับชำระเงินผ่าน Atome QR สามารถทำการคืนเงินเต็มจำนวนบางส่วนได้ภายในระยะเวลา 60 วันนับจากวันทำรายการ

ข้อจำกัด

ประเทศไทย

  • จำนวนรับชำระขั้นต่ำ: 2000 (THB 20.00)
  • จำนวนรับชำระสูงสุด: 5000000 (THB 50,000.00)

สิงคโปร์

  • จำนวนรับชำระขั้นต่ำ: 150 (SGD 1.50)
  • จำนวนรับชำระสูงสุด: 300000 (SGD 3,000.00)

มาเลเซีย

  • จำนวนรับชำระขั้นต่ำ: 1000 (MYR 10.00)
  • จำนวนรับชำระสูงสุด: 500000 (MYR 5,000.00)

ขั้นตอนต่อไป

เว็ปไซต์นี้มีการใช้คุกกี้เพื่อวิเคราะห์การใช้และปรับการใช้งานให้เหมาะกับท่าน เมื่อกดยอมรับหรือยังคงเข้าชมเว็บไซต์ต่อ เราถือว่าท่านยินยอมในการใช้งานคุกกี้ของเว็บไซต์ อ่านนโยบายความเป็นส่วนตัว