Integration with Exchanges V2 (Better Exchanges)
Anchor to PurposePurpose
Shopify added a new field on the Order object in the 2023-07 version of the GraphQL API, which requires authorized access. This field gives merchant systems, such as Enterprise Resource Planning (ERP), access to the data they need to identify and model exchanges V2 data.
The new exchangeV2s
field is available on the Order object through the order and order list queries. Only clients with authorized access will have visibility to the data. This document provides details on how to request access for your client and how to integrate with the exchangeV2s
field.
Type of Merchant ERP Integration | Client | Who requests access to the exchangeV2s field? | Who to reach out to? |
---|---|---|---|
Uses ERP native connector | ERP | ERP | Shopify Product Partnerships |
Uses 3rd Party ERP connector | 3rd Party | 3rd Party | Shopify Product Partnerships or Support Team |
Uses custom in house connector | Merchant | Merchant | MSM or Support Team |
This access authorized field is a temporary solution as Shopify builds the future of exchange functionality and APIs. This data is only available on Shopify’s GraphQL Admin API.
Anchor to Requesting AccessRequesting Access
Clients need to request access to the exchangeV2s
field. Refer to above table for Shopify point of contact regarding access.
The client will receive a "Field 'exchangeV2s' doesn't exist on type 'Order'
" or an “Access denied for exchangeV2s field
” error message if access has not been requested or has been requested and access is pending.
Anchor to What data is available in the exchangeV2s field?What data is available in the exchange V2s field?
The exchangeV2s field returns a paginated list of ExchangeV2Connection objects using the filters provided. You can follow the return object to see more details on each level.
ExchangeV2Connection
: An auto-generated type for paginating through multiple ExchangeV2s.
ExchangeV2Edge
: An auto-generated type which holds one ExchangeV2 and a cursor during pagination.
ExchangeV2
: An exchange where existing items on an order are returned and new items are added to the order.
ExchangeV2Additions
: New items associated to the exchange.
ExchangeV2Returns
: Return items associated to the exchange.
ExchangeV2LineItem
: Contains information about an item in the exchange.
Anchor to Real Time Support (Webhooks)Real Time Support (Webhooks)
Our API does not emit exchange specific webhooks throughout the processing of an exchange. There is no dedicated webhook emitted when an exchange starts or when it fully completes (i.e.when all the data is available). In that sense, our API does not offer real time support.
However, when an exchange is being processed, there will be multiple existing webhooks that are emitted. They are emitted to reflect the changes happening to the Order as part of the exchange. The following chart shows the emitted webhooks in the order in which they are enqueued. They are not guaranteed to be delivered in this order since the received order will vary depending on the traffic.
Exchange V2 Operation | Webhook Triggered | Data changes visible when querying the GraphQL API |
---|---|---|
Process Refund (*only for net-refundable + Interac refunds) | refunds/create | Refund transaction appears on the Order. |
Payment (*only for net-payable refunds) | checkouts/create | No changes observed. |
Create Exchange | A new empty exchangeV2s connection appears on the Order. (Interac Refund and the transaction will also be visible under exchangeV2s.refunds and exchangeV2s.transactions ). | |
Process Checkout (*only for net-payable refunds) | orders/updated | Payment transaction shows up on the Order.transactions and exchangeV2s.transaction fields. |
Process Refund (*only for net-refundable + non-Interac refunds) | refunds/create, orders/updated | Refund transaction appears on Order.transactions and exchangeV2s.transactions . |
Add New Items | orders/edited, orders/updated, fulfillments/create | New items are available in Order.line_items and exchangeV2s.additions . |
Remove Returned Items | refunds/create, orders/updated | New refund and return objects appear on Order, calculated returns values also appear in exchangeV2s.returns . |
Order Financial Status Update | orders/paid (if payable), orders/updated | Update order.finicial_status |
Complete Exchange | ExchangeV2 updates the completed_at timestamp. |
As shown by the chart above, receiving an “orders/updated
” does not indicate the completion of the exchange. This webhook is triggered by the in-between order update actions. The complete exchangeV2s
data can only be guaranteed to be available when the exchange is marked as completed. To determine if the exchange is marked as completed, you can check that the completed_at
field on exchangeV2s
is not empty. If it is empty, it means the exchange is still in progress and the data under exchangeV2s
is incomplete.
It is possible that fewer orders/updated
webhooks than the ones shown in the chart above are received due to performance optimizations. However, at least one webhook for a topic will be sent out during the exchange process.