Pay for Orders

Link to section

Using the Payments API (CreatePayment endpoint)

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).

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.

Link to section

Using the Orders API (PayOrder endpoint)

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 the autocomplete field to false (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 to COMPLETED, 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

Link to section

Make a $0 payment

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 $0 CASH or EXTERNAL 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