CreatePaymentLink doesn't honour order state

Hi,

I’m using the CreatePaymentLink API and passing in the Order State of OPEN, but the response is DRAFT. Why does the order state not get honoured?

Request:

{
“idempotency_key”: “8519cf5f-2850-4aa9-9e1a-0d37e48ed1c3”,
“order”: {
“location_id”: “LVYAJFRZ4X6G9”,
“reference_id”: “PMO-3-3320”,
“customer_id”: “F18H88Q3C7D84BC7MA2EJZSE7C”,
“line_items”: [
{
“uid”: “3320”,
“name”: “xxxxxxx”,
“quantity”: “1”,
“base_price_money”: {
“amount”: 29500,
“currency”: “GBP”
}
}
],
“state”: “OPEN”
},
“checkout_options”: {
“allow_tipping”: false,
“redirect_url”: “xxxxx”,
“merchant_support_email”: “xxxxx”,
“ask_for_shipping_address”: false
},
“pre_populated_data”: {
“buyer_email”: “xxxxx”,
“buyer_phone_number”: “xxxxx”
}
}

Response:
{
“payment_link”: {
“id”: “UVX2LSH2RLBXDD5G”,
“version”: 1,
“order_id”: “AFeDrodxhTGbkUzVFxiW9zcZJtEZY”,
“checkout_options”: {
“allow_tipping”: false,
“redirect_url”: “xxxx”,
“merchant_support_email”: “xxxx”,
“ask_for_shipping_address”: false
},
“pre_populated_data”: {
“buyer_email”: “xxxxx”,
“buyer_phone_number”: “xxxxx”
},
“url”: “https://connect.squareupsandbox.com/v2/online-checkout/sandbox-testing-panel/ML4STSSC84TW3/UVX2LSH2RLBXDD5G”,
“created_at”: “2022-08-24T12:40:04Z”
},
“related_resources”: {
“orders”: [
{
“id”: “AFeDrodxhTGbkUzVFxiW9zcZJtEZY”,
“location_id”: “LVYAJFRZ4X6G9”,
“reference_id”: “PMO-3-3320”,
“source”: {
“name”: “Sandbox for sq0idp-GUL2D_Gizxt1Qd9FKVWSQg”
},
“customer_id”: “F18H88Q3C7D84BC7MA2EJZSE7C”,
“line_items”: [
{
“uid”: “3320”,
“name”: “xxxxxxx”,
“quantity”: “1”,
“item_type”: “ITEM”,
“base_price_money”: {
“amount”: 29500,
“currency”: “GBP”
},
“variation_total_price_money”: {
“amount”: 29500,
“currency”: “GBP”
},
“gross_sales_money”: {
“amount”: 29500,
“currency”: “GBP”
},
“total_tax_money”: {
“amount”: 0,
“currency”: “GBP”
},
“total_discount_money”: {
“amount”: 0,
“currency”: “GBP”
},
“total_money”: {
“amount”: 29500,
“currency”: “GBP”
}
}
],
“fulfillments”: [
{
“uid”: “9JVwdqjg2GG1x30FbkEpkD”,
“type”: “DIGITAL”,
“state”: “PROPOSED”
}
],
“net_amounts”: {
“total_money”: {
“amount”: 29500,
“currency”: “GBP”
},
“tax_money”: {
“amount”: 0,
“currency”: “GBP”
},
“discount_money”: {
“amount”: 0,
“currency”: “GBP”
},
“tip_money”: {
“amount”: 0,
“currency”: “GBP”
},
“service_charge_money”: {
“amount”: 0,
“currency”: “GBP”
}
},
“created_at”: “2022-08-24T12:40:04.003Z”,
“updated_at”: “2022-08-24T12:40:04.003Z”,
“state”: “DRAFT”,
“version”: 1,
“total_money”: {
“amount”: 29500,
“currency”: “GBP”
},
“total_tax_money”: {
“amount”: 0,
“currency”: “GBP”
},
“total_discount_money”: {
“amount”: 0,
“currency”: “GBP”
},
“total_tip_money”: {
“amount”: 0,
“currency”: “GBP”
},
“total_service_charge_money”: {
“amount”: 0,
“currency”: “GBP”
},
“net_amount_due_money”: {
“amount”: 29500,
“currency”: “GBP”
}
}
]
}
}

:wave: This is the expected behavior. All payments links are initially created with an order in a DRAFT state. :slightly_smiling_face:

As it doesn’t honour the state passed into the CreatePaymentLink endpoint, then I have to immediately call the UpdateOrder endpoint to move the state to OPEN. This is less than ideal.

I’m sure this worked ok about 2 or 3 versions ago.

Paul

Wondering why you need to have the order in an OPEN state prior to it being paid for? :slightly_smiling_face:

My process is as follows:

  • create a payment link with an order
  • send link to customer
  • allow the customer to use either the link or pay on the website

For them to pay on the website, the order needs to be in an OPEN state.

Therefore, I want to create the order with the payment link in an OPEN state - so that I don’t then need to set the order to OPEN in another API call.

(There is a side issue that I’m working around - It is that the CreatePaymentLink endpoint doesn’t accept an OrderID for an existing order - so I need to create the order via the CreatePaymentLink endpoint so that I can use the same Order when making a web Card payment.)

Does this help?

Paul

We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team. :slightly_smiling_face:

1 Like