Class: Workarea::Payment::StoreCreditCard
- Inherits:
-
Object
- Object
- Workarea::Payment::StoreCreditCard
- Includes:
- CreditCardOperation
- Defined in:
- app/models/workarea/payment/store_credit_card.rb
Instance Method Summary collapse
-
#initialize(credit_card, options = {}) ⇒ StoreCreditCard
constructor
A new instance of StoreCreditCard.
-
#perform! ⇒ Boolean
Reaches out to the credit card gateway to store a new credit card.
-
#save! ⇒ Boolean
Reaches out to the credit card gateway to store a new credit card.
Methods included from CreditCardOperation
#gateway, #handle_active_merchant_errors
Constructor Details
#initialize(credit_card, options = {}) ⇒ StoreCreditCard
Returns a new instance of StoreCreditCard.
6 7 8 9 |
# File 'app/models/workarea/payment/store_credit_card.rb', line 6 def initialize(credit_card, = {}) @credit_card = credit_card @options = end |
Instance Method Details
#perform! ⇒ Boolean
Reaches out to the credit card gateway to store a new credit card
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/workarea/payment/store_credit_card.rb', line 14 def perform! return true if @credit_card.token.present? response = handle_active_merchant_errors do gateway.store(@credit_card.to_active_merchant) end @credit_card.token = response.params['billingid'] response.success? end |
#save! ⇒ Boolean
Reaches out to the credit card gateway to store a new credit card
29 30 31 |
# File 'app/models/workarea/payment/store_credit_card.rb', line 29 def save! perform! && @credit_card.save end |