Can't delete a subscription plan or Disable subscription plan

Using the API Explorer and I can’t delete any subscription plan. I found a prior Question where square says they can’t be deleted… they can only be disabled via UpsertCatalogObject by setting present_at_all_locations to false. So I use the API Explorer to try to UpsertCatalogObject the Subscription Plan Variation and set the present to false, but that doesn’t work either. I fill out the API Explorer form with the minimum required information: Id, type, and present at all locations flag:
{
“errors”: [
{
“category”: “INVALID_REQUEST_ERROR”,
“code”: “INVALID_VALUE”,
“detail”: “Object of type SUBSCRIPTION_PLAN_VARIATION missing subscription_plan_variation_data field: ID="xxxxxxxxxx".”,
“field”: “subscription_plan_variation_data”
}
]
}

So I fill in the subscription plan variation info, and I get this:
{
“errors”: [
{
“category”: “INVALID_REQUEST_ERROR”,
“code”: “ARRAY_EMPTY”,
“detail”: “Repeated field must have at least one value”,
“field”: “object.subscription_plan_variation_data.phases”
}
]
}

So I fill in the phases info, and I get this:
{
“errors”: [
{
“category”: “INVALID_REQUEST_ERROR”,
“code”: “INVALID_VALUE”,
“detail”: “On existing plan xxxxxxxxxx, phases should not be added, removed, or replaced.”,
“field”: “phases”
}
]
}

This is what the final request looked like:
curl https://connect.squareup.com/v2/catalog/object
-X POST
-H ‘Square-Version: 2024-01-18’
-H 'Authorization: Bearer xxxxxxxxxx
-H ‘Content-Type: application/json’
-d ‘{
“idempotency_key”: “xxxxxxxxxx”,
“object”: {
“id”: “xxxxxxxxxx”,
“type”: “SUBSCRIPTION_PLAN_VARIATION”,
“present_at_all_locations”: false,
“subscription_plan_variation_data”: {
“name”: “Monthly Fee”,
“phases”: [
{
“cadence”: “MONTHLY”
}
]
}
}
}’

What am I doing wrong? Or is there no clean up of subscription plans?

Hi @armando :wave:

Welcome to the forums!

I would like to take a look at all the API calls to see what might be happening. Could I get your application id so I can take a look at your API Logs?
And could I get the subscription plan id in question?

{
“type”: “SUBSCRIPTION_PLAN_VARIATION”,
“id”: “HOYWNO7JXCHPUI2F3P2EFHSO”,
“updated_at”: “2023-04-20T20:19:33.531Z”,
“created_at”: “2023-01-31T10:30:37.52Z”,
“version”: 1682021973531,
“is_deleted”: false,
“present_at_all_locations”: true,
“subscription_plan_variation_data”: {
“name”: “Monthly Software Fee”,
“phases”: [
{
“uid”: “IJ3NYJZDHFVNAZIKYXL22TQX”,
“cadence”: “MONTHLY”,
“periods”: 0,
“ordinal”: 0,
“pricing”: {
“type”: “STATIC”,
“price”: {
“amount”: 154,
“currency”: “USD”
},
“price_money”: {
“amount”: 154,
“currency”: “USD”
}
}
}
],
“subscription_plan_id”: “O4RLOHEGEKUCWFUDX4G4STVX”
}
}

@armando
Thanks for the Subscription Plan & Variation ids.
Could I also get your application id from Developer Dashboard, so I can see all your recent API calls in API Logs?

Do you mind trying to share your application id again.
And DO NO share your access token.
Here’s an example of what the syntax should look like: sq0idp-AbC1d2T7jJ1PLpevSDFHVw where it started with sq0idp

sq0idp-tDKk6aFzGV8l9iSaOD8K2w

@armando Thanks for the application id.

The Catalog API upsert is a bit picky, and unique amongst the Square APIs since it’s an upsert.

Try starting with a RetrieveCatalogObject API call first to HOYWNO7JXCHPUI2F3P2EFHSO, then take that response object, and use it as the base for your UpsertCatalogObject API call. Remove any read only fields noted in the Technical Reference, like the updated_at time stamp. Then change want you’d like to change, setting present_at_all_locations to false like you noted was recommended, per our docs.

