as

Settings
Sign out
Notifications
Alexa
Amazonアプリストア
Ring
AWS
ドキュメント
Support
Contact Us
My Cases
Docs
Resources
Ecommerce Plug-ins
Publish
Connect
アクセスいただきありがとうございます。こちらのページは現在英語のみのご用意となっております。順次日本語化を進めてまいりますので、ご理解のほどよろしくお願いいたします。

Create Purchases Test Cases

Disclaimer: This document contains sample content for illustrative purposes only. Organizations should follow their own established best practices, security requirements, and compliance standards to ensure solutions are production-ready.

Create Purchases API Test Cases

Overview

These test cases validate the Create Purchases API (POST /v1/order/purchases), which Amazon calls after a shopper exits the store to pass the virtual shopping cart to the retailer's Ordering Connector. The retailer calculates pricing, promotions, and taxes, then returns a purchaseId. All requests must be handled idempotently using the idempotentShoppingTripId.


1. Successful Purchase Creation (201)

1.1 Single Item Cart — SKU Type, Sold by Unit

Objective: Verify a single-item cart with unit quantity is processed successfully

Request:

{
  "requestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "idempotentShoppingTripId": "11111111-2222-3333-4444-555555555555",
  "storeId": "STORE-001",
  "shoppingTrip": {
    "startTime": "2024-03-22T17:00:00Z",
    "endTime": "2024-03-22T17:09:39Z",
    "authEvents": [
      {
        "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
        "timestamp": "2024-03-22T17:00:00Z",
        "location": "ENTRY",
        "payloadType": "FINANCIAL",
        "scanResult": {
          "id": "shopper-001",
          "type": "SHOPPER"
        }
      }
    ]
  },
  "cartItems": [
    {
      "id": "SKU-001",
      "type": "SKU",
      "quantity": {
        "value": "1.0",
        "unit": "unit"
      }
    }
  ],
  "shopperIdentity": {
    "id": "shopper-identity-001"
  }
}

Expected Response (201):

{
  "purchaseId": "PUR-00001"
}

Expected Result: Purchase record created. purchaseId returned for cross-system tracking.

1.2 Multi-Item Cart

Objective: Verify a cart with multiple different items is processed successfully

Request:

{
  "requestId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
  "idempotentShoppingTripId": "22222222-3333-4444-5555-666666666666",
  "storeId": "STORE-001",
  "shoppingTrip": {
    "startTime": "2024-03-22T17:00:00Z",
    "endTime": "2024-03-22T17:15:00Z",
    "authEvents": [
      {
        "id": "bbbbbbbb-cccc-dddd-eeee-ffffffffffff",
        "timestamp": "2024-03-22T17:00:00Z",
        "location": "ENTRY",
        "payloadType": "SCAN_CODE",
        "scanResult": {
          "id": "shopper-002",
          "type": "SHOPPER"
        }
      }
    ]
  },
  "cartItems": [
    {
      "id": "SKU-001",
      "type": "SKU",
      "quantity": { "value": "2.0", "unit": "unit" }
    },
    {
      "id": "SKU-002",
      "type": "SKU",
      "quantity": { "value": "1.0", "unit": "unit" }
    },
    {
      "id": "SKU-003",
      "type": "SKU",
      "quantity": { "value": "4.0", "unit": "unit" }
    }
  ]
}

Expected Response (201):

{
  "purchaseId": "PUR-00002"
}

Expected Result: All items priced correctly. Promotions and taxes applied.

1.3 Weight-Based Item

Objective: Verify a cart item sold by weight is processed correctly

Request cartItems:

{
  "cartItems": [
    {
      "id": "SKU-PRODUCE-001",
      "type": "SKU",
      "quantity": {
        "value": "1.5",
        "unit": "lb"
      }
    }
  ]
}

Expected Response (201): purchaseId returned. Charge calculated based on weight × price per unit.

1.4 SCANCODE Cart Item Type

Objective: Verify a cart item with type SCANCODE is processed correctly

Request cartItems:

