Atome App Redirection

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

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

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

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

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

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

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

การชำระผ่านเบราว์เซอร์บนคอมพิวเตอร์

Atome Desktop

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

การชำระผ่านเบราว์เซอร์บนโทรศัพท์มือถือ

Atome Mobile Browser

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

การชำระผ่านแอปพลิเคชันบนโทรศัพท์มือถือ

Atome Mobile Deeplink

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

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

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

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

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

ส่วนการสร้างรายการ (charge) เพื่อรับชำระเงินผ่าน Atome จะเกิดขึ้นในฝั่งของร้านค้า (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
phone_number string (required) เบอร์โทรศัพท์มือถือพร้อมรหัสประเทศของผู้ซื้อ (ยกตัวอย่างเช่น: +66876543210)
items Item (required) รายละเอียดของสินค้า
shipping Address (required) ที่อยู่จัดส่ง
name string (optional) ชื่อของผู้ซื้อ
email string (optional) อีเมลของผู้ซื้อ
billing Address (optional) ที่อยู่เรียกเก็บเงิน

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

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

Omise.setPublicKey(omise_public_key);

Omise.createSource('atome', {
  "amount": 50000,
  "currency": "SGD",
  "phone_number": "+66876543210",
  "shipping":
    {
      "street1": "1448/4 Praditmanutham Road",
      "postal_code": "10320",
      "country": "th"
    },
  "items":
    [
      {
        "sku": "AAA111",
        "name": "water bottle",
        "amount": "25000",
        "quantity: "2"
      }
    ],
}, 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" \
  --data-urlencode "phone_number=+66876543210" \
  -d "shipping[postal_code]=10320" \
  -d "shipping[country]=TH" \
  -d "shipping[street1]=1448/4 Praditmanutham Road" \
  -d "items[0][sku]=AAA111" \
  -d "items[0][name]=water bottle" \
  -d "items[0][quantity]=2" \
  -d "items[0][amount]=25000"
{
  "object": "source",
  "id": "src_test_5vz4s25jpdlpt9ggmem",
  "livemode": false,
  "location": "/sources/src_test_5vz4s25jpdlpt9ggmem",
  "amount": 50000,
  "barcode": null,
  "bank": null,
  "created_at": "2023-06-02T08:53:34Z",
  "currency": "SGD",
  "email": null,
  "flow": "redirect",
  "installment_term": null,
  "absorption_type": null,
  "name": null,
  "mobile_number": "+66876543210",
  "phone_number": "+66876543210",
  "platform_type": null,
  "scannable_code": null,
  "billing": null,
  "shipping": {
    "city": null,
    "country": "TH",
    "postal_code": "10320",
    "state": null,
    "street1": "1448/4 Praditmanutham Road",
    "street2": null
  },
  "items": [
    {
      "sku": "AAA111",
      "name": "water bottle",
      "brand": null,
      "category": null,
      "amount": 25000,
      "quantity": 2,
      "item_uri": null,
      "image_uri": null
    }
  ],
  "references": null,
  "store_id": null,
  "store_name": null,
  "terminal_id": null,
  "type": "atome",
  "zero_interest_installments": null,
  "charge_status": "unknown",
  "receipt_amount": null,
  "discounts": []
}

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

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

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

  • return_uri จะเป็นตำแหน่งบนเว็บไซต์ของร้านค้าที่ผู้ซื้อจะถูกส่งไปเมื่อยืนยันรายการสำเร็จ
  • source จะเป็นตัวกำหนด source identifier
  • amount และ currency จะต้องมีค่าตรงกับ amount และ currency ของ source

รองรับทั้งการตัดวงเงินด้วยตัวเอง (Manual Capture) และการตัดวงเงินอัตโนมัติ (Automatic Capture)

ตัวอย่างด้านล่างนี้แสดงให้เห็นถึงการสร้างรายการรับชำระเงินขึ้นมาใหม่ โดยใช้ 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 "return_uri=http://example.com/orders/345678/complete" \
  -d "source=$SOURCE_ID"
{
  "object": "charge",
  "id": "chrg_test_5vz4s29fbc4obd1tym0",
  "location": "/charges/chrg_test_5vz4s29fbc4obd1tym0",
  "amount": 50000,
  "net": 47250,
  "fee": 2750,
  "fee_vat": 0,
  "interest": 0,
  "interest_vat": 0,
  "funding_amount": 50000,
  "refunded_amount": 0,
  "transaction_fees": {
    "fee_flat": "0.0",
    "fee_rate": "5.5",
    "vat_rate": "0.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_test_5vz4s29fbc4obd1tym0/refunds",
    "order": "chronological",
    "from": "1970-01-01T00:00:00Z",
    "to": "2023-06-02T08:53:35Z"
  },
  "link": null,
  "description": null,
  "metadata": {},
  "card": null,
  "source": {
    "object": "source",
    "id": "src_test_5vz4s1xg61tlhy2i9p8",
    "livemode": false,
    "location": "/sources/src_test_5vz4s1xg61tlhy2i9p8",
    "amount": 50000,
    "barcode": null,
    "bank": null,
    "created_at": "2023-06-02T08:53:33Z",
    "currency": "SGD",
    "email": null,
    "flow": "redirect",
    "installment_term": null,
    "absorption_type": null,
    "name": null,
    "mobile_number": "+66876543210",
    "phone_number": "+66876543210",
    "platform_type": null,
    "scannable_code": null,
    "billing": null,
    "shipping": {
      "city": null,
      "country": "th",
      "postal_code": "10320",
      "state": null,
      "street1": "1448/4 Praditmanutham Road",
      "street2": null
    },
    "items": [
      {
        "sku": "AAA111",
        "name": "water bottle",
        "brand": null,
        "category": null,
        "amount": 25000,
        "quantity": 2,
        "item_uri": null,
        "image_uri": null
      }
    ],
    "references": null,
    "store_id": null,
    "store_name": null,
    "terminal_id": null,
    "type": "atome",
    "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": "https://pay.omise.co/payments/pay2_test_5vz4s29ibio0cyi0j15/authorize",
  "return_uri": "http://example.com/orders/345678/complete",
  "created_at": "2023-06-02T08:53:34Z",
  "paid_at": null,
  "expires_at": "2023-06-09T08:53:34Z",
  "expired_at": null,
  "reversed_at": null,
  "zero_interest_installments": false,
  "branch": null,
  "terminal": null,
  "device": null,
  "authorized": false,
  "capturable": false,
  "capture": true,
  "disputable": false,
  "livemode": false,
  "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 "return_uri=http://example.com/orders/345678/complete" \
  -d "source[type]=atome" \
  --data-urlencode "source[phone_number]=+66876543210" \
  -d "source[shipping][postal_code]=10320" \
  -d "source[shipping][country]=th" \
  -d "source[shipping][street1]=1448/4 Praditmanutham Road" \
  -d "source[items][0][sku]=AAA111" \
  -d "source[items][0][name]=water bottle" \
  -d "source[items][0][quantity]=2" \
  -d "source[items][0][amount]=25000"

การตั้งเวลาหมดอายุสำหรับรายการชำระเงิน

โดยทั่วไป รายการรับชำระเงินจะหมดอายุภายใน 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" \
  --data-urlencode "source[phone_number]=+66876543210" \
  -d "source[shipping][postal_code]=10320" \
  -d "source[shipping][country]=TH" \
  -d "source[shipping][street1]=1448/4 Praditmanutham Road" \
  -d "source[items][0][sku]=AAA111" \
  -d "source[items][0][name]=water bottle" \
  -d "source[items][0][quantity]=2" \
  -d "source[items][0][amount]=25000" \
  -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 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 merchant->>customer: Redirect to "authorize_uri" for pending charge customer->>api.omise.co: Provide charge authorization details at "authorize_uri" api.omise.co-->>customer: Redirect to "return_uri" api.omise.co-xmerchant: Send "charge.complete" webhook merchant-xcustomer: Send charge result (e.g., via email)

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

ระบบจะส่งผู้ซื้อไปยังตำแหน่งที่ระบุไว้ใน authorize_uri เพื่อให้ผู้ซื้อสามารถดำเนินการอนุมัติรายการรับชำระเงินได้

ร้านค้าสามารถจำลองขั้นตอนการอนุมัติรายการในโหมดทดสอบ โดยเข้าไปที่ authorize_uri เพื่อปรับสถานะรายการเป็น สำเร็จ หรือ ไม่สำเร็จ ได้ด้วยตนเอง หลังจากผู้ซื้อทำการอนุมัติรายการเสร็จสิ้น ผู้ซื้อจะถูกส่งไปยังหน้าที่ร้านค้าระบุไว้ใน return_uri

การรับ 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 สามารถทำการคืนเงินเต็มจำนวนบางส่วนได้ภายในระยะเวลา 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)

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

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