Module: RailsTrade::PaymentMethod::StripeMethod
- Extended by:
- ActiveSupport::Concern
- Included in:
- StripeMethod
- Defined in:
- app/models/rails_trade/payment_method/stripe_method.rb
Instance Method Summary collapse
- #customer_info(customer) ⇒ Object
- #detective_save ⇒ Object
- #remove ⇒ Object
- #retrieve ⇒ Object
- #update_extra ⇒ Object
Instance Method Details
#customer_info(customer) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/rails_trade/payment_method/stripe_method.rb', line 13 def customer_info(customer) card = customer.sources.data[0] return {} unless card { description: customer.description, address_zip: card.address_zip, address_zip_check: card.address_zip_check, brand: card.brand, country: card.country, cvc_check: card.cvc_check, exp_month: card.exp_month, exp_year: card.exp_year, fingerprint: card.fingerprint, funding: card.funding, last4: card.last4 } end |
#detective_save ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/models/rails_trade/payment_method/stripe_method.rb', line 40 def detective_save begin customer = Stripe::Customer.create(description: "buyer_id: #{payment_references.map { |i| i.buyer_id }}", source: self.token) self.account_num = customer.id self.extra = self.customer_info(customer) rescue Stripe::StripeError => ex self.errors.add :base, ex. end self.verified = true if self.errors.blank? self.save else false end end |
#remove ⇒ Object
35 36 37 38 |
# File 'app/models/rails_trade/payment_method/stripe_method.rb', line 35 def remove cu = Stripe::Customer.retrieve account_num cu.delete end |
#retrieve ⇒ Object
8 9 10 11 |
# File 'app/models/rails_trade/payment_method/stripe_method.rb', line 8 def retrieve customer = Stripe::Customer.retrieve account_num customer_info(customer) end |
#update_extra ⇒ Object
31 32 33 |
# File 'app/models/rails_trade/payment_method/stripe_method.rb', line 31 def update_extra self.update extra: retrieve.to_h end |