{
  "cartItems": [
    {
      "id": "BARCODE-123456789012",
      "type": "SCANCODE",
      "quantity": { "value": "1.0", "unit": "unit" }
    }
  ]
}

Expected Response (201): purchaseId returned.

1.5 Cart Item with External Identifiers

Objective: Verify cart items with optional externalIdentifiers are processed correctly

Request cartItems:

{
  "cartItems": [
    {
      "id": "SKU-001",
      "type": "SKU",
      "quantity": { "value": "1.0", "unit": "unit" },
      "externalIdentifiers": [
        { "id": "123456789012", "type": "UPC" },
        { "id": "5901234123457", "type": "EAN" }
      ]
    }
  ]
}

Expected Response (201): purchaseId returned. External identifiers associated with the cart item.

1.6 Cart Item with lineItemId

Objective: Verify optional lineItemId is accepted and can be used for input/output cart item correlation

Request cartItems:

{
  "cartItems": [
    {
      "id": "SKU-001",
      "type": "SKU",
      "quantity": { "value": "1.0", "unit": "unit" },
      "lineItemId": "line-item-001"
    }
  ]
}

Expected Response (201): purchaseId returned.

1.7 Empty Cart

Objective: Verify an empty cart (shopper exited without taking items) is handled correctly

Request:

{
  "requestId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
  "idempotentShoppingTripId": "33333333-4444-5555-6666-777777777777",
  "storeId": "STORE-001",
  "shoppingTrip": {
    "startTime": "2024-03-22T17:00:00Z",
    "endTime": "2024-03-22T17:02:00Z",
    "authEvents": [
      {
        "id": "cccccccc-dddd-eeee-ffff-111111111111",
        "timestamp": "2024-03-22T17:00:00Z",
        "location": "ENTRY",
        "payloadType": "FINANCIAL"
      }
    ]
  },
  "cartItems": []
}

Expected Response (201):

{
  "purchaseId": ""
}

Expected Result: Empty purchaseId returned. No charge is created. For app entry stores, pre-auth cancellation should be triggered.

1.8 Credit Card Entry (FINANCIAL payloadType)

Objective: Verify purchase creation for a credit card entry shopping trip

Request authEvents:

{
  "authEvents": [
    {
      "id": "dddddddd-eeee-ffff-1111-222222222222",
      "timestamp": "2024-03-22T17:00:00Z",
      "location": "ENTRY",
      "payloadType": "FINANCIAL"
    }
  ]
}

Expected Response (201): purchaseId returned.

1.9 QR Code Entry (SCAN_CODE payloadType)

Objective: Verify purchase creation for a QR code / app entry shopping trip

Request authEvents:

{
  "authEvents": [
    {
      "id": "eeeeeeee-ffff-1111-2222-333333333333",
      "timestamp": "2024-03-22T17:00:00Z",
      "location": "ENTRY",
      "payloadType": "SCAN_CODE",
      "scanResult": {
        "id": "shopper-003",
        "type": "SHOPPER"
      }
    }
  ]
}

Expected Response (201): purchaseId returned.

1.10 Associate Shopping Trip

Objective: Verify purchase creation when the visitor is a store associate

Request authEvents scanResult:

{
  "scanResult": {
    "id": "associate-001",
    "type": "ASSOCIATE"
  }
}

Expected Response (201): purchaseId returned. Associate purchase tracked separately.

1.11 Cash Shopper Trip

Objective: Verify purchase creation for a CASH shopper type

Request authEvents scanResult:

{
  "scanResult": {
    "id": "cash-shopper-001",
    "type": "CASH"
  }
}

Expected Response (201): purchaseId returned.

1.12 Loyalty Shopper Trip

Objective: Verify purchase creation for a LOYALTY shopper type with loyalty pricing applied

Request authEvents scanResult:

{
  "scanResult": {
    "id": "loyalty-shopper-001",
    "type": "LOYALTY"
  }
}

Expected Response (201): purchaseId returned. Loyalty promotions applied to cart.

