How can I cancel subscription which was created by checkout api

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"
    }
  }
}

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

https://developer.squareup.com/docs/app-marketplace/requirements/subscriptions-api

Additional Documentation

Retrieve Payments
Cancel or Delete Invoices
Refund Payments

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

When a buyer pays for a subscription plan through a checkout page, Square creates a subscription for the buyer. The subscription ID is not returned in the API response, but you can retrieve it by calling the SearchSubscriptions endpoint of the Subscriptions API.

You can use the customer ID to search for the subscription. The customer ID is the same one you used when creating the checkout page for the subscription plan. Once you have the subscription ID, you can use it to cancel the subscription by calling the CancelSubscription endpoint.

Remember, the subscription ID is different from the subscription plan ID. The subscription plan ID is used to generate the checkout page for the subscription plan, while the subscription ID represents the buyer’s subscription to the plan.

This answer was reviewed by @Bryan-Square.

But I don’t find customer information in the payment or order webhook, and I don’t find any subscription webhook api log. Though I open it.
payment update log:

{
  "merchant_id": "MLSYP1V7VEZYY",
  "type": "payment.updated",
  "event_id": "79f68e98-3042-36f2-9f42-18f32f9494a9",
  "created_at": "2025-02-06T02:25:32.591Z",
  "data": {
    "type": "payment",
    "id": "HB9r2cnTGROv4CfGvucsDOzPtZdZY",
    "object": {
      "payment": {
        "amount_money": {
          "amount": 14900,
          "currency": "USD"
        },
        "application_details": {
          "application_id": "sandbox-sq0idb-lky4CaPAWmDnHY3YtYxINg",
          "square_product": "ECOMMERCE_API"
        },
        "capabilities": [
          "EDIT_AMOUNT_UP",
          "EDIT_AMOUNT_DOWN",
          "EDIT_TIP_AMOUNT_UP",
          "EDIT_TIP_AMOUNT_DOWN"
        ],
        "created_at": "2025-02-06T02:25:31.134Z",
        "external_details": {
          "source": "Developer Control Panel",
          "type": "CARD"
        },
        "id": "HB9r2cnTGROv4CfGvucsDOzPtZdZY",
        "location_id": "L3P65NPGFEZVP",
        "order_id": "BB5fSw99nXu4p8X6dkYwIxZ3gb4F",
        "receipt_number": "HB9r",
        "receipt_url": "https://squareupsandbox.com/receipt/preview/HB9r2cnTGROv4CfGvucsDOzPtZdZY",
        "source_type": "EXTERNAL",
        "status": "COMPLETED",
        "total_money": {
          "amount": 14900,
          "currency": "USD"
        },
        "updated_at": "2025-02-06T02:25:31.235Z",
        "version": 1
      }
    }
  }
}

order update log:

{
  "merchant_id": "MLSYP1V7VEZYY",
  "type": "order.updated",
  "event_id": "1c5fd587-7539-3bd0-b157-7e3365bba696",
  "created_at": "2025-02-06T02:25:35Z",
  "data": {
    "type": "order_updated",
    "id": "BB5fSw99nXu4p8X6dkYwIxZ3gb4F",
    "object": {
      "order_updated": {
        "created_at": "2025-02-06T02:24:23.749Z",
        "location_id": "L3P65NPGFEZVP",
        "order_id": "BB5fSw99nXu4p8X6dkYwIxZ3gb4F",
        "state": "OPEN",
        "updated_at": "2025-02-06T02:25:33.000Z",
        "version": 7
      }
    }
  }
}

Also, when I call /v2/subscriptions/search, I can not find any new subscription appear.

If this was with Sandbox it currently won’t return a subscription from the Checkout API. This is a limitation of sandbox at this time. 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. :slight_smile: