class Pay::Stripe::Customer
def save_payment_method(payment_method, default:)
def save_payment_method(payment_method, default:) pay_payment_method = payment_methods.where(processor_id: payment_method.id).first_or_initialize attributes = Pay::Stripe::PaymentMethod.extract_attributes(payment_method).merge(default: default) # Ignore the payment method if it's already in the database payment_methods.where.not(id: pay_payment_method.id).update_all(default: false) if default pay_payment_method.update!(attributes) # Reload the Rails association reload_default_payment_method pay_payment_method end