1.13 Group Shopping Trip — Multiple Auth Events

Objective: Verify purchase creation when multiple shoppers entered together (group trip)

Request authEvents:

{
  "authEvents": [
    {
      "id": "aaaaaaaa-1111-2222-3333-444444444444",
      "timestamp": "2024-03-22T17:00:00Z",
      "location": "ENTRY",
      "payloadType": "SCAN_CODE",
      "scanResult": { "id": "shopper-A", "type": "SHOPPER" }
    },
    {
      "id": "bbbbbbbb-1111-2222-3333-444444444444",
      "timestamp": "2024-03-22T17:00:05Z",
      "location": "ENTRY",
      "payloadType": "SCAN_CODE",
      "scanResult": { "id": "shopper-B", "type": "SHOPPER" }
    }
  ]
}

Expected Response (201): purchaseId returned. Cart is associated with the group trip.

1.14 Auth Event with MANUAL_IN_STORE Location

Objective: Verify purchase creation when an auth event has location MANUAL_IN_STORE (associate-assisted entry)

Request authEvents:

{
  "authEvents": [
    {
      "id": "ffffffff-1111-2222-3333-444444444444",
      "timestamp": "2024-03-22T17:05:00Z",
      "location": "MANUAL_IN_STORE",
      "payloadType": "SCAN_CODE",
      "scanResult": { "id": "shopper-004", "type": "SHOPPER" }
    }
  ]
}

Expected Response (201): purchaseId returned.

1.15 Optional Fields Omitted

Objective: Verify request succeeds when all optional fields (shopperIdentity, shopperDeviceId, keyChannel, lineItemId, externalIdentifiers, scanResult, authEvent timestamp/location) are omitted

Request: Include only required fields: requestId, idempotentShoppingTripId, storeId, shoppingTrip (with startTime, endTime, authEvents containing id and payloadType), cartItems (with id, type, quantity)

Expected Response (201): purchaseId returned.


2. Idempotency

2.1 Duplicate Request — Same idempotentShoppingTripId

Objective: Verify the same purchaseId is returned when the API is called multiple times with the same idempotentShoppingTripId

Test Steps:

  1. Send a valid request with idempotentShoppingTripId 11111111-2222-3333-4444-555555555555
  2. Confirm 201 response with purchaseId PUR-00001
  3. Send the exact same request again
  4. Confirm the response returns the same purchaseId PUR-00001

Expected Result: Both responses are identical. No duplicate purchase records created.

2.2 Same idempotentShoppingTripId, Different requestId

Objective: Verify idempotency is keyed on idempotentShoppingTripId, not requestId

Test Steps:

  1. Send a request with idempotentShoppingTripId AAAA-... and requestId 1111-...
  2. Send the same request but with a new requestId 2222-... and the same idempotentShoppingTripId
  3. Confirm both responses return the same purchaseId

Expected Result: idempotentShoppingTripId drives idempotency.

2.3 Rapid Retries

Objective: Simulate Amazon retrying the same shopping trip multiple times in quick succession

Test Steps:

  1. Send 5 identical requests with the same idempotentShoppingTripId within 1 second
  2. Verify all responses return the same purchaseId
  3. Verify only one purchase record is created

Expected Result: All responses are consistent. No duplicate side effects.


3. Bad Request — Validation Errors (400)

3.1 Missing requestId

Request: Omit requestId from the body

Expected Response (400):

{ "message": "Missing required field: requestId" }

3.2 Invalid requestId Format

Request: Set requestId to "not-a-uuid"

Expected Response (400):

{ "message": "Invalid requestId format" }

3.3 Missing idempotentShoppingTripId

Request: Omit idempotentShoppingTripId from the body

Expected Response (400):

{ "message": "Missing required field: idempotentShoppingTripId" }

3.4 Missing storeId

Request: Omit storeId from the body

Expected Response (400):

{ "message": "Missing required field: storeId" }

3.5 storeId Exceeds 255 Characters

Request: Set storeId to a string longer than 255 characters