Let me know if that works.

{
“errors”: [
{
“category”: “INVALID_REQUEST_ERROR”,
“code”: “INVALID_VALUE”,
“detail”: “Invalid object: Invalid Object with Id: IJ3NYJZDHFVNAZIKYXL22TQX\n[merchant_token=ME0Y4MT4BBDBC] Attribute of type subscription_periods has value 0 less than min value 1.”
}
]
}

with this request:
curl https://connect.squareup.com/v2/catalog/object
-X POST
-H ‘Square-Version: 2024-01-18’
-H ‘Content-Type: application/json’
-d ‘{
“idempotency_key”: “c575c0f2-a4a6-40cf-89e8-3ec9b828692a”,
“object”: {
“id”: “HOYWNO7JXCHPUI2F3P2EFHSO”,
“type”: “SUBSCRIPTION_PLAN_VARIATION”,
“present_at_all_locations”: false,
“subscription_plan_variation_data”: {
“name”: “Monthly Software Fee”,
“phases”: [
{
“cadence”: “MONTHLY”,
“ordinal”: 0,
“uid”: “IJ3NYJZDHFVNAZIKYXL22TQX”,
“pricing”: {
“price_money”: {
“amount”: 154,
“currency”: “USD”
},
“type”: “STATIC”
},
“periods”: 0
}
],
“subscription_plan_id”: “O4RLOHEGEKUCWFUDX4G4STVX”
},
“is_deleted”: false,
“version”: 1682021973531
}
}’

Thanks for the request bodies.

Took a look at your API calls, compared the RetrieveCatalogObject against the UpsertCatalogObject.

I believe at times, you did not include the uid, which is needed to know that you are talking about the existing phase and not trying to create a new one and delete the old one (since you did not id the old one via the uid. Quirks of an upsert endpoint.

And later, you did include the uid, but then, I believe you are missing the full pricing object, where it seems you are missing the price object.

Try again: call retrieve, then just removing the two timestamps, updated_at and created_at, I believe everything else can be included in your update upsert, and just change present_at_all_locations to true.

Let’s see if that works.

I’m trying to disable a subscription plan via the API Explorer, but I used postman because the API Explorer doesn’t let me add a “price” node. Here is my request:
{
“idempotency_key”: “7fc753e3-8fe2-4a8c-9a16-9f2cc03e1d84”,
“object”: {
“type”: “SUBSCRIPTION_PLAN_VARIATION”,
“id”: “HOYWNO7JXCHPUI2F3P2EFHSO”,
“version”: 1682021973531,
“is_deleted”: false,
“present_at_all_locations”: false,
“subscription_plan_variation_data”: {
“name”: “Monthly Software Fee”,
“phases”: [
{
“uid”: “IJ3NYJZDHFVNAZIKYXL22TQX”,
“cadence”: “MONTHLY”,
“periods”: 0,
“ordinal”: 0,
“pricing”: {
“type”: “STATIC”,
“price”: {
“amount”: 154,
“currency”: “USD”
},
“price_money”: {
“amount”: 154,
“currency”: “USD”
}
}
}
],
“subscription_plan_id”: “O4RLOHEGEKUCWFUDX4G4STVX”
}
}
}

Here is the response:
{“errors”:[{“category”:“INVALID_REQUEST_ERROR”,“code”:“INVALID_VALUE”,“detail”:“Invalid object: Invalid Object with Id: IJ3NYJZDHFVNAZIKYXL22TQX\n[merchant_token=ME0Y4MT4BBDBC] Attribute of type subscription_periods has value 0 less than min value 1.”}]}

Thanks for trying that. Let me try and reproduce your subscription on my on account later today, and I’ll get back to you on next steps.

@armando , I was able to make the update.

I’m not too sure how that variation has only one phase with a periods of 0, but that’s a problem.

Try another UpsertCatalogObject, copying a fresh RetrieveCatalogObject, and without the read only fields like the timestamps, then remove just the “periods”: 0.
If that works, then get another fresh copy from a RetrieveCatalogObject, and change present_at_all_locations to false.