Class: SpreeAdyen::Webhooks::CreditCardPresenter
- Inherits:
-
Object
- Object
- SpreeAdyen::Webhooks::CreditCardPresenter
- Defined in:
- app/presenters/spree_adyen/webhooks/credit_card_presenter.rb
Constant Summary collapse
- CREDIT_CARD_BRANDS =
{ 'mc' => 'master', 'mc_googlepay' => 'master', 'maestro' => 'master', 'maestro_googlepay' => 'master', 'amex' => 'american_express', 'amex_googlepay' => 'american_express', 'cartebancaire' => 'cartes_bancaires', 'diners' => 'diners_club', 'eftpos_australia' => 'eftpos_au', 'googlepay' => 'google_pay', 'visa_googlepay' => 'visa' }.freeze
Instance Method Summary collapse
-
#initialize(event) ⇒ CreditCardPresenter
constructor
A new instance of CreditCardPresenter.
- #to_h ⇒ Object
Constructor Details
#initialize(event) ⇒ CreditCardPresenter
Returns a new instance of CreditCardPresenter.
18 19 20 |
# File 'app/presenters/spree_adyen/webhooks/credit_card_presenter.rb', line 18 def initialize(event) @event = event end |
Instance Method Details
#to_h ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/presenters/spree_adyen/webhooks/credit_card_presenter.rb', line 22 def to_h { name: event.card_details['type'], month: event.card_details['expiryDate']&.split('/')&.first, year: event.card_details['expiryDate']&.split('/')&.last, cc_type: CREDIT_CARD_BRANDS.fetch(payment_method_reference, payment_method_reference), last_digits: event.card_details['cardSummary'], gateway_customer_profile_id: nil, gateway_payment_profile_id: event.stored_payment_method_id } end |