ทำเครื่องหมาย Charge ว่าชำระแล้ว
ทำเครื่องหมาย charge ทดสอบว่าชำระแล้ว endpoint นี้ใช้สำหรับการทดสอบและการกระทบยอดเป็นหลัก และรองรับเฉพาะวิธีการชำระเงินที่ระบุเท่านั้น
ข้อมูลยืนยันตัวตน API
พารามิเตอร์คำขอ
จำเป็น - 1 ฟิลด์พารามิเตอร์ที่จำเป็น
`id`STRING(required)
charge ID ที่จะทำเครื่องหมายว่าชำระแล้ว ต้องเป็น charge ทดสอบที่สามารถอัปเดตสถานะด้วยตนเองได้
การตอบกลับ
200
ทำเครื่องหมายว่าชำระแล้วสำเร็จสถานะของ Charge ได้รับการอัปเดตเป็นสำเร็จและทำเครื่องหมายว่าชำระแล้ว
การเปลี่ยนแปลงฟิลด์หลัก:
status- เปลี่ยนเป็ น successfulpaid- ตั้งค่าเป็น truepaid_at- ตั้งค่าเป็นเวลาปัจจุบันtransaction- สร้าง Transaction ID
400
คำขอไม่ถูกต้องการตรวจสอบคำขอล้มเหลว
สาเหตุทั่วไป:
- รูปแบบ charge ID ไม่ถูกต้อง
- Charge ไม่มีสิทธิ์สำหรับการชำระเงินด้วยตนเอง
- การใช้ charge จริง (รองรับเฉพาะ charge ทดสอบเท่านั้น)
401
ไม่ได้รับอนุญาตการยืนยันตัวตนล้มเหลว API key ไม่ถูกต้องหรือขาดหายไป
สาเหตุทั่วไป:
- ขาด Authorization header
- secret key ไม่ถูกต้อง
- ใช้ public key แทน secret key
404
ไม่พบCharge ID ไม่มีอยู่
สาเหตุทั่วไป:
- charge ID ไม่ถูกต้อง
- Charge จากบัญชีอื่น
- ใช้ test key สำหรับ charge จริง (หรือใน ทางกลับกัน)
ตัวอย่างโค้ด
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/charges/chrg_test_5xuy4w91xqz7d1w9u0t/mark_as_paid \
-X POST \
-u skey_test_5xuy4w91xqz7d1w9u0t:
require 'omise'
Omise.api_key = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = Omise::Charge.mark_paid('chrg_test_5xuy4w91xqz7d1w9u0t')
import omise
omise.api_secret = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = omise.Charge.mark_paid('chrg_test_5xuy4w91xqz7d1w9u0t')
const omise = require('omise')({
secretKey: 'skey_test_5xuy4w91xqz7d1w9u0t'
});
const charge = await omise.charges.markPaid('chrg_test_5xuy4w91xqz7d1w9u0t');
<?php
define('OMISE_SECRET_KEY', 'skey_test_5xuy4w91xqz7d1w9u0t');
$charge = OmiseCharge::retrieve('chrg_test_5xuy4w91xqz7d1w9u0t');
$charge->markPaid();
Client client = new Client.Builder()
.secretKey("skey_test_5xuy4w91xqz7d1w9u0t")
.build();
Charge charge = client.charges().markPaid("chrg_test_5xuy4w91xqz7d1w9u0t")
.send();
var client = new Client("skey_test_5xuy4w91xqz7d1w9u0t");
var charge = await client.Charges.MarkPaid("chrg_test_5xuy4w91xqz7d1w9u0t");
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"skey_test_5xuy4w91xqz7d1w9u0t",
)
charge, _ := client.MarkChargePaid("chrg_test_5xuy4w91xqz7d1w9u0t", nil)
รหัสข้อผิดพลาดและรหัสผลลัพธ์
รหัสข้อผิดพลาดทั่วไป
| Code | คำอธิบาย | แนว ทางแก้ไข |
|---|---|---|
not_found | Charge ID ไม่มีอยู่ | ตรวจสอบว่า Charge ID ถูกต้อง |
not_eligible | ไม่สามารถทำเครื่องหมาย Charge ว่าชำระแล้ว | ตรวจสอบสถานะของ Charge และวิธีการชำระเงิน |
already_paid | Charge ชำระแล้ว | ไม่จำเป็นต้องดำเนินการ |
not_test_charge | รองรับเฉพาะ charge ทดสอบเท่านั้น | ใช้ test key และ test charge |
ลองใช้งาน
จำเป็น - 1 ฟิลด์