Order Management¶
In this chapter we will show examples of retrieving orders and changing their details.
Get a Purchase¶
By using the purchases
query field you can get everything about an order
including the customer, captures, returns and items.
By selecting only the fields you need, you optimize the data transfer and minimize the encoding overhead on your side.
Hint
Try adding more fields to the query and using the autocompletion feature in the editor to discover all the fields you can fetch.
You may use one of the purchases you completed in the Checkout.
Also, remember to explore the Docs tab in the editor. Search, for example,
for the Purchase
type.
Cancel a Purchase¶
A purchase can be canceled before any captures have happened. You need to use the purchaseCancel
mutation and provide the id
of the purchase you want to cancel.
Add New Items¶
Adding new items to an order can be done using the editPurchase
mutation. This mutation allows
you to add new items and edit existing ones at the same time. In this example we will only
show how to add.
The total amount for the purchase needs to be updated with the new total when adding new items.
Note
Currently, orders can be edited only before they are captured for the first time.
Edit Existing Items¶
As explained above, editing existing items can be done with the editPurchase
mutation too.
When editing existing items the total amount for the purchase needs to be updated with the
new total.
Note
Currently, orders can be edited only before they are captured for the first time.