Class: Workarea::Payment::Authorize::GiftCard
- Inherits:
-
Object
- Object
- Workarea::Payment::Authorize::GiftCard
- Includes:
- OperationImplementation
- Defined in:
- app/models/workarea/payment/authorize/gift_card.rb
Instance Method Summary collapse
Instance Method Details
#cancel! ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/workarea/payment/authorize/gift_card.rb', line 26 def cancel! return unless transaction.success? Payment::GiftCard.refund(tender.number, transaction.amount.cents) transaction.cancellation = ActiveMerchant::Billing::Response.new( true, I18n.t( 'workarea.gift_cards.credit', amount: transaction.amount, number: tender.number ) ) end |
#complete! ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/workarea/payment/authorize/gift_card.rb', line 7 def complete! Payment::GiftCard.purchase(tender.number, transaction.amount.cents) transaction.response = ActiveMerchant::Billing::Response.new( true, I18n.t( 'workarea.gift_cards.debit', amount: transaction.amount, number: tender.number ) ) rescue Payment::InsufficientFunds transaction.response = ActiveMerchant::Billing::Response.new( false, I18n.t('workarea.gift_cards.insufficient_funds') ) end |