-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep consistent customer across purchases
- Loading branch information
1 parent
a7d01ca
commit 35b2cf1
Showing
4 changed files
with
120 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spree | ||
module CreditCardDecorator | ||
def cc_type=(type) | ||
# See https://stripe.com/docs/api/cards/object#card_object-brand, | ||
# active_merchant/lib/active_merchant/billing/credit_card.rb, | ||
# and active_merchant/lib/active_merchant/billing/credit_card_methods.rb | ||
# (And see also the Solidus docs at core/app/models/spree/credit_card.rb, | ||
# which indicate that Solidus uses ActiveMerchant conventions by default.) | ||
self[:cc_type] = case type | ||
when 'American Express' | ||
'american_express' | ||
when 'Diners Club' | ||
'diners_club' | ||
when 'Discover' | ||
'discover' | ||
when 'JCB' | ||
'jcb' | ||
when 'MasterCard' | ||
'master' | ||
when 'UnionPay' | ||
'unionpay' | ||
when 'Visa' | ||
'visa' | ||
when 'Unknown' | ||
super('') | ||
else | ||
super(type) | ||
end | ||
end | ||
|
||
::Spree::CreditCard.prepend(self) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters