0
votes

When using the sample POSTMAN request:

{
  "idempotency_key": "74ae1696-b1e3-4328-af6d-f1e04d947a13",
  "order": {
    "reference_id": "my-order-001",
    "line_items": [
    {
      "name": "line-item-1",
      "quantity": "1",
      "base_price_money": {
        "amount": 1599,
        "currency": "USD"
      }
    },
    {
      "name": "line-item-2",
      "quantity": "2",
      "base_price_money": {
        "amount": 799,
        "currency": "USD"
      }
    }]
  },
  "ask_for_shipping_address": true,
  "merchant_support_email": "[email protected]",
  "pre_populate_buyer_email": "[email protected]",
  "pre_populate_shipping_address": {
    "address_line_1": "500 Electric Ave",
    "address_line_2": "Suite 600",
    "locality": "New York",
    "administrative_district_level_1": "NY",
    "postal_code": "10003",
    "first_name": "Jane",
    "last_name": "Doe"
  },
  "redirect_url": "https://merchant.website.com/order-confirm"
}

I'm getting the following response:

{
  "errors": [
    {
      "category": "INVALID_REQUEST_ERROR",
      "code": "INVALID_VALUE",
      "detail": "The order must have at least one line item.",
        "field": "line_items"
    }]
}

This is simply executing the sample POSTMAN requests available via https://docs.connect.squareup.com/api/connect/v2/#runningpostman

2

2 Answers

0
votes

I was having the same issue and I reached out to Tristan. Tristan replied there was a bug that square development had to fix. I confirmed that the create checkout API is now working properly so this issue should be resolved now.

0
votes

Are you using your sandbox or production access tokens? I was able to generate a checkout form with the example postman request:

{
  "idempotency_key": "73ae1696-b1e3-4328-af6d-f1e04d947a13",
  "order": {
    "reference_id": "my-order-001",
    "line_items": [
      {
        "name": "line-item-1",
        "quantity": "1",
        "base_price_money": {
          "amount": 1599,
          "currency": "USD"
        }
      },
      {
        "name": "line-item-2",
        "quantity": "2",
        "base_price_money": {
          "amount": 799,
          "currency": "USD"
        }
      }
    ]
  },
  "ask_for_shipping_address": true,
  "merchant_support_email": "[email protected]",
  "pre_populate_buyer_email": "[email protected]",
  "pre_populate_shipping_address": {
    "address_line_1": "500 Electric Ave",
    "address_line_2": "Suite 600",
    "locality": "New York",
    "administrative_district_level_1": "NY",
    "postal_code": "10003",
    "first_name": "Jane",
    "last_name": "Doe"
  },
  "redirect_url": "https://merchant.website.com/order-confirm"
}