Class: Workarea::Checkout::CreditCardParams
- Inherits:
-
Object
- Object
- Workarea::Checkout::CreditCardParams
- Defined in:
- app/models/workarea/checkout/credit_card_params.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(params) ⇒ CreditCardParams
constructor
A new instance of CreditCardParams.
-
#new? ⇒ Boolean
Whether these params represent setting a new card as payment on the order.
-
#new_card ⇒ Hash
New credit card params.
-
#number ⇒ String
The new credit card number for these params.
-
#saved? ⇒ Boolean
Do these params represent using a saved credit card as payment?.
-
#saved_card_id ⇒ String
The saved card id for these params.
Constructor Details
#initialize(params) ⇒ CreditCardParams
Returns a new instance of CreditCardParams.
5 6 7 8 |
# File 'app/models/workarea/checkout/credit_card_params.rb', line 5 def initialize(params) @params = params @card_params = params.fetch(:credit_card, {}) end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'app/models/workarea/checkout/credit_card_params.rb', line 3 def params @params end |
Instance Method Details
#new? ⇒ Boolean
Whether these params represent setting a new card as payment on the order.
15 16 17 |
# File 'app/models/workarea/checkout/credit_card_params.rb', line 15 def new? params[:payment] == 'new_card' end |
#new_card ⇒ Hash
New credit card params.
23 24 25 |
# File 'app/models/workarea/checkout/credit_card_params.rb', line 23 def new_card @card_params end |
#number ⇒ String
The new credit card number for these params
31 32 33 |
# File 'app/models/workarea/checkout/credit_card_params.rb', line 31 def number @card_params[:number] end |
#saved? ⇒ Boolean
Do these params represent using a saved credit card as payment?
39 40 41 |
# File 'app/models/workarea/checkout/credit_card_params.rb', line 39 def saved? saved_card_id.present? end |
#saved_card_id ⇒ String
The saved card id for these params. Returns the ‘:payment` param if it is a legal BSON::ObjectId
48 49 50 51 52 |
# File 'app/models/workarea/checkout/credit_card_params.rb', line 48 def saved_card_id if BSON::ObjectId.legal?(params[:payment]) params[:payment] end end |