Charge API

Charge API สามารถใช้เพื่อสร้าง, เรียกข้อมูล และอัปเดตรายการรับชำระเงิน ทั้งในส่วนของจำนวนและสกุลเงิน กับบัตร, ลูกค้า (ตัวอย่างเช่น บัตรหลักของลูกค้า) หรือ source รายการรับชำระเงินที่ได้รับการอนุมัติแล้วสามารถที่จะตัดวงเงินในภายหลังได้ หรือในรายการที่ยังไม่ได้ทำการตัดวงเงินก็สามารถที่จะทำการคืนวงเงินได้ ทางร้านค้าสามารถเลือกที่จะเพิ่มข้อมูล metadata ไว้กับรายการรับชำระเงินได้

Attributes

Name Type Description
object string

The string charge.

id string

The charge identifier matching /chrg(_test)?_[0-9a-z]+/.

livemode boolean

Whether this is a live (true) or test (false) charge.

location string

API path to retrieve the current charge object.

acquirer_reference_number string

Reference number for the charge initiated by the customer. This information is sent as part of the settlement report to Visa and Master Card.

amount integer

Charge amount in smallest unit of charge currency.

approval_code string

Approval code

authorization_type string

Determines the final amount to capture. See parameters for more details.

authorize_uri string

URI for payment authorization (e.g. 3-D Secure).

authorized boolean

Whether charge has been authorized.

authorized_amount integer

Maximum amount that has been authorized for a specific card charge.

authorized_at string

UTC datetime of charge authorization in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

branch object_id_expandable

Physical location of a merchant terminal.

can_perform_void boolean

Whether the charge can be voided or not.

capturable boolean

Whether charge is able to be captured (paid).

capture boolean

Whether charge is set to be automatically captured (paid).

captured_amount integer

Captured amount

card card

Card that was charged (if card was charged).

created_at string

UTC datetime of charge creation in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

currency string

Currency for charge as three-letter ISO 4217 code.

customer object_id_expandable

Customer associated with charge.

description string

Charge description.

device object_id_expandable

Physical hardware linked to a terminal.

disputable boolean

Whether charge is able to be disputed.

dispute dispute

Dispute associated with charge.

expired boolean

Whether charge has expired.

expired_at string

UTC datetime of actual charge expiration in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

expires_at string

UTC datetime of expected charge expiration in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

failure_code string

Failure code if status == failed. See testing for possible codes.

failure_message string

Message describing the failure if status == failed.

fee integer

Opn Payments charge fee.

fee_vat integer

Value-added Tax (VAT) applied to fee.

funding_amount integer

For multi-currency charges, amount after exchange into account funding currency (funding_currency) specified in the smallest unit of funding_currency.

For non-multi-currency charges, amount specified in the smallest unit of currency.

funding_currency string

Currency for account as three-letter ISO 4217 code. This is the settlement currency for all charges.

interest integer

Interest paid by customer or merchant over the course of an installment term.

interest_vat integer

Value-added Tax (VAT) applied to interest.

ip string

IP address provided to Opn payments at charge creation. May be IPv4 or IPv6.

link object_id_expandable

Link identifier for charge (if any).

linked_account linked_account

The linked account object for direct debit.

merchant_advice string

Advice to the merchant on how to proceed when a payment error occurs.

merchant_name string

The name of the sub-merchant who initiated the charge.

Note: This field is applicable only if the merchant uses the Payfac solution. To enroll in Payfac, contact Opn Support.

merchant_uid string

The ID of the sub-merchant who initiated the charge.

Note: This field is applicable only if the merchant uses the Payfac solution. To enroll in Payfac, contact Opn Support.

metadata object

Custom metadata (e.g. {answer: 42}) for charge. The maximum field length is 15.000 characters.

net integer

funding_amount after fees, interest, and VAT deducted.

paid boolean

Whether charge has been captured (paid).

paid_at string

UTC datetime of the charge payment in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

partially_refundable boolean

Indicates whether a charge’s type (credit card, QR, Promptpay) is partially refundable.

platform_fee object

Platform fee object as fixed amount and/or percentage of charge amount.

refundable boolean

Whether charge is able to be refunded.

refunded_amount integer

Refunded amount in smallest unit of currency.

refunds list

List of refunds.

return_uri string

URI to which customer is redirected after 3-D Secure card authorization or other redirect-based authorization.

reversed boolean

Whether charge authorization has been reversed.

reversed_at string

UTC datetime of charge authorization reversal in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

reversible boolean

Whether charge authorization is able to be reversed.

schedule object_id_expandable

Schedule associated with the charge.

source source

Source that was charged (if a source was charged).

status string

Charge status. One of failed, expired, pending, reversed or successful.

terminal object_id_expandable

Point of sale within a branch.

transaction object_id_expandable

Transaction generated by charge.

transaction_fees object

Transaction fees

unmanaged_payment object

Unmanaged payment information

voided boolean

Whether, in the case of a refund, charge was voided instead. Charges are voided if refund is processed before settlement time.

zero_interest_installments boolean

