Pay for Orders
Follow step-by-step instructions to pay for orders using the Payments and Orders APIs.
The Orders API not only provides the functionality to create and retrieve orders, but it also provides us methods to pay for orders. In a broader perspective, we can pay for orders in two ways:
- Payments API (CreatePayment endpoint)
- Orders API (PayOrder endpoint)
Payments API (CreatePayment endpoint)
To pay for an order, we must create one first. Let’s create an order using the following code:
Press + to interact
ACCESS_TOKEN
Not Specified...
LOCATION_ID
Not Specified...
result = client.orders.create_order(body = {"order": {"location_id": "{{LOCATION_ID}}","line_items": [{"name": "Wearnetic Fleece","quantity": "1","base_price_money": {"amount": 199,"currency": "USD"}}]}})if result.is_success():pprint(result.body)elif result.is_error():pprint(result.errors)
The following code uses the CreatePayment endpoint of the Payments API to pay for the order we just created. Please note the following points:
- The payment
amount
in line 9 must match the total amount,total_money
, in the