Class: Gateway::StripeGateway
- Inherits:
-
Gateway
- Object
- Gateway
- Gateway::StripeGateway
- Defined in:
- app/models/spree/gateway/stripe_gateway.rb
Constant Summary collapse
- CARD_TYPE_MAPPING =
{ 'American Express' => 'american_express', 'Diners Club' => 'diners_club', 'Visa' => 'visa' }
Instance Method Summary collapse
- #authorize(money, creditcard, gateway_options) ⇒ Object
- #cancel(response_code) ⇒ Object
- #capture(money, response_code, gateway_options) ⇒ Object
- #create_profile(payment) ⇒ Object
- #credit(money, creditcard, response_code, gateway_options) ⇒ Object
- #method_type ⇒ Object
- #partial_name ⇒ Object
- #payment_profiles_supported? ⇒ Boolean
- #provider_class ⇒ Object
- #purchase(money, creditcard, gateway_options) ⇒ Object
- #void(response_code, creditcard, gateway_options) ⇒ Object
Instance Method Details
#authorize(money, creditcard, gateway_options) ⇒ Object
34 35 36 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 34 def (money, creditcard, ) provider.(*(money, creditcard, )) end |
#cancel(response_code) ⇒ Object
50 51 52 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 50 def cancel(response_code) provider.void(response_code, {}) end |
#capture(money, response_code, gateway_options) ⇒ Object
38 39 40 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 38 def capture(money, response_code, ) provider.capture(money, response_code, ) end |
#create_profile(payment) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 54 def create_profile(payment) return unless payment.source.gateway_customer_profile_id.nil? = { email: payment.order.email, login: preferred_secret_key, }.merge! address_for(payment) source = update_source!(payment.source) if source.number.blank? && source.gateway_payment_profile_id.present? creditcard = source.gateway_payment_profile_id else creditcard = source end response = provider.store(creditcard, ) if response.success? payment.source.update_attributes!({ cc_type: payment.source.cc_type, # side-effect of update_source! 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 |
#credit(money, creditcard, response_code, gateway_options) ⇒ Object
42 43 44 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 42 def credit(money, creditcard, response_code, ) provider.refund(money, response_code, {}) end |
#method_type ⇒ Object
13 14 15 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 13 def method_type 'stripe' end |
#partial_name ⇒ Object
17 18 19 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 17 def partial_name 'stripe' end |
#payment_profiles_supported? ⇒ Boolean
26 27 28 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 26 def payment_profiles_supported? true end |
#provider_class ⇒ Object
22 23 24 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 22 def provider_class ActiveMerchant::Billing::StripeGateway end |
#purchase(money, creditcard, gateway_options) ⇒ Object
30 31 32 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 30 def purchase(money, creditcard, ) provider.purchase(*(money, creditcard, )) end |
#void(response_code, creditcard, gateway_options) ⇒ Object
46 47 48 |
# File 'app/models/spree/gateway/stripe_gateway.rb', line 46 def void(response_code, creditcard, ) provider.void(response_code, {}) end |