Class: Workarea::Payment::Authorize::Afterpay

Inherits:
Object
  • Object
show all
Includes:
CreditCardOperation, OperationImplementation, Workarea::Payment::AfterpayPaymentGateway
Defined in:
app/models/workarea/payment/authorize/afterpay.rb

Instance Method Summary collapse

Methods included from Workarea::Payment::AfterpayPaymentGateway

#gateway

Instance Method Details

#cancel!Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/models/workarea/payment/authorize/afterpay.rb', line 29

def cancel!
  return unless transaction.success?

  payment_id = transaction.response.params["id"]
  response = gateway.void(payment_id)

  transaction.cancellation = ActiveMerchant::Billing::Response.new(
    true,
      I18n.t('workarea.afterpay.void'),
      response.body
    )
end

#complete!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/workarea/payment/authorize/afterpay.rb', line 9

def complete!
  response = authorize
  if response.success? && response.body['status'] == 'APPROVED'
    transaction.response = ActiveMerchant::Billing::Response.new(
      true,
      I18n.t(
        'workarea.afterpay.authorize',
        amount: transaction.amount
      ),
      response.body
    )
  else
     transaction.response = ActiveMerchant::Billing::Response.new(
       false,
      I18n.t('workarea.afterpay.capture_failure'),
      response.body
    )
  end
end