INTERNAL_SERVER_ERROR when trying to Create Subscriptions

Hey,

Can’t work out what’s going on here, seems to trigger when the plan_variation_id is populated, beforehand would get the API errors you’d expect for missing data etc.

This is happening in both the API Explorer for me and the PHP SDK.

Sandboxed App ID is: sandbox-sq0idb-CZ8JPWAB_B_AdmGxs17ogA

This is what I’m trying in the explorer:

$price_override_money = new \Square\Models\Money();
$price_override_money->setAmount(14000);
$price_override_money->setCurrency(‘GBP’);

$body = new \Square\Models\CreateSubscriptionRequest(‘L7QKV9PNWZ30Y’, ‘MCN2MQM2H121Z5B6PDGX0QZDD4’);
$body->setIdempotencyKey(‘1cb148cb-e695-4a57-9ece-0176665979eb’);
$body->setPlanVariationId(‘COIOR4VK4G3DQJKAGDZBPEZE’);
$body->setStartDate(‘2023-07-12’);
$body->setTaxPercentage(‘0’);
$body->setPriceOverrideMoney($price_override_money);
$body->setTimezone(‘Europe/London’);

$api_response = $client->getSubscriptionsApi()->createSubscription($body);

if ($api_response->isSuccess()) {
$result = $api_response->getResult();
} else {
$errors = $api_response->getErrors();
}

This is the result:

{
“errors”: [
{
“code”: “INTERNAL_SERVER_ERROR”,
“detail”: “An internal error has occurred, and the API was unable to service your request.”,
“category”: “API_ERROR”
}
]
}

So, tried this in production with the relevant details for that enviroment and it worked, so not sure why Sandbox isn’t playing ball?

Not particularly keen on fooling about in production as you can imagine!

I took a look at the logs and it looks like your trying to pass an item variation instead of a subscription plan. We still shouldn’t be throwing a 5xx but you’ll need to create a subscription plan and variation first then create the subscription. :slightly_smiling_face:

Perhaps it’s worth sorting out that 5xx error so it’s more helpful.

So, I wanted to create some plans in the Dashboard for testing, rather than the API, how on earth do I even create this mystical “plan_variation_id” … I have a Subscription plan with the ID:

GWN5HIBEDAVH57TOQ2C4EXHG

So, where are variations in the dashboard? I only see items.

EDIT:

Looking at the live account for my client, the design of the Subscriptions > Plans interface is completely different to my Sandbox, with columns for price, frequency, trial period etc.

None of this thing makes sense, man I wish they used Stripe, navigating the Dashboard is painful. :frowning:

The sandbox Dashboard should match production. What’s your application ID so we can take a look?

As for creating the subscription plan and plan_variation_id you can reference our Subscription Plans and Variations. :slightly_smiling_face: