8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/models/workarea/payment/purchase/affirm.rb', line 8
def complete!
auth_response = gateway.authorize(tender.checkout_token, tender.payment.id)
return auth_error(auth_response.body) unless auth_response.success?
response = gateway.capture(auth_response.body['id'], transaction.amount, tender.payment.id)
if response.success?
transaction.response = ActiveMerchant::Billing::Response.new(
true,
I18n.t(
'workarea.affirm.purchase',
amount: transaction.amount
),
auth_response.body
)
else
transaction.response = ActiveMerchant::Billing::Response.new(
false,
I18n.t('workarea.affirm.purchase_capture_failure'),
response.body
)
end
end
|