ruby-on-railsstripe-payments

Retrieve Customer's default and active card from Stripe


I am trying to retrieve the default and active card of a Customer. (Also keep in mind that with the coding I have, the customer can always have one card which means if there is a way around it it can help).

Some months ago I used this code segment which was working fine. It seems Stripe made some updates and I can't get it to work now.

current_user.stripe_card_id = customer.active_card.id

The error I get is

undefined method `active_card' for #Stripe::Customer

If you need any more information please let me know.

edit: customer.default_card.id does not work either.


Solution

  • I used customer.methods to check the methods and found this (default_source):

    current_user.stripe_card_id = customer.default_source
    

    Works fine now. Thank you