Class: Workarea::Payment::Purchase::GiftCard

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

Instance Method Summary collapse

Methods included from GiftCardOperation

#gateway

Instance Method Details

#cancel!Object



17
18
19
20
21
22
23
24
25
26
# File 'app/models/workarea/payment/purchase/gift_card.rb', line 17

def cancel!
  return unless transaction.success?

  response = gateway.refund(transaction.amount.cents, tender)

  transaction.cancellation = ActiveMerchant::Billing::Response.new(
    response.success?,
    response.message
  )
end

#complete!Object



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

def complete!
  response = gateway.purchase(transaction.amount.cents, tender)

  transaction.response = ActiveMerchant::Billing::Response.new(
    response.success?,
    response.message
  )
end