Sha256: 25057519d8c660c0523fadeb3df142527e80ca9d44123d4c051b3da120b7b41f
Contents?: true
Size: 1.59 KB
Versions: 23
Compression:
Stored size: 1.59 KB
Contents
module Spree class Gateway::PinGateway < Gateway preference :api_key, :string preference :currency, :string, :default => 'AUD' def provider_class ActiveMerchant::Billing::PinGateway end def purchase(money, creditcard, options = {}) super(money, creditcard.try(:gateway_customer_profile_id) || creditcard.try(:gateway_payment_profile_id) || creditcard, options) end def create_profile(payment) if payment.source.gateway_customer_profile_id.nil? response = provider.store(payment.source, options_for_payment(payment)) if response.success? payment.source.update_attributes!(:gateway_customer_profile_id => response.authorization) cc = response.params['response']['card'] payment.source.update_attributes!(:gateway_payment_profile_id => cc['token']) if cc else payment.send(:gateway_error, response.message) end end end # Pin does not appear to support authorizing transactions yet def auto_capture? true end def payment_profiles_supported? true end private def options_for_payment(p) o = Hash.new o[:email] = p.order.email if p.order.bill_address bill_addr = p.order.bill_address o[:billing_address] = { address1: bill_addr.address1, city: bill_addr.city, state: bill_addr.state ? bill_addr.state.name : bill_addr.state_name, country: bill_addr.country.iso3, zip: bill_addr.zipcode } end return o end end end
Version data entries
23 entries across 23 versions & 2 rubygems