Search code examples
subscriptionbraintree

Can we update payment method for braintree subscription?


I'm new to braintree. Can we update payment method to an existing subscription. Is their any way to update payment method. So user can change their cards for subscription ? From braintree documentation will this work ?

$result = $gateway->subscription()->update('old_subscription_id', [ 'id' => 'old_subscription_id', 'paymentMethodToken' => 'new_payment_method_token' ]);


Solution

  • Full disclosure, I work at Braintree. If you have any additional questions, contact Support

    You can update an existing subscription to use any other payment method that is stored in your Vault. You can do this with an existing payment method, or by creating a new payment method with a paymentMethod()->create() API request.

    With that said, the request you provided may work, but I recommend not including the id parameter, as that is reserved for setting a new subscription ID. The subscription ID you are hoping to edit will be placed in the first argument, as you've included in your code. You can simplify the request to look something more like this:

    $result = $gateway->subscription()->update('old_subscription_id', [
        'paymentMethodToken' => 'new_payment_method_token'
    ]);