Class: Workarea::Payment::Authorize::Paypal

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

Instance Method Summary collapse

Instance Method Details

#cancel!Object



19
20
21
22
23
24
25
26
27
# File 'app/models/workarea/payment/authorize/paypal.rb', line 19

def cancel!
  return unless transaction.success?

  transaction.cancellation =
    Workarea::Paypal.gateway.refund(
      transaction.response.params['id'],
      amount: transaction.amount
    )
end

#complete!Object



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

def complete!
  response = Workarea::Paypal.gateway.capture(tender.paypal_id)

  if response.success? && response.params['status'] == 'PENDING'
    transaction.action = 'authorize'
  else
    transaction.action = 'purchase'
  end

  transaction.response = response
end