Expected Response (400):

{ "message": "storeId exceeds maximum length of 255 characters" }

3.6 Missing shoppingTrip

Request: Omit the entire shoppingTrip object

Expected Response (400):

{ "message": "Missing required field: shoppingTrip" }

3.7 Missing shoppingTrip.startTime

Request: Omit startTime from shoppingTrip

Expected Response (400):

{ "message": "Missing required field: shoppingTrip.startTime" }

3.8 Missing shoppingTrip.endTime

Request: Omit endTime from shoppingTrip

Expected Response (400):

{ "message": "Missing required field: shoppingTrip.endTime" }

3.9 Invalid shoppingTrip.startTime Format

Request: Set startTime to "not-a-timestamp"

Expected Response (400):

{ "message": "Invalid shoppingTrip.startTime format" }

3.10 endTime Before startTime

Request: Set startTime to "2024-03-22T18:00:00Z" and endTime to "2024-03-22T17:00:00Z"

Expected Response (400):

{ "message": "shoppingTrip.endTime must be after shoppingTrip.startTime" }

3.11 Missing shoppingTrip.authEvents

Request: Omit authEvents from shoppingTrip

Expected Response (400):

{ "message": "Missing required field: shoppingTrip.authEvents" }

3.12 Missing authEvent.id

Request: Include an authEvent without the id field

Expected Response (400):

{ "message": "Missing required field: authEvents[].id" }

3.13 Invalid authEvent.id Format

Request: Set authEvent id to "not-a-uuid"

Expected Response (400):

{ "message": "Invalid authEvents[].id format" }

3.14 authEvent.id Exceeds 255 Characters

Request: Set authEvent id to a string longer than 255 characters

Expected Response (400):

{ "message": "authEvents[].id exceeds maximum length of 255 characters" }

3.15 Missing authEvent.payloadType

Request: Include an authEvent without the payloadType field

Expected Response (400):

{ "message": "Missing required field: authEvents[].payloadType" }

3.16 Invalid authEvent.payloadType Value

Request: Set payloadType to "INVALID"

Expected Response (400):

{ "message": "Invalid authEvents[].payloadType value" }

3.17 Invalid authEvent.location Value

Request: Set location to "INVALID" (valid values: ENTRY, EXIT, MANUAL_IN_STORE)

Expected Response (400):

{ "message": "Invalid authEvents[].location value" }

3.18 Missing cartItems

Request: Omit the cartItems array entirely

Expected Response (400):

{ "message": "Missing required field: cartItems" }

3.19 Missing cartItems[].id

Request: Include a cart item without the id field

Expected Response (400):

{ "message": "Missing required field: cartItems[].id" }

3.20 cartItems[].id Exceeds 255 Characters

Request: Set cart item id to a string longer than 255 characters

Expected Response (400):

{ "message": "cartItems[].id exceeds maximum length of 255 characters" }

3.21 Missing cartItems[].type

Request: Include a cart item without the type field

Expected Response (400):

{ "message": "Missing required field: cartItems[].type" }

3.22 Invalid cartItems[].type Value

Request: Set cart item type to "INVALID" (valid values: SKU, SCANCODE)

Expected Response (400):

{ "message": "Invalid cartItems[].type value" }

3.23 Missing cartItems[].quantity

Request: Include a cart item without the quantity object

Expected Response (400):

{ "message": "Missing required field: cartItems[].quantity" }

3.24 Missing cartItems[].quantity.value

Request: Include quantity object without the value field

Expected Response (400):

{ "message": "Missing required field: cartItems[].quantity.value" }

3.25 quantity.value Exceeds 10 Characters

Request: Set quantity value to "12345678901" (exceeds 10 character limit)

Expected Response (400):

{ "message": "cartItems[].quantity.value exceeds maximum length of 10 characters" }

3.26 Missing cartItems[].quantity.unit

Request: Include quantity object without the unit field

Expected Response (400):

{ "message": "Missing required field: cartItems[].quantity.unit" }

