Charge: Update subscription card details 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 =&gt; {
  post({
    params: {
      action: 'charge/updateSubscription',
      opts,
      cardToken,
      subscriptionId
    },
    then: response =&gt; 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?
In the end I worked out the card is related to a customer, not a subscription.

I couldn't see any public endpoint to update a customer's card, so I added this method in charge/controllers/ChargeController.php (not ideal to update the plugin directly I know):

public function actionUpdateCard()
{
  $this-&gt;requirePostRequest();
  $customer = craft()-&gt;charge_customer-&gt;find();
  $cardToken = craft()-&gt;request-&gt;getRequiredPost('cardToken');

  if ($customer-&gt;addCard($cardToken)) {
    $this-&gt;returnJson(['success' =&gt; true]);
  } else {
    $this-&gt;returnJson(['success' =&gt; false]);
  }
}


and then can make requests to the charge/updateCard endpoint:

getStripeToken(cardToken =&gt; {
  post({
    params: {
      action: 'charge/updateCard',
      cardToken
    },
    then: ({ success }) =&gt; console.log(`Card updated: ${success}`)
    url: '/'
  })
})