I use payment link api (/v2/online-checkout/payment-links) to provide a quick pay for subscription plan ( doc link: Subscription Plan Checkout), But I don’t know how can I cancel it if my customer don’t want to continue. But according the doc (doc link: Pause, Resume, or Cancel Subscriptions), I should use cancel api (/v2/subscriptions/{subscription_id}/cancel). When I complete my payment, I can see the webhook log about payment and order, but no information about subscription. So how can I cancel it without subscription id.
The subscription_plan_id (N55LK67IT5CRUSIXPACZ5C3E) is created by catalog api (/v2/catalog/object) and can be searched by retrieve api(/v2/catalog/object/{object_id}). Can not be used as subscription id.
My payment link api response:
{
"payment_link": {
"id": "VRTG35CNNPEJUEOX",
"version": 1,
"order_id": "voB5Hs4WL9iCFHWBsXte51zpZd4F",
"checkout_options": {
"subscription_plan_id": "N55LK67IT5CRUSIXPACZ5C3E"
},
"url": "https://sandbox.square.link/u/bs8hKlow",
"long_url": "https://connect.squareupsandbox.com/v2/online-checkout/sandbox-testing-panel/MLSYP1V7VEZYY/VRTG35CNNPEJUEOX",
"created_at": "2025-02-05T08:44:31Z"
},
"related_resources": {
"orders": [
{
"id": "voB5Hs4WL9iCFHWBsXte51zpZd4F",
"location_id": "L3P65NPGFEZVP",
"source": {
"name": "Sandbox for sq0idp-mfW2Mc6WUxEdLbxntQEu1A"
},
"line_items": [
{
"uid": "2KuFHVS4PV33fVjWCW0vqB",
"name": "SuperBillTest",
"quantity": "1",
"item_type": "ITEM",
"base_price_money": {
"amount": 14900,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 14900,
"currency": "USD"
},
"gross_sales_money": {
"amount": 14900,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 14900,
"currency": "USD"
},
"total_service_charge_money": {
"amount": 0,
"currency": "USD"
}
}
],
"fulfillments": [
{
"uid": "fa0koKiK8mYAvDvRGby0z",
"type": "DIGITAL",
"state": "PROPOSED"
}
],
"net_amounts": {
"total_money": {
"amount": 14900,
"currency": "USD"
},
"tax_money": {
"amount": 0,
"currency": "USD"
},
"discount_money": {
"amount": 0,
"currency": "USD"
},
"tip_money": {
"amount": 0,
"currency": "USD"
},
"service_charge_money": {
"amount": 0,
"currency": "USD"
}
},
"created_at": "2025-02-05T08:44:31.164Z",
"updated_at": "2025-02-05T08:44:31.164Z",
"state": "DRAFT",
"version": 1,
"total_money": {
"amount": 14900,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_tip_money": {
"amount": 0,
"currency": "USD"
},
"total_service_charge_money": {
"amount": 0,
"currency": "USD"
},
"net_amount_due_money": {
"amount": 14900,
"currency": "USD"
}
}
],
"subscription_plans": [
{
"type": "SUBSCRIPTION_PLAN_VARIATION",
"id": "N55LK67IT5CRUSIXPACZ5C3E",
"updated_at": "2025-01-24T09:38:09.82Z",
"created_at": "2025-01-24T09:38:09.861Z",
"version": 1737711489820,
"is_deleted": false,
"present_at_all_locations": true,
"subscription_plan_variation_data": {
"name": "SuperBill",
"phases": [
{
"uid": "N5B5HZSIBMD2PZ3INTHNFOZ7",
"cadence": "MONTHLY",
"periods": 1,
"ordinal": 0,
"pricing": {
"type": "STATIC",
"price": {
"amount": 14900,
"currency": "USD"
},
"price_money": {
"amount": 14900,
"currency": "USD"
}
}
}
],
"subscription_plan_id": "FAOWMOD4TZC4EYPJDNXUJM5B"
}
}
]
}
}
My retrieve catalog object api response:
{
"object": {
"type": "SUBSCRIPTION_PLAN_VARIATION",
"id": "N55LK67IT5CRUSIXPACZ5C3E",
"updated_at": "2025-01-24T09:38:09.82Z",
"created_at": "2025-01-24T09:38:09.861Z",
"version": 1737711489820,
"is_deleted": false,
"present_at_all_locations": true,
"subscription_plan_variation_data": {
"name": "SuperBill",
"phases": [
{
"uid": "N5B5HZSIBMD2PZ3INTHNFOZ7",
"cadence": "MONTHLY",
"periods": 1,
"ordinal": 0,
"pricing": {
"type": "STATIC",
"price": {
"amount": 14900,
"currency": "USD"
},
"price_money": {
"amount": 14900,
"currency": "USD"
}
}
}
],
"subscription_plan_id": "FAOWMOD4TZC4EYPJDNXUJM5B"
}
}
}