app/models/spree/gateway/stripe_gateway.rb in spree_gateway-3.2.0.beta vs app/models/spree/gateway/stripe_gateway.rb in spree_gateway-3.2.0

- old
+ new

@@ -4,10 +4,17 @@ preference :publishable_key, :string CARD_TYPE_MAPPING = { 'American Express' => 'american_express', 'Diners Club' => 'diners_club', + 'Discover' => 'discover', + 'JCB' => 'jcb', + 'Laser' => 'laser', + 'Maestro' => 'maestro', + 'MasterCard' => 'master', + 'Solo' => 'solo', + 'Switch' => 'switch', 'Visa' => 'visa' } def method_type 'stripe' @@ -59,11 +66,15 @@ creditcard = source end response = provider.store(creditcard, options) if response.success? + cc_type=payment.source.cc_type + response_cc_type = response.params['sources']['data'].first['brand'] + cc_type = CARD_TYPE_MAPPING[response_cc_type] if CARD_TYPE_MAPPING.include?(response_cc_type) + payment.source.update_attributes!({ - cc_type: payment.source.cc_type, # side-effect of update_source! + cc_type: 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