I am attempting to create a form where the user can update their subscription card details (with Stripe Elements).
From looking at the Charge plugin's source code, I believe the endpoint I need is charge/updateSubscription
.
As with checkout I am creating an opts hidden input in my twig template like so:
{{
craft.charge.setPaymentOptions({
planAmount: currentSubscription.planAmount,
planInterval: currentSubscription.planInterval,
planIntervalCount: currentSubscription.planIntervalCount
})
}}
And then making a POST request with Javascript to the endpoint:
getStripeToken(cardToken => {
post({
params: {
action: 'charge/updateSubscription',
opts,
cardToken,
subscriptionId
},
then: response => console.log(response)
url: '/'
})
})
Quite simply, this doesn't work. I receive a {success: true}
response, but the Stripe card has not been updated.
Does anybody what I'm doing wrong, or even if this is possible?