You can pay for your orders in two ways: with the Payments API (CreatePayment endpoint) or with the Orders API (PayOrder endpoint). This topic explains when to use each API.
Pay for Orders
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 theOrder
).
The following CreatePayment
example charges the specified payment source $2 to pay for the specified order:
Create payment
For more information about how to use payments, see Take Payments.
Sometimes applications might want to apply multiple payments to an order. For example, first pay a portion using a gift card and then apply a credit card for the rest of the 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, you specify the order ID and set theautocomplete
field tofalse
(to obtain only authorization). - Call
PayOrder
by specifying the authorized payment IDs. The endpoint captures the previously authorized payments. The endpoint also sets the order state toCOMPLETED
, provided that:The sum of all these payments is equal to the order total (
total_money
).The order doesn't include fulfillment.
Note
If the order includes fulfillment, call
UpdateOrder
to explicitly set both the fulfillment and order state.
The following PayOrder
example pays for an order by specifying payment IDs of previously authorized payments:
Pay order
Suppose you create an order for $20 and apply a $20 discount. You then need to make a $0 payment to set the order state
to COMPLETED
. Applications can use either the Payments API or Orders API.
Using the Payments API - Use the
CreatePayment
endpoint to record a $0CASH
orEXTERNAL
payment for an order.Create payment
Using the Orders API - Use the
PayOrder
endpoint to apply a $0 payment. The request doesn't include any payment IDs.Pay order
If you need more assistance, contact Developer Support or ask for help in the Developer Forums.