Class: Workarea::Payment::Refund::GiftCard

Inherits:
Object
  • Object
show all
Includes:
OperationImplementation
Defined in:
app/models/workarea/payment/refund/gift_card.rb

Instance Method Summary collapse

Instance Method Details

#cancel!Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/workarea/payment/refund/gift_card.rb', line 19

def cancel!
  return unless transaction.success?

  Payment::GiftCard.purchase(tender.number, transaction.amount.cents)
  transaction.cancellation = ActiveMerchant::Billing::Response.new(
    true,
    I18n.t(
      'workarea.gift_cards.debit',
      amount: transaction.amount,
      number: tender.number
    )
  )
end

#complete!Object



7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/workarea/payment/refund/gift_card.rb', line 7

def complete!
  Payment::GiftCard.refund(tender.number, transaction.amount.cents)
  transaction.response = ActiveMerchant::Billing::Response.new(
    true,
    I18n.t(
      'workarea.gift_cards.credit',
      amount: transaction.amount,
      number: tender.number
    )
  )
end