lib/pay/stripe/billable.rb
# Used by webhooks when the customer or source changes
Used by webhooks when the customer or source changes
Used by webhooks when the customer or source changes
def sync_card_from_stripe
        stripe_cust = stripe_customer
        default_payment_method_id = stripe_cust.invoice_settings.default_payment_method
        if default_payment_method_id.present?
          payment_method = ::Stripe::PaymentMethod.retrieve(default_payment_method_id)
          update(
            card_type: payment_method.card.brand,
            card_last4: payment_method.card.last4,
            card_exp_month: payment_method.card.exp_month,
            card_exp_year: payment_method.card.exp_year
          )
        else
          update(card_type: nil, card_last4: nil)
        end
      end
def sync_card_from_stripe stripe_cust = stripe_customer default_payment_method_id = stripe_cust . invoice_settings . default_payment_method if default_payment_method_id . present? payment_method = :: Stripe :: PaymentMethod . retrieve ( default_payment_method_id ) update ( card_type : payment_method . card . brand , card_last4 : payment_method . card . last4 , card_exp_month : payment_method . card . exp_month , card_exp_year : payment_method . card . exp_year ) else update ( card_type : nil , card_last4 : nil ) end end
Used by webhooks when the customer or source changes
Used by webhooks when the customer or source changes
# Customer has no default payment method