Class: Gateway::KomojuCreditCard
- Inherits:
-
KomojuGateway
- Object
- KomojuGateway
- Gateway::KomojuCreditCard
- Defined in:
- app/models/spree/gateway/komoju_credit_card.rb
Instance Method Summary collapse
- #auto_capture? ⇒ Boolean
-
#create_profile(payment) ⇒ Object
enable either token-based profiles or customer-based profiles.
- #payment_profiles_supported? ⇒ Boolean
- #purchase(money, source, options) ⇒ Object
Instance Method Details
#auto_capture? ⇒ Boolean
3 4 5 |
# File 'app/models/spree/gateway/komoju_credit_card.rb', line 3 def auto_capture? true end |
#create_profile(payment) ⇒ Object
enable either token-based profiles or customer-based profiles
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/spree/gateway/komoju_credit_card.rb', line 18 def create_profile(payment) return unless payment.source.number.present? if SpreeKomoju.enable_customer_profiles profile_id_name = :gateway_customer_profile_id = { email: payment.order.email, customer_profile: true } else profile_id_name = :gateway_payment_profile_id = {} end profile_id = payment.source.public_send(profile_id_name) if profile_id.nil? response = provider.store(payment.source.to_active_merchant, ) if response.success? payment.source.update_attributes!(profile_id_name => response.params['id']) else payment.send(:gateway_error, response.) end end end |
#payment_profiles_supported? ⇒ Boolean
41 42 43 |
# File 'app/models/spree/gateway/komoju_credit_card.rb', line 41 def payment_profiles_supported? true end |
#purchase(money, source, options) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/models/spree/gateway/komoju_credit_card.rb', line 7 def purchase(money, source, ) = () if [:currency] == "JPY" if profile_id = source.gateway_payment_profile_id || source.gateway_customer_profile_id payment_details = profile_id else payment_details = source.to_active_merchant end super(money - [:tax], payment_details, ) end |