I’m working on a custom membership page. I’d like to display the available tiers and let the user pick one. (No, I don’t want to use the built-in Portal page. I need more customization.)
I’m good on displaying tiers, and if I have a user without an account, the link I’m creating work. (They look like this: <a class="c-btn Monthly" href="javascript:void(0)" data-portal="signup/{{id}}/monthly">
)
But I’m having trouble figuring out how to let a user who already has a subscription choose a different plan. That link doesn’t work - I get a popup that says: “A subscription exists for this Member.”
This is doable using Portal - there’s no problem there to edit a subscription. I opened dev tools and I can see that when I go through the process of changing a subscription (as a user), I first see a request to /members/api/session . I can do that with fetch, and I get back a long string, no errors. Then I see a PUT request to https://demo.spectralwebservices.com/members/api/subscriptions/sub_1MikcPHXfUM0q3dxMn6EYpkV/ , where that last part is the subscription I’m trying to change to. The body for that PUT looks like: {"cancel_at_period_end":false,"identity":"<bigstringfromaminuteago>","tierId":"640615f0ce7981003de31937","cadence":"month"}
Trying to exactly replicate that PUT request, I’m getting a 400 error.
Can anyone nudge me in the right direction? What am I missing?