Query a Buy with Prime Order
Buy with Prime API is now available for early access
Sign up for early access to the Buy with Prime API using the 'Sign Up' button below. The API may change as Amazon receives feedback and iterates on it.
This topic provides examples of how to get information about a Buy with Prime order. In general, you might want to query Buy with Prime orders in the following situations:
- Before updating a Buy with Prime order (for example, to indicate that a pending refund was successful).
- Before updating the status of a Buy with Prime order in your order management system (for example, if you receive a Buy with Prime
ITEM_CANCELLED
event). - To show information, such as delivery tracking, on your site.
To learn how to call the Buy with Prime API, see Call the Buy with Prime API.
Sample data
The examples in this topic use the following sample data.
Order identifier
orderIdentifier: {
orderAlias: {
aliasType: "EXTERNAL_ID",
aliasId: "example-alias-id"
}
}
Order aliases
{
"data": {
"order": {
"orderAliases": [
{
"aliasId": "example-alias-id",
"aliasType": "EXTERNAL_ID"
}
]
}
}
}
Customer
{
"data": {
"order": {
"id": "example-order-id",
"customer": {
"contact": {
"id": "example-contact-id",
"name": "John Doe",
"email": "[[email protected]](mailto:[email protected])"
}
}
}
}
}
Tax summary
{
"data": {
"order": {
"id": "example-order-id",
"taxes": {
"summary": {
"collectableTaxAmount": {
"amount": 10,
"currencyCode": "USD"
}
}
}
}
}
}
Discount summary
{
"data": {
"order": {
"id": "example-order-id",
"discounts": {
"summary": {
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100"
}
}
}
}
}
Discount details
{
"data": {
"order": {
"id": "example-order-id",
"discounts": {
"details": \[
{
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100",
"promotionAliases": [
{
"aliasType": "EXTERNAL_ID",
"aliasId": "M001"
}
],
"couponCode": "BWP001"
}
]
}
}
}
}
Order total
{
"data": {
"order": {
"id": "example-order-id",
"orderTotal": {
"rollupCharges": [
{
"rollupChargeType": "ORDER_SUB_TOTAL",
"value": {
"amount": 10,
"currencyCode": "USD"
}
}
],
"totalPrice": {
"amount": 10,
"currencyCode": "USD"
}
}
}
}
}
Payment summary
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"payments": {
"summary": {
"amount": {
"amount": 10,
"currencyCode": "USD"
},
"paymentMethodDisplayString": "Visa ending in 1234",
"state": "CAPTURED"
}
}
}
],
}
}
}
Payment details
{
"data": {
"order": {
"id": "example-order-id",
"payments": {
"details": [
{
"id": "example-payment-transfer-id",
"amount": {
"amount": 10
},
"paymentMethod": {
"displayString": "AmazonPay",
"type": "AMAZON_PAY"
},
"state": "SUCCESS",
"payer": {
"id": "amzn1.account.ABCDE12345"
},
"aliases": [
{
"aliasType": "EXTERNAL_ID",
"aliasId": "PAY_001-123-456"
}
],
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-04T18:17:19Z"
}
]
}
}
}
}
Refund summary
{
"data": {
"order": {
"id": "example-order-id",
"refunds": {
"summary": {
"refundTotal": {
"totalAmount": {
"amount": 30,
"currencyCode": "USD"
}
},
"paymentSummary": {
"amount": {
"amount": 30,
"currencyCode": "USD"
},
"paymentMethodDisplayString": "Visa ending in 1234",
"state": "REFUNDED"
}
}
}
}
}
}
Refund details
{
"data": {
"order": {
"id": "example-order-id",
"refunds": {
"details": [
{
"id": "example-refund-id",
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-04T18:17:19Z",
"aliases": {
"aliasType": "EXTERNAL_ID",
"aliasId": "example-refund-alias"
},
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-03T18:17:19Z",
"refundTotal": {
"totalAmount": {
"amount": 30,
"currencyCode": "USD"
}
},
"state": "SUCCESS",
"refundFor": {
"orderLineItems": [
{
"lineItem": {
"id": "example-line-item-id"
},
"quantity": {
"amount": 1
}
}
]
},
"paymentDetails": [
{
"id": "example-payment-transfer-id",
"amount": {
"amount": 10
},
"paymentMethod": {
"displayString": "AmazonPay",
"type": "AMAZON_PAY"
},
"state": "SUCCESS",
"payer": {
"id": "amzn1.account.12345ABCDE"
},
"aliases": [],
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-04T18:17:19Z"
}
]
}
]
}
}
}
}
Returns
{
"data": {
"order": {
"id": "example-order-id",
"returns": {
"details": [
{
"id": "example-refund-id",
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-03T18:17:19Z",
"state": "COMPLETED",
"returnFor": {
"orderLineItems": [
{
"lineItem": {
"id": "example-line-item-id"
},
"quantity": {
"amount": 1
}
}
]
}
}
]
}
}
}
}
Order metadata
{
"data": {
"order": {
"id": "example-order-id",
"metadata": {
"executionState": "NOT_STARTED",
"createdAt": "2024-01-18T18:41:30.610Z",
"updatedAt": "2024-01-18T18:41:30.610Z"
}
}
}
}
Order links
{
"data": {
"order": {
"id": "example-order-id",
"orderLinks": [
{
"destinationType": "BWP_STOREFRONT",
"url": "https://order.buywithprime.amazon.com/1234ABCD/orders/example-order-id"
}
]
}
}
}
Email
This section contains a query that you can use to get order details for a confirmation email.
Get order details for a confirmation email
The following example gets information such as line items, customer details, and the order total. You might want this information for an order confirmation email.
Request
query order {
order(orderId: "example-order-id") {
id
customer {
contact {
id
name
email
}
}
lineItems {
id
quantity {
unit
amount
}
purchasedItem {
title
imageUrl
price {
currentPrice {
currencyCode
amount
}
}
}
}
orderTotal {
rollupCharges {
rollupChargeType
value {
amount
currencyCode
}
}
totalPrice {
amount
currencyCode
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"customer": {
"contact": {
"id": "example-contact-id",
"name": "John Doe",
"email": "[email protected]"
}
},
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 2
},
"purchasedItem": {
"title": "example-title",
"imageUrl": "example-image-url",
"price": {
"currentPrice": {
"currencyCode": "USD",
"amount": 8
}
}
}
}
],
"orderTotal": {
"rollupCharges": [
{
"rollupChargeType": "ORDER_SUB_TOTAL",
"value": {
"amount": 10,
"currencyCode": "USD"
}
},
{
"rollupChargeType": "ORDER_TAX",
"value": {
"amount": 2,
"currencyCode": "USD"
}
},
{
"rollupChargeType": "ORDER_SHIPPING",
"value": {
"amount": 0,
"currencyCode": "USD"
}
},
{
"rollupChargeType": "DISCOUNT",
"value": {
"amount": 2,
"currencyCode": "USD"
}
}
],
"totalPrice": {
"amount": 10,
"currencyCode": "USD"
}
}
}
}
}
Order detail page
This section contains queries that you can use to show items on an order detail page.
Get order details for an order detail page
The following example gets customer details, line items, delivery, and other information that you might show on an order detail page.
Request
query order {
order(orderId: "example-order-id") {
id
customer {
contact {
id
name
email
}
}
lineItems {
id
quantity {
unit
amount
}
purchasedItem {
title
imageUrl
price {
currentPrice {
currencyCode
amount
}
}
}
deliveryOffer {
deliveryOfferDetails {
taxes {
summary {
collectableTaxAmount {
amount
currencyCode
}
}
}
discounts {
details {
amount {
amount
currencyCode
}
couponCode
promotionAliases {
aliasType
}
displayString
}
}
}
}
taxes {
summary {
collectableTaxAmount {
amount
currencyCode
}
}
}
discounts {
summary {
amount {
amount
currencyCode
}
}
}
deliveryInformation {
summary {
state
}
}
payments {
summary {
amount {
amount
}
paymentMethodDisplayString
state
}
}
}
taxes {
summary {
collectableTaxAmount {
amount
currencyCode
}
}
}
discounts {
details {
amount {
amount
currencyCode
}
couponCode
promotionAliases {
aliasType
}
displayString
}
}
orderTotal {
rollupCharges {
rollupChargeType
value {
amount
currencyCode
}
}
totalPrice {
amount
currencyCode
}
}
payments {
summary {
amount {
amount
}
paymentMethodDisplayString
state
}
}
refunds {
details {
id
updatedAt
state
refundTotal {
totalAmount {
amount
}
}
refundFor {
orderLineItems {
lineItem {
id
}
refundedQuantity {
amount
unit
}
}
}
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"customer": {
"contact": {
"id": "example-contact-id",
"name": "John Doe",
"email": "[email protected]"
}
},
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"createdAt": "2024-01-18T18:41:30.569Z",
"purchasedItem": {
"title": "example-item-title",
"imageUrl": "example-image-url",
"altText": "This is a picture of the item",
"price": {
"currentPrice": {
"currencyCode": "USD",
"amount": 10
}
}
},
"deliveryOffer": {
"deliveryOfferDetails": {
"taxes": {
"summary": {
"collectableTaxAmount": {
"amount": 2,
"currencyCode": "USD"
}
}
},
"discounts": {
"summary": {
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100"
}
}
}
},
"taxes": {
"summary": {
"collectableTaxAmount": {
"amount": 2,
"currencyCode": "USD"
}
}
},
"discounts": {
"summary": {
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100"
}
},
"deliveryInformation": {
"summary": {
"state": "PENDING"
}
},
"payments": {
"summary": {
"amount": {
"amount": 10,
"currencyCode": "USD"
},
"paymentMethodDisplayString": "Visa ending in 1234",
"state": "CAPTURED"
}
}
}
],
"taxes": {
"summary": {
"collectableTaxAmount": {
"amount": 2,
"currencyCode": "USD"
}
}
},
"discounts": {
"summary": {
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100"
}
},
"payments": {
"summary": {
"amount": {
"amount": 10,
"currencyCode": "USD"
},
"paymentMethodDisplayString": "Visa ending in 1234",
"state": "CAPTURED"
}
},
"orderTotal": {
"rollupCharges": [
{
"rollupChargeType": "ORDER_SUB_TOTAL",
"value": {
"amount": 10,
"currencyCode": "USD"
}
},
{
"rollupChargeType": "ORDER_TAX",
"value": {
"amount": 2,
"currencyCode": "USD"
}
},
{
"rollupChargeType": "ORDER_SHIPPING",
"value": {
"amount": 0,
"currencyCode": "USD"
}
},
{
"rollupChargeType": "DISCOUNT",
"value": {
"amount": 2,
"currencyCode": "USD"
}
}
],
"totalPrice": {
"amount": 10,
"currencyCode": "USD"
}
},
"refunds": {
"details": [
{
"id": "example-refund-id",
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-03T18:17:19Z",
"aliases": {
"aliasType": "EXTERNAL_ID",
"aliasId": "example-alias-id"
},
"refundTotal": {
"totalAmount": {
"amount": 30,
"currencyCode": "USD"
}
},
"state": "SUCCESS",
"refundFor": {
"orderLineItems": [
{
"lineItem": {
"id": "example-line-item-id"
},
"quantity": {
"amount": 1
}
}
]
}
}
]
}
}
}
}
Returns, refunds, and cancellations
This section contains queries that you can use to get information about the returns, refunds, and cancellations associated with an order.
Get all returns that have been initiated for an order
The following example gets all returns that have been initiated for an order. For possible return states, see ReturnDetails
.
Request
query order {
order(orderId: "example-order-id") {
id
returns {
details {
id
createdAt
updatedAt
state
returnFor {
orderLineItems {
lineItem {
id
}
}
}
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"returns": {
"details": [
{
"id": "example-refund-id",
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-03T18:17:19Z",
"state": "COMPLETED",
"returnFor": {
"orderLineItems": [
{
"lineItem": {
"id": "example-line-item-id"
},
"quantity": {
"amount": 1
}
}
]
}
}
]
}
}
}
}
Get refund details
The following example gets all refunds that are associated with an order. For possible refund states, see RefundDetails
.
Request
query order {
order(orderId: "example-order-id") {
id
lineItems {
id
quantity {
unit
amount
}
purchasedItem {
title
imageUrl
price {
currentPrice {
currencyCode
amount
}
}
}
}
refunds {
details {
id
updatedAt
state
refundTotal {
totalAmount {
amount
}
}
refundFor {
orderLineItems {
lineItem {
id
}
refundedQuantity {
amount
unit
}
}
}
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"createdAt": "2024-01-18T18:41:30.569Z",
"purchasedItem": {
"title": "example-item-title",
"imageUrl": "https://example-image-url.jpeg",
"altText": "This is a picture of the item.",
"price": {
"currentPrice": {
"currencyCode": "USD",
"amount": 10
}
}
}
}
],
"refunds": {
"details": [
{
"id": "example-refund-id",
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-03T18:17:19Z",
"aliases": {
"aliasType": "EXTERNAL_ID",
"aliasId": "example-alias-id"
},
"refundTotal": {
"totalAmount": {
"amount": 30,
"currencyCode": "USD"
}
},
"state": "SUCCESS",
"refundFor": {
"orderLineItems": [
{
"lineItem": {
"id": "example-line-item-id"
},
"quantity": {
"amount": 1
}
}
]
}
}
]
}
}
}
}
Get all line items that were canceled in an order
The following example gets the line items that were canceled in an order. In this scenario, the query should start from the lineItems
object and include fields for cancellation. For a list of possible cancellation reasons, see CancellationDetails
. For information about the quantities that were requested for cancellation, see CanceledOrderLineItem
.
Request
query order {
order(orderId: "example-order-id") {
id
lineItems {
id
quantity {
unit
amount
}
cancellations {
details {
aliases {
aliasType
aliasId
}
createdAt
updatedAt
reason
requestedBy
additionalComments
state
refundDetails {
id
aliases {
aliasType
aliasId
}
state
refundTotal {
totalAmount {
amount
}
}
paymentDetails {
id
amount {
amount
}
paymentMethod {
displayString
type
}
state
}
refundFor {
orderLineItems {
lineItem {
id
}
}
}
}
canceledOrderLineItems {
lineItem {
id
}
quantity {
amount
}
}
}
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"cancellations": {
"details": [
{
"aliases": {},
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-03T18:17:19Z",
"reason": "ORDERED_BY_MISTAKE",
"requestedBy": "SHOPPER",
"additionalComments": "",
"state": "SUCCESS",
"refundDetails": [
{
"id": "example-refund-id",
"aliases": {
"aliasType": "EXTERNAL_ID",
"aliasId": "example-alias-id"
},
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-03T18:17:19Z",
"refundTotal": {
"totalAmount": {
"amount": 30,
"currencyCode": "USD"
}
},
"state": "SUCCESS",
"refundFor": {
"orderLineItems": [
{
"lineItem": {
"id": "example-line-item-id"
},
"quantity": {
"amount": 1
}
}
]
},
"paymentDetails": [
{
"id": "example-payment-transfer-id",
"amount": {
"amount": 10
},
"paymentMethod": {
"displayString": "AmazonPay",
"type": "AMAZON_PAY"
},
"state": "SUCCESS",
"payer": {
"id": "example-payer-id"
},
"aliases": [],
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-04T18:17:19Z"
}
],
"canceledOrderLineItems": [
{
"lineItem": {
"id": "example-line-item-id"
},
"quantity": {
"amount": 1
}
}
]
}
]
}
]
}
}
]
}
}
}
Discounts
This section contains queries that you can use to get information about discounts that are associated with an order.
Get discount details and taxes that have been applied at the order and line-item level for an order
The following example looks for discount details and tax summary information at the order level, line item level, and delivery offer level. For details about discounts, see DiscountAllocationDetails
.
Request
query order {
order(orderId: "example-order-id") {
id
lineItems {
id
quantity {
unit
amount
}
deliveryOffer {
deliveryOfferDetails {
taxes {
summary {
collectableTaxAmount {
amount
currencyCode
}
}
}
discounts {
details {
amount {
amount
currencyCode
}
couponCode
promotionAliases {
aliasType
}
displayString
}
}
}
}
taxes {
summary {
collectableTaxAmount {
amount
currencyCode
}
}
}
discounts {
details {
amount {
amount
currencyCode
}
couponCode
promotionAliases {
aliasType
}
displayString
}
}
}
taxes {
summary {
collectableTaxAmount {
amount
currencyCode
}
}
}
discounts {
details {
amount {
amount
currencyCode
}
couponCode
promotionAliases {
aliasType
}
displayString
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"deliveryOffer": {
"deliveryOfferDetails": {
"taxes": {
"summary": {
"collectableTaxAmount": {
"amount": 2,
"currencyCode": "USD"
}
}
},
"discounts": {
"details": {
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100",
"promotionAliases": [],
"couponCode": "BWP001"
}
}
}
},
"taxes": {
"summary": {
"collectableTaxAmount": {
"amount": 2,
"currencyCode": "USD"
}
}
},
"discounts": {
"details": {
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100",
"promotionAliases": [],
"couponCode": "BWP001"
}
}
}
],
"taxes": {
"summary": {
"collectableTaxAmount": {
"amount": 2,
"currencyCode": "USD"
}
}
},
"discounts": {
"details": {
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100",
"promotionAliases": [],
"couponCode": "BWP001"
}
}
}
}
}
Get summaries of all discounts and taxes that have been applied at the order and line-item level for an order
Discounts and taxes can be applied at the order level, line item level, and delivery offer level. The following example looks for discount and tax summary information at all levels.
Request
query order {
order(orderId: "example-order-id") {
id
lineItems {
id
quantity {
unit
amount
}
deliveryOffer {
deliveryOfferDetails {
taxes {
summary {
collectableTaxAmount {
amount
currencyCode
}
}
}
discounts {
summary {
amount {
amount
currencyCode
}
}
}
}
}
taxes {
summary {
collectableTaxAmount {
amount
currencyCode
}
}
}
discounts {
summary {
amount {
amount
currencyCode
}
}
}
}
taxes {
summary {
collectableTaxAmount {
amount
currencyCode
}
}
}
discounts {
summary {
amount {
amount
currencyCode
}
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"deliveryOffer": {
"deliveryOfferDetails": {
"taxes": {
"summary": {
"collectableTaxAmount": {
"amount": 2,
"currencyCode": "USD"
}
}
},
"discounts": {
"summary": {
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100"
}
}
}
},
"taxes": {
"summary": {
"collectableTaxAmount": {
"amount": 2,
"currencyCode": "USD"
}
}
},
"discounts": {
"summary": {
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100"
}
}
}
],
"taxes": {
"summary": {
"collectableTaxAmount": {
"amount": 2,
"currencyCode": "USD"
}
}
},
"discounts": {
"summary": {
"amount": {
"amount": 1,
"currencyCode": "USD"
},
"displayString": "20% off on orders above $100"
}
}
}
}
}
Customer, products, delivery, and payments
This section contains queries that you can use to get information about the customer, products, delivery, and payments that are associated with an order.
Get customer information for an order
The following example gets the customer information for an order. For details about customer information, see Customer
.
Request
query order {
order(orderId: "example-order-id") {
id
customer {
contact {
id
name
email
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"customer": {
"contact": {
"id": "example-contact-id",
"name": "John Doe",
"email": "[email protected]"
}
}
}
}
}
Get product information for all line items in an order
The following example gets the product information for all line items in an order. For details, see LineItem
.
Request
query order {
order(orderId: "example-order-id") {
id
lineItems {
id
quantity {
unit
amount
}
createdAt
purchasedItem {
title
imageUrl
productDetailPageUrl
altText
price {
currentPrice {
currencyCode
amount
}
}
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"createdAt": "2024-01-18T18:41:30.569Z",
"purchasedItem": {
"title": "example-item-title",
"imageUrl": "example-image-url",
"productDetailPageUrl": "example-product-detail-page-url",
"altText": "This is a picture of the item.",
"price": {
"currentPrice": {
"currencyCode": "USD",
"amount": 10
}
}
}
}
]
}
}
}
Get delivery information for all line items in an order
The following example gets delivery information for all line items in an order. You can query for both DeliveryInformationSummary
(minimal details like delivery state) and DeliveryInformationDetails
(delivery state, estimated delivery date, tracking details, and so on). If an order only has summary information, the details will be empty.
Request
query order {
order(
orderIdentifier: {
orderAlias: { aliasType: "EXTERNAL_ID", aliasId: "example-alias-id" }
}
) {
id
lineItems {
id
quantity {
unit
amount
}
deliveryInformation {
summary {
state
}
details {
state
reason
estimatedDeliveryDate
deliverFromAddress {
name
streetAddress
locality
region
countryCode
postalCode
}
trackingDetails {
trackingId
carrierCode
}
association {
interval {
start
measure
}
}
}
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"deliveryInformation": {
"summary": {
"state": "PENDING"
},
"details": [
{
"state": "PENDING",
"reason": null,
"estimatedDeliveryDate": "2024-01-11",
"deliverFromAddress": {
"name": "John Doe",
"streetAddress": "440 Terry Ave N",
"locality": "Seattle",
"region": "WA",
"countryCode": "US",
"postalCode": "98109"
},
"trackingDetails": {
"trackingId": "example-tracking-id",
"carrierCode": "UPS"
},
"association": [
{
"interval": {
"start": 0,
"measure": 1
}
}
]
}
]
}
}
]
}
}
}
Get all payments that have been applied at the order and line-item level for an order
While you create or update an order, you can input either a PaymentSummary
that captures a summary of all payment transactions at the order and line-item level, or you can enter PaymentDetails
to capture detailed information for each payment transaction. You can query for both summary and details, but the response contains either summary or details depending on what you passed in when you created or updated the order.
The following example gets payments at the order and line-item level in the case where the order was created with only a PaymentSummary
at the line-item level.
Request
query order {
order(orderId: "example-order-id") {
id
lineItems {
id
quantity {
unit
amount
}
payments {
summary {
amount {
amount
}
paymentMethodDisplayString
state
}
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"payments": {
"summary": {
"amount": {
"amount": 10,
"currencyCode": "USD"
},
"paymentMethodDisplayString": "Visa ending in 1234",
"state": "CAPTURED"
}
}
}
],
}
}
}
The following example gets payments at the order and line-item level in the case where the order was created with a PaymentSummary
at both the line-item level ($10 payment) and order level ($20 payment).
Request
query order {
order(orderId: "examplel-order-id") {
id
lineItems {
id
quantity {
unit
amount
}
payments {
summary {
amount {
amount
currencyCode
}
paymentMethodDisplayString
state
}
}
}
payments {
summary {
amount {
amount
currencyCode
}
paymentMethodDisplayString
state
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"payments": {
"summary": {
"amount": {
"amount": 10,
"currencyCode": "USD"
},
"paymentMethodDisplayString": "Visa ending in 1234",
"state": "CAPTURED"
}
}
}
],
"payments": {
"summary": {
"amount": {
"amount": 20,
"currencyCode": "USD"
},
"paymentMethodDisplayString": "Visa ending in 1234",
"state": "CAPTURED"
}
}
}
}
}
The following example gets payments at the order and line-item level in the case where the order was created with PaymentDetails
at the order level.
Request
query order {
order(orderId: "example-order-id") {
id
lineItems {
id
quantity {
unit
amount
}
payments {
details {
id
amount {
amount
}
paymentMethod {
displayString
type
}
state
payer {
id
}
aliases {
aliasType
aliasId
}
createdAt
updatedAt
}
}
}
payments {
details {
id
amount {
amount
}
paymentMethod {
displayString
type
}
state
payer {
id
}
aliases {
aliasType
aliasId
}
createdAt
updatedAt
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
},
"payments": {
"details": []
}
}
],
"payments": {
"details": [
{
"id": "example-payment-transfer-id",
"amount": {
"amount": 10
},
"paymentMethod": {
"displayString": "AmazonPay",
"type": "AMAZON_PAY"
},
"state": "SUCCESS",
"payer": {
"id": "amzn1.account.ABCDE12345"
},
"aliases": [],
"createdAt": "2022-02-03T18:17:19Z",
"updatedAt": "2022-02-04T18:17:19Z"
}
]
}
}
}
}
Overall order
This section contains queries that you can use to retrieve overall details about the order.
Get an order with the specified alias
An alias is an external ID, such as the order number in your own system, that you can optionally include when you create an order with the Order API. The following query gets an order with the specified alias. To query an order that has an alias, pass orderIdentifier
in the query input. Note that the query input takes either an orderIdentifier
(an alias) or an orderId
(Buy with Prime order ID), never both.
Request
query order {
order(
orderIdentifier: {
orderAlias: { aliasType: "EXTERNAL_ID", aliasId: "example-alias-id" }
}
) {
id
lineItems {
id
quantity {
unit
amount
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
}
}
]
}
}
}
Get the order total, execution state, and last updated time for an order
The following example gets general information about an order. For details about order metadata, see OrderMetadata
.
Request
query order {
order(orderId: "example-order-id") {
id
orderTotal {
rollupCharges {
rollupChargeType
value {
amount
currencyCode
}
}
totalPrice {
amount
currencyCode
}
}
metadata {
executionState
createdAt
updatedAt
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"orderTotal": {
"rollupCharges": [
{
"rollupChargeType": "ORDER_SUB_TOTAL",
"value": {
"amount": 10,
"currencyCode": "USD"
}
},
{
"rollupChargeType": "ORDER_TAX",
"value": {
"amount": 2,
"currencyCode": "USD"
}
},
{
"rollupChargeType": "ORDER_SHIPPING",
"value": {
"amount": 0,
"currencyCode": "USD"
}
},
{
"rollupChargeType": "DISCOUNT",
"value": {
"amount": 2,
"currencyCode": "USD"
}
}
],
"totalPrice": {
"amount": 10,
"currencyCode": "USD"
}
},
"metadata": {
"executionState": "NOT_STARTED",
"createdAt": "2024-01-18T18:41:30.610Z",
"updatedAt": "2024-01-18T18:41:30.610Z"
}
}
}
}
Related topics
Updated 3 days ago