Class: Workarea::Payment::Refund::StoreCredit

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

Instance Method Summary collapse

Methods included from OperationImplementation

#initialize, #validate_reference!

Instance Method Details

#cancel!Object



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

def cancel!
  return unless transaction.success?

  profile.purchase_on_store_credit(transaction.amount.cents)
  transaction.cancellation = ActiveMerchant::Billing::Response.new(
    true,
    I18n.t(
      'workarea.payment.store_credit_debit',
      amount: transaction.amount,
      email: profile.email
    )
  )
end

#complete!Object



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

def complete!
  profile.reload_store_credit(transaction.amount.cents)
  transaction.response = ActiveMerchant::Billing::Response.new(
    true,
    I18n.t(
      'workarea.payment.store_credit_credit',
      amount: transaction.amount,
      email: profile.email
    )
  )
end