Skip to content

Commit

Permalink
Payeezy change method on capture
Browse files Browse the repository at this point in the history
For Apple Pay transactions, the value for `method` is set to `3DS`, but
when executing a `capture`, this value should be changed to
`credit_card`.

This differs from other use cases where the value provided on auth
transactions should be the same one given for capture.

Unit: 45 tests, 206 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

46 tests, 184 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
naashton committed Jan 19, 2023
1 parent ac06be7 commit d46885f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/active_merchant/billing/gateways/payeezy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def authorize(amount, payment_method, options = {})
def capture(amount, authorization, options = {})
params = { transaction_type: 'capture' }

add_authorization_info(params, authorization)
add_authorization_info(params, authorization, options)
add_amount(params, amount, options)
add_soft_descriptors(params, options)

Expand Down Expand Up @@ -155,6 +155,7 @@ def amount_from_authorization(authorization)
def add_authorization_info(params, authorization, options = {})
transaction_id, transaction_tag, method, = authorization.split('|')
params[:method] = method == 'token' ? 'credit_card' : method
params[:method] = 'credit_card' if method == '3DS'

if options[:reversal_id]
params[:reversal_id] = options[:reversal_id]
Expand Down
8 changes: 8 additions & 0 deletions test/remote/gateways/remote_payeezy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ def test_successful_purchase_with_apple_pay
assert_success response
end

def test_successful_authorize_and_capture_with_apple_pay
assert auth = @gateway.authorize(@amount, @apple_pay_card, @options)
assert_success auth

assert capture = @gateway.capture(@amount, auth.authorization)
assert_success capture
end

def test_successful_purchase_with_echeck
options = @options.merge({ customer_id_type: '1', customer_id_number: '1', client_email: 'test@example.com' })
assert response = @gateway.purchase(@amount, @check, options)
Expand Down

0 comments on commit d46885f

Please sign in to comment.