Applies to: Orders API | Payments API
Learn about paying for orders using the Orders API or Payments API.
You can pay for your orders in two ways: with the Payments API (CreatePayment endpoint) or with the Orders API (PayOrder endpoint). The following sections explain when to use each API.
Note
If you're creating a CASH
payment for an order, you need to call CreatePayment
to create the cash payment and then call PayOrder
to actually pay for the order.
Sometimes customers want to apply multiple payments to an order (for example, to pay a portion of an order using a gift card and then apply a credit card for the remaining amount).
To apply multiple payments to an order, applications must use the Orders API (PayOrder endpoint). These payments must be previously authorized (see Delayed Capture of a Card Payment). For example, to pay for an order using three payments, do the following:
- Call
CreatePayment
three times. In each request, specify the order ID and set the autocomplete
field to false
(to obtain only authorization). - Call
PayOrder
by specifying the authorized payment IDs. The endpoint captures the previously authorized payments.
Important
You cannot set the fulfillment.state
of any order fulfillment to COMPLETED
until after you call PayOrder
.
The endpoint also sets the order state to COMPLETED
, provided that:
- The sum of all these payments is equal to the order total (
total_money
). - The order doesn't include fulfillments.
If the order does include a fulfillment, you need to call UpdateOrder after you've called PayOrder
. In your UpdateOrder
request, set the state of any fulfillments to COMPLETED
and the state of the order itself to COMPLETED
.
The following PayOrder
example pays for an order by specifying the payment IDs of previously authorized payments:
Use the PayOrder
endpoint to apply a $0 payment. The request doesn't include any payment IDs.
When you want an application to pay for an order using a single payment, use the Payments API ((CreatePayment endpoint). Note the following:
- The
CreatePayment
request must include an order ID. - The payment amount must match the order total (the
total_money
in the Order
object).
The following CreatePayment
example charges the specified payment source $2 to pay for the specified order:
Suppose you create an order for $20 and apply a $20 discount. You then need to make a $0 payment before you can set the order state
to COMPLETED
. Applications can use either the Payments API or Orders API.
Use the CreatePayment
endpoint to record a $0 CASH
or EXTERNAL
payment for an order.
After you record a cash payment, the order isn't paid until you call the PayOrder
endpoint with the ID of your cash payment.
For more information about how to use payments, see Take Payments.