Skip to content

Instantly share code, notes, and snippets.

@blakewest
blakewest / gist:ed22e52731f33f53f1f3
Last active September 22, 2015 21:02 — forked from khempenius/gist:55c6c1ca82163edb4bb2
Import Customers from Stripe
# Used when a practice's patients have been transferred to Stripe from
# another payment processing platform and we need to associate their Stripe
# customers with their Hint patients. This is done by matching credit card name
# to patient name or to email, or to address, or hint hid.
def get_customers(practice, params = nil)
response = Stripe::Customer.all(params, practice.stripe_token)
response.data.each do |customer|
stripe_customer_id = customer.id
source_with_name = customer.sources.data.find { |source| source.try(:name) }