Class: Gateway::StripeAchGateway
- Inherits:
-
StripeGateway
- Object
- StripeGateway
- Gateway::StripeAchGateway
- Defined in:
- app/models/spree/gateway/stripe_ach_gateway.rb
Instance Method Summary collapse
- #available_for_order?(order) ⇒ Boolean
- #create_profile(payment) ⇒ Object
- #method_type ⇒ Object
- #payment_source_class ⇒ Object
- #supports?(_source) ⇒ Boolean
- #verify(source, **gateway_options) ⇒ Object
Instance Method Details
#available_for_order?(order) ⇒ Boolean
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/spree/gateway/stripe_ach_gateway.rb', line 48 def available_for_order?(order) # Stripe ACH payments are supported only for US customers # Therefore we need to check order's addresses return unless order.ship_address_id && order.bill_address_id return unless order.ship_address && order.bill_address_id usa_id = ::Spree::Country.find_by(iso: 'US')&.id return false unless usa_id order.ship_address.country_id == usa_id && order.bill_address.country_id == usa_id end |
#create_profile(payment) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/spree/gateway/stripe_ach_gateway.rb', line 16 def create_profile(payment) return unless payment.source&.gateway_customer_profile_id.nil? = { email: payment.order.user&.email || payment.order.email, login: preferred_secret_key, }.merge! address_for(payment) source = payment.source bank_account = if source.gateway_payment_profile_id.present? source.gateway_payment_profile_id else source end response = provider.store(bank_account, ) if response.success? payment.source.update!({ gateway_customer_profile_id: response.params['id'], gateway_payment_profile_id: response.params['default_source'] || response.params['default_card'] }) else payment.send(:gateway_error, response.) end end |
#method_type ⇒ Object
4 5 6 |
# File 'app/models/spree/gateway/stripe_ach_gateway.rb', line 4 def method_type 'stripe_ach' end |
#payment_source_class ⇒ Object
8 9 10 |
# File 'app/models/spree/gateway/stripe_ach_gateway.rb', line 8 def payment_source_class Check end |
#supports?(_source) ⇒ Boolean
44 45 46 |
# File 'app/models/spree/gateway/stripe_ach_gateway.rb', line 44 def supports?(_source) true end |
#verify(source, **gateway_options) ⇒ Object
12 13 14 |
# File 'app/models/spree/gateway/stripe_ach_gateway.rb', line 12 def verify(source, **) provider.verify(source, ) end |