3.27 Invalid externalIdentifiers[].type Value

Request: Set external identifier type to "INVALID" (valid values: UPC, EAN, BARCODE, GTIN, PLU)

Expected Response (400):

{ "message": "Invalid externalIdentifiers[].type value" }

3.28 externalIdentifiers[].id Exceeds 255 Characters

Request: Set external identifier id to a string longer than 255 characters

Expected Response (400):

{ "message": "externalIdentifiers[].id exceeds maximum length of 255 characters" }

3.29 Invalid scanResult.type Value

Request: Set scanResult type to "INVALID" (valid values: SHOPPER, ASSOCIATE, CASH, LOYALTY)

Expected Response (400):

{ "message": "Invalid scanResult.type value" }

3.30 scanResult.id Exceeds 255 Characters

Request: Set scanResult id to a string longer than 255 characters

Expected Response (400):

{ "message": "scanResult.id exceeds maximum length of 255 characters" }

3.31 shopperIdentity.id Exceeds 255 Characters

Request: Set shopperIdentity id to a string longer than 255 characters

Expected Response (400):

{ "message": "shopperIdentity.id exceeds maximum length of 255 characters" }

3.32 shopperDeviceId Exceeds 255 Characters

Request: Set shopperDeviceId to a string longer than 255 characters

Expected Response (400):

{ "message": "shopperDeviceId exceeds maximum length of 255 characters" }

3.33 lineItemId Exceeds 255 Characters

Request: Set lineItemId to a string longer than 255 characters

Expected Response (400):

{ "message": "lineItemId exceeds maximum length of 255 characters" }

3.34 Duplicate lineItemId Values

Request: Include two cart items with the same lineItemId

Expected Response (400):

{ "message": "Duplicate lineItemId values in cartItems" }

3.35 Empty Request Body

Request:

{}

Expected Response (400):

{ "message": "Invalid request body" }

4. Unauthorized (401)

4.1 Missing Authorization

Objective: Verify 401 when the request does not contain valid authorization credentials

Test Method: Send a request without IAM role credentials or with an IAM role that is not allowlisted in the retailer's API Gateway

Expected Response (401):

{ "message": "Authorization declined" }

4.2 Expired Credentials

Objective: Verify 401 when the IAM STS credentials have expired

Expected Response (401):

{ "message": "Authorization declined" }

5. Not Found (404)

5.1 Unknown Resource URL

Objective: Verify 404 when the request is made to an incorrect endpoint

Test Method: Send a POST to /v1/order/invalid instead of /v1/order/purchases

Expected Response (404):

{ "message": "Not found" }

5.2 Misconfigured Invoke URL

Objective: Verify 404 when the retailer's invoke URL is not properly configured in the Amazon system

Expected Response (404):

{ "message": "Not found" }

6. Rate Limiting (429)

6.1 Exceed Rate Limit

Objective: Trigger throttling by exceeding the API rate limit

Test Method: Send rapid concurrent requests beyond the configured rate limit

Expected Response (429):

{ "message": "Too Many Requests" }

Expected Result: Caller should retry with exponential backoff.


7. Internal Server Error (500)

7.1 Unhandled Server Exception

Objective: Verify 500 when the Ordering Connector encounters an unhandled exception

Test Method: Simulate a backend failure (e.g., database unavailable, unhandled null pointer)

Expected Response (500):

{ "message": "Internal server error" }

8. Service Unavailable (503)

8.1 Endpoint Down for Maintenance

Objective: Verify 503 when the Ordering Connector endpoint is unavailable

Test Method: Simulate endpoint downtime (planned or unplanned)

Expected Response (503):

{ "message": "Service unavailable" }

9. Cart Edge Cases

9.1 Unrecognized SKU in Cart

Objective: Verify behavior when a cart item contains a SKU not found in the uploaded catalog

Request cartItems:

{
  "cartItems": [
    {
      "id": "UNKNOWN-SKU-999",
      "type": "SKU",
      "quantity": { "value": "1.0", "unit": "unit" }
    }
  ]
}

