Sasha
Sasha

Reputation: 301

What's the difference between stripe default_source and default_payment_method?

I'm using the following code to make a card default:

 if ($form_state['input']['default'] == TRUE) {
      // Set the current card as default.
      try {
        $stripe->customers->update(
          $customer['id'],
          ['invoice_settings' => ['default_payment_method' => $card['id']]]
        );
      } catch (\Stripe\Exception\InvalidRequestException $e) {
        watchdog('store', $e->getMessage(), array(), WATCHDOG_ERROR);
      }
    }

because per documentation on https://stripe.com/docs/api/payment_methods/attach and https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method, it's advised to use the default_payment_method parameter.

And it works fine marking properly the $customer['invoice_settings']['default_payment_method'] array value.

However, when I add a new card via Stripe UI, then $customer['default_source'] gets silently marked for it.

So I wonder what's the difference between them and which one is preferable to use? If the default_source is a outdated legacy parameter, then why Stripe's own UI keeps using it?

UPDATE of January 10, 2023: In addition to the accepted answer, here is the update from Stripe support on the subject matter:

enter image description here

Upvotes: 5

Views: 1465

Answers (1)

yuting
yuting

Reputation: 1694

invoice_settings.default_payment_method is the recommended parameter to be set for setting up the default payment method of a customer. default_source is the legacy parameter.

Upvotes: 5

Related Questions