Whether merchant absorbs the interest for installment payments; must match value in associated source.

Example

  • JSON Response

Capture a charge

- POST https://api.omise.co/charges/{id}/capture

Capture a charge that has not yet been captured (parameter capture=false passed at charge creation). Posting to this endpoint after charge expiration will result in an expired charge error. Any other issue processing capture will result in an failed capture error.

Request Parameters

Name Type Description
capture_amount integer

(optional) Denotes the amount in the smallest unit of charge currency to capture. This is the amount processed and transferred from the customer’s account to the merchant’s account using the capture API.

The amount may be equal to the authorized amount in case of a final authorization, or may be a part of the authorized amount in case of a pre-authorization.

This field is required only for Single Partial Capture.

Example

  • Capture a charge

Create a charge

- POST https://api.omise.co/charges

When creating a new charge, first create a token and then create a charge. Token creation is done by a client-side or server-side program, and charging is done by a server-side program (please do not implement charging on the client side).

Successfully posting to this endpoint will either authorize a charge on a card (for later capture) or directly capture a charge from a card or source. In case the charge fails, this endpoint will either return one of several errors or else a charge with failure_code set to one of the following:

failure_code Description
confirmed_amount_mismatch Final amount from payment channel does not match original amount charged
failed_fraud_check Card was marked as fraudulent.
failed_processing General payment processing failure.
insufficient_balance/insufficient_fund Insufficient funds in the account or the card has reached the credit limit.
invalid_account_number/invalid_account Valid account for payment method not found.
payment_cancelled Payment cancelled by payer.
payment_rejected Payment rejected by issuer.
stolen_or_lost_card Card stolen or lost.
timeout Payment provider did not respond in time.

When testing credit cards charges, you can make the API return the above responses using special test credit card numbers.

Request Parameters

Name Type Description
amount integer

(required) Amount for charge in smallest currency unit. If charging a source, amount must match amount specified in the source at its creation.

currency string

(required) Currency for the charge. If charging a source, currency must match currency specified in the source at its creation.

authorization_type string

(optional) One of:

a. pre_auth: Pre-authorization occurs when the merchant requests initial authorization for an estimated amount, typically when the final transaction amount is unknown or subject to change. This allows the merchant to reserve the maximum potential amount and provides flexibility to decrease the initially authorized amount at a later stage before capturing the payment. Read more about partial capture.

b. final_auth: Final authorization occurs when the merchant and customer agree on the final amount of the transaction in advance, and will make no adjustments to the authorized amount. In this case, the full authorized amount is captured during the payment process.

capture boolean

(optional, default: true, one of: true, false) Whether charge is set to be automatically captured (paid). Default: true. Valid only for credit/debit card charges, PayPay and Rabbit Line Pay.

card string

(optional, but conditionally required) Unused token identifier or card identifier. If a card identifier is passed, you must also pass the identifier of the customer who owns the card under the customer parameter. If a token identifier is passed, the customer parameter must not be present.

customer string

(optional, but conditionally required) A valid identifier for a customer that has at least one card already associated. By default, the default card of the customer will be used. Required if passing a card identifier in the card parameter. If passing a token identifier in the card parameter, this parameter must not be present.

description string

(optional, but recommended) Charge description. Supplying information about a purchase (e.g. number of items, type of items, date of delivery) helps Opn Payments better conduct fraud analysis.

expires_at string

(optional) UTC datetime of desired charge expiration in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

Supported by:

  • atome
  • atome_qr
  • mobile_banking_ktb
  • shopeepay
  • shopeepay_jumpapp
  • promptpay
  • econtext

Note: This list is not exhaustive. Please consult the specific payment method to check if this field is supported.

first_charge string

(optional) The Charge ID of the first transaction in the recurring cycle. Passed as an optional parameter to increase the likelihood of approval when creating recurring charges.

ip string

(optional, but recommended) IP address to attach to the charge. Supplying the customer's real IP address helps Opn Payments better conduct fraud analysis. May be IPv4 or IPv6.

linked_account string

(optional) The linked account object for direct debit.

metadata object

(optional) Custom metadata (e.g. {answer: 42}) for charge. The maximum field length is 15.000 characters.

platform_fee object

(optional) Platform fee object as fixed amount and/or percentage of charge amount.

recurring_reason string