Expected Result: 201 response per API spec (payload is structurally valid). Retailer routes the item to the bad cart process for resolution.

9.2 Zero Quantity Item

Objective: Verify behavior when a cart item has a quantity value of 0

Request cartItems:

{
  "cartItems": [
    {
      "id": "SKU-001",
      "type": "SKU",
      "quantity": { "value": "0.0", "unit": "unit" }
    }
  ]
}

Expected Result: Verify whether the system rejects (400) or accepts (201) a zero-quantity item. Document the behavior.

9.3 Negative Quantity Item

Objective: Verify behavior when a cart item has a negative quantity value

Request cartItems:

{
  "cartItems": [
    {
      "id": "SKU-001",
      "type": "SKU",
      "quantity": { "value": "-1.0", "unit": "unit" }
    }
  ]
}

Expected Result: Verify whether the system rejects (400) or accepts (201) a negative quantity. Document the behavior.

9.4 Large Cart — Many Items

Objective: Verify the API handles a cart with a large number of items

Test Method: Submit a request with 500+ cart items

Expected Response (201): purchaseId returned. All items processed.

9.5 Mixed SKU and SCANCODE Items

Objective: Verify a cart containing both SKU and SCANCODE item types

Request cartItems:

{
  "cartItems": [
    {
      "id": "SKU-001",
      "type": "SKU",
      "quantity": { "value": "1.0", "unit": "unit" }
    },
    {
      "id": "BARCODE-987654321098",
      "type": "SCANCODE",
      "quantity": { "value": "1.0", "unit": "unit" }
    }
  ]
}

Expected Response (201): purchaseId returned.

9.6 Multiple External Identifier Types on One Item

Objective: Verify a cart item with multiple external identifiers of different types

Request cartItems:

{
  "cartItems": [
    {
      "id": "SKU-001",
      "type": "SKU",
      "quantity": { "value": "1.0", "unit": "unit" },
      "externalIdentifiers": [
        { "id": "123456789012", "type": "UPC" },
        { "id": "5901234123457", "type": "EAN" },
        { "id": "00123456789012", "type": "GTIN" },
        { "id": "4011", "type": "PLU" }
      ]
    }
  ]
}

Expected Response (201): purchaseId returned. All external identifiers associated.


10. Graceful Handling of New Attributes

10.1 Unknown Fields in Request

Objective: Verify the Ordering Connector gracefully ignores unknown fields (forward compatibility)

Request: Add an unknown field "newFutureField": "value" to the request body

Expected Response (201): purchaseId returned. Unknown field does not cause a failure.


Test Data Requirements

Data Item Description
Valid store ID Store ID assigned during onboarding
Valid SKU IDs SKUs that exist in the uploaded catalog
Unknown SKU ID A SKU not present in the catalog (for bad cart testing)
SCANCODE ID A valid barcode value for SCANCODE type items
Shopper identity ID UUID returned by the Identity Connector for a known shopper
Associate identity ID UUID for a known store associate
Loyalty shopper ID UUID for a shopper with loyalty program membership
Cash shopper ID UUID for a cash-paying shopper (cash-enabled store only)
Weight-based item SKU A SKU configured for sale by weight (e.g., produce)

Test Execution Notes

  1. Idempotency: Verify that repeated calls with the same idempotentShoppingTripId produce the same purchaseId and do not create duplicate records.
  2. Empty Carts: For app entry stores, confirm that empty carts trigger pre-auth cancellation. For credit card entry stores, confirm no additional tasks are needed.
  3. Bad Cart Process: Coordinate with your team to verify that unrecognized SKUs are routed to the bad cart handling process.
  4. Authorization: Ensure the Amazon IAM role is allowlisted in your API Gateway before running tests. A missing allowlist entry will produce 401 errors.
  5. Forward Compatibility: Structure your code to ignore unknown attributes gracefully, as Amazon may add new fields in the future.
  6. Timestamps: All timestamps must follow ISO-8601 UTC format.