Hello,
I have tried doing as you suggested, but I am still getting an Internal Server Error.
I first create a subscription plan variation as follows:
await catalogApi.upsertCatalogObject({
idempotencyKey: crypto.randomBytes(12).toString('hex'),
object: {
id: '#temp',
type: 'SUBSCRIPTION_PLAN',
subscriptionPlanData: {
name: 'Phased Monthly Subscription Plan With Variations',
subscriptionPlanVariations: [
{
id: '#temp2',
type: 'SUBSCRIPTION_PLAN_VARIATION',
subscriptionPlanVariationData: {
subscriptionPlanId: '#temp',
name: 'Phased Monthly Subscription Main Variation',
phases: [
{
ordinal: BigInt(0),
cadence: 'MONTHLY',
pricing: {
type: 'STATIC',
priceMoney: {
amount: 1000n,
currency: 'USD'
}
}
}
]
}
}
]
}
}
})
The resulting subscription plan variation id is “T3CMYUTFIC5F4ZAEWBL5DX2U”. Then I use this id to create a subscription for a test customer using a test card Id. This time I removed the phases from the request as you suggested.
const subscriptionResult = await subscriptionsApi.createSubscription({
idempotencyKey: crypto.randomBytes(12).toString('hex'),
locationId: 'LQYAKTAMA4MDG',
customerId: 'CM0280KCRRYP4DY2ZKK429WTNW',
cardId: 'ccof:customer-card-id-ok',
planVariationId: 'T3CMYUTFIC5F4ZAEWBL5DX2U'
})
The result is the error below (full output)
ApiError: Response status code was not ok: 500.
{
request: {
method: 'POST',
url: 'https://connect.squareupsandbox.com/v2/subscriptions',
headers: {
'Content-Type': 'application/json',
authorization: '***',
'user-agent': 'Square-TypeScript-SDK/39.1.1 (2024-12-18) node/20.17.0 (linux) ',
'Square-Version': '2024-12-18'
},
body: {
type: 'text',
content: '{"idempotency_key":"59216198ff789749d2433569","location_id":"LQYAKTAMA4MDG","plan_variation_id":"T3CMYUTFIC5F4ZAEWBL5DX2U","customer_id":"CM0280KCRRYP4DY2ZKK429WTNW","card_id":"ccof:customer-card-id-ok"}'
}
},
statusCode: 500,
headers: {
date: 'Fri, 27 Dec 2024 11:13:43 GMT',
'content-type': 'application/json',
'content-length': '164',
connection: 'keep-alive',
'cf-ray': '8f88e2008806d51e-CDG',
'cf-cache-status': 'DYNAMIC',
'strict-transport-security': 'max-age=631152000; includeSubDomains; preload',
'frame-options': 'DENY',
'square-version': '2024-12-18',
'squareup--connect--v2--common--versionmetadata-bin': 'CgoyMDI0LTEyLTE4',
'x-content-type-options': 'nosniff',
'x-envoy-decorator-operation': '/v2/subscriptions/**',
'x-frame-options': 'DENY',
'x-sq-dc': 'aws',
'x-sq-region': 'us-west-2',
'x-xss-protection': '1; mode=block',
'set-cookie': '__cf_bm=VJpa6z8XgJp_Q_SPVeNn.g_4jBGjJA1wjWPBjXkvy2s-1735298023-1.0.1.1-uMBavNzXQTJe04KnqY2tGniXbDX7AG9atuaGv_DMsIOgauRtZjhlZbVCN_oYzDZQ0M48WYs7lXw13Shm5Ezf.Q; path=/; expires=Fri, 27-Dec-24 11:43:43 GMT; domain=.squareupsandbox.com; HttpOnly; Secure; SameSite=None',
vary: 'Accept-Encoding',
server: 'cloudflare'
},
body: '{"errors": [{"code": "INTERNAL_SERVER_ERROR","detail": "An internal error has occurred, and the API was unable to service your request.","category": "API_ERROR"}]}\n',
result: [Object: null prototype] {
errors: [
[Object: null prototype] {
code: 'INTERNAL_SERVER_ERROR',
detail: 'An internal error has occurred, and the API was unable to service your request.',
category: 'API_ERROR'
}
]
},
errors: [
[Object: null prototype] {
code: 'INTERNAL_SERVER_ERROR',
detail: 'An internal error has occurred, and the API was unable to service your request.',
category: 'API_ERROR'
}
]
}