(optional) One of:

  • blank - The customer agrees to store the credential on file with the merchant for future transactions.

  • unscheduled - The customer agrees to store the credential on file so that the merchant can initiate transactions when the balance in the customer account with the merchant falls below an established threshold (auto top-up). The payment can be a variable or fixed amount but is not initiated at fixed intervals.

  • standing_order - The customer agrees to store the credential on file so that the merchant can initiate transactions for monthly utility payments. The payment is a variable amount but initiated at fixed intervals.

  • subscription - The customer agrees to store the credential on file so that the merchant can initiate subscriptions. The payment is a fixed amount initiated at fixed intervals.

  • installment - The customer agrees to store the credential on file so that the merchant can initiate the installment payments. The payment is a fixed amount initiated for a fixed recurring period for a single purchase, For example, for a TV bought on 12 equal monthly installments.

  • partial_shipment - The customer agrees to store the credential on file so that the merchant can initiate the payments for partial shipments (as and when the merchant ships things in the order, instead of shipping all items at once).

  • delayed_charge - The customer agrees to store the credential on file so that the merchant can initiate the payments for services already rendered. For example, a hotel charges a customer's card when the customer checks out.

  • no_show - The customer agrees to store the credential on file so that the merchant can initiate the penalty for the customer canceling a service or a product without required prior intimation.

  • resubmission - The customer agrees to store the credential on file so that the merchant can initiate the payments later even if the transaction has failed earlier. For example, a merchant retries payment at a later date although the payment failed due to insufficient funds earlier.

return_uri string

(optional, but conditionally required) URI to which customer is redirected after 3-D Secure card authorization or other redirect-based authorization. Required if account is set to use 3-D Secure or any other redirect-based authorization for payment.

On payment methods that require opening the external app (e.g. mobile banking app) to authorize the transaction, set the return_uri to a deeplink or applink to be able to open the merchant app. Else, after the card holder completes authorizing the transaction on the external app, the flow redirects to the normal link in the return_uri and opens it on the browser app, and therefore results in the payment not being completed.

source string

(optional, but conditionally required) Valid source identifier or source object. See Source API for source request parameters. Required if card and customer are not present.

transaction_indicator string

(optional) Indicates who initiated the charge. One of:

  • MIT - Merchant initiated transaction
  • CIT - Customer initiated transaction

Allows Opn to format the authorization request accordingly.

webhook_endpoints array

(optional) URLs to which charge notifications are to be sent. This field can contain a maximum of two URLs. Each URL must be secure (HTTPS) and must not be:

  • localhost
  • an IPv4 or IPv6 address
  • a hostname with only numbers

All event notifications related to the associated charge and refund (if any) will be delivered to the URLs defined here instead of the default webhook_endpoint from account setting.

zero_interest_installments boolean

(optional, one of: true, false) Whether merchant absorbs the interest for installment payments; must match value in associated source.

Example

  • Create an Alipay charge

  • Create an Installment Payment charge

  • Create an Internet Banking charge

  • Create and charge a new source

  • Charge a card using a customer and a card

  • Charge a card using a customer

  • Charge a card while adding metadata

  • Charge a card using a token

Expire a pending charge

- POST https://api.omise.co/charges/{id}/expire

Set a charge that has not yet been authorized (status=pending) to expire. Supported by charges with the following source[type]: alipay_cn, alipay_hk, barcode_alipay, dana, gcash, kakaopay, paypay or touch_n_go.

Example

  • Expire a pending charge

List charges

- GET https://api.omise.co/charges

Returns a list of charges belonging to your account.

Request Parameters

Name Type Description
from string

(optional, default: 1970-01-01T00:00:00Z) Earliest UTC datetime for returned records in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

limit integer

(optional, default: 20) Number of records returned.

offset integer

(optional, default: 0) Offset of the first record returned (i.e. how many records to skip from the beginning).

order string

(optional, default: chronological, one of: chronological, reverse_chronological) Order of records returned.

to string

(optional) Latest UTC datetime for returned records in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

Example

  • List all charges

List charges for a link

- GET https://api.omise.co/links/{id}/charges

Returns a list of charges associated with a link.

Request Parameters

Name Type Description
from string

(optional, default: 1970-01-01T00:00:00Z) Earliest UTC datetime for returned records in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

limit integer

(optional, default: 20) Number of records returned.

offset integer

(optional, default: 0) Offset of the first record returned (i.e. how many records to skip from the beginning).

order string

(optional, default: chronological, one of: chronological, reverse_chronological) Order of records returned.

to string

(optional) Latest UTC datetime for returned records in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

Mark a charge as failed

- POST https://api.omise.co/charges/{id}/mark_as_failed

Mark a test charge as failed. Not supported by all payment methods.

Example

  • Mark a test charge as failed

Mark a charge as paid

- POST https://api.omise.co/charges/{id}/mark_as_paid

Mark a test charge as paid. Not supported by all payment methods.

Example

  • Mark a test charge as paid

Retrieve a charge

- GET https://api.omise.co/charges/{id}

Returns the charge matching :id.

Example

  • Retrieve a charge

Reverse a charge

- POST https://api.omise.co/charges/{id}/reverse

Reverse a charge that has not yet been captured (parameter capture=false passed at charge creation).

Example

  • Reverse an uncaptured charge

Update a charge

- PATCH https://api.omise.co/charges/{id}

Update attributes for a charge.

Request Parameters

Name Type Description
description string

(optional, but recommended) Charge description. Supplying information about a purchase (e.g. number of items, type of items, date of delivery) helps Opn Payments better conduct fraud analysis.

metadata object

(optional) Custom metadata (e.g. {answer: 42}) for charge. The maximum field length is 15.000 characters.

Example

  • Update charge description

  • Update charge metadata

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