Pay for Orders
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.
When applications want to pay for an order using a single payment, they can 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:
For more information about how to use payments, see the 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, you 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 does not include fulfillment.
Note
If the order includes fulfillment, you call
UpdateOrder
to explicitly set both the fulfillment and the order state.
The following PayOrder
example pays for an order by specifying payment IDs of previously authorized payments:
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. You can use the
CreatePayment
endpoint to record a $0 CASH or EXTERNAL payment for an order.Using the Orders API. You can use the
PayOrder
endpoint to apply a $0 payment. The request does not include any payment IDs.
If you need more assistance, contact Developer Support or ask for help in the Developer Forums.