piesync / billbo

Easy to use billing service for Stripe with VAT support
MIT License
73 stars 3 forks source link

Provide fallback for new SCA payment method subscriptions #93

Closed masqita closed 5 years ago

masqita commented 5 years ago

With the new 3D Secure handling, Stripe no longer supports the source attribute but instead uses payment_methods. Old subscriptions still have the source attribute, so we should use that if it's available. However, when source is nil, the card can be found on payment_method_details.card instead.

Example (stripped irrelevant properties):

{
  "id": "ch_1FI9TT2nHroS7mLX2bL8PqLr",
  "object": "charge",
  "amount": 10800,
  "amount_refunded": 0,
  "customer": "cus_Fnkz9iV6vuk6pK",
  "description": "Invoice 1DA65605-0001",
  "invoice": "in_1FI9TH2nHroS7mLX9lOVBuBp",
  "paid": true,
  "payment_intent": "pi_1FI9TH2nHroS7mLXe644rjVe",
  "payment_method": "pm_1FI9TC2nHroS7mLXqvtO81iz",
  "payment_method_details": {"card":{"brand":"visa","checks":{"address_line1_check":null,"address_postal_code_check":null,"cvc_check":"pass"},"country":"IE","exp_month":2,"exp_year":2022,"fingerprint":"c8eaPdOX9yQnp8fq","funding":"credit","last4":"3220","three_d_secure":{"authenticated":true,"succeeded":true,"version":"2.1.0"},"wallet":null},"type":"card"},
  "source": null,
}

I also synced the ruby version specified by the Gemfile with .ruby-version.

I can't get tests etc to run locally but it should be fine.