I am working on an app where users can subscribe to gain acces to content.
I would like to make subscription plans and variations using the dashboard, as it is more user friendly for my colleagues. I have been playing around with the options in Sandbox and believe have a good grasp of the api but unfortunately I get an INTERNAL_SERVER_ERROR in the last step of creating a subscription.
The current flow is as follows. First tokenise a card with it verification code (verifyBuyer) using the Web SDK. These codes are send to my backend server which will check if the logged in user already is in the Square Directory or not. If it is, it will retrieve the customer_id, if not it will add the customer to the Square Directory and with the corresponding customer_id assign the card to the customer. So far so good.
Now I make a subscription using the sandbox dashboard NVJWSYCOTPRPIJI4WKRYQCYD with a plan variation S2PWD7LBU5QMRRVTSSJVLZQQ. When creating the subscription, the API throws error that I have to include the phases, so OK, I include the phases as obtained when I retrieve the subscription:
"phases": [ { "uid": "LPXPKJUOTW2AGQ7IOMO7JBMC", "cadence": "MONTHLY", "ordinal": 0, "pricing": { "type": "RELATIVE" } } ]
But now I get the error:
errors: [ { code: 'INTERNAL_SERVER_ERROR', detail: 'An internal error has occurred, and the API was unable to service your request.', category: 'API_ERROR' } ]
Example of the data body when creating the subscription:
{ idempotency_key: '9601acf8f4452c84b0dd46e183587079cab986ed', location_id: 'LVVPXS39HD364', plan_variation_id: 'S2PWD7LBU5QMRRVTSSJVLZQQ', customer_id: 'Z8WXR2JVJX61Z28HE8FKWWF21R', card_id: 'ccof:CA4SEDFhF_AvNyipFJnN4DK9SO4oAg', phases: [ { ordinal: 0, order_template_id: 'LPXPKJUOTW2AGQ7IOMO7JBMC' } ], source: { name: 'NxtDay' } }
When I try with a subscription plan as in the Coffee subscription Square example using only the API, it works. I guess it has something to do the STATIC/RELATIVE stuff, as this examples uses STATIC. But you get a ‘legacy’ plan and more over you cannot make such item in the dashboard.
SQUARE_UP_LOCATION=LVVPXS39HD364
Would be cool is someone had similar problem or could help me look at what I am doing wrong.