Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paymentez: Add inquire by transaction_id #4729

Merged
merged 1 commit into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
* Credorax: Set default ECI values for token transactions [sainterman] #4693
* CyberSourceRest: Add ACH Support [edgarv09] #4722
* CybersourceREST: Add capture request [heavyblade] #4726
* Paymentez: Add transaction inquire request [aenand] #4729

== Version 1.127.0 (September 20th, 2022)
* BraintreeBlue: Add venmo profile_id [molbrown] #4512
Expand Down
24 changes: 18 additions & 6 deletions lib/active_merchant/billing/gateways/paymentez.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ def unstore(identification, options = {})
commit_card('delete', post)
end

def inquire(authorization, options = {})
commit_transaction('inquire', authorization)
end

def supports_scrubbing?
true
end
Expand Down Expand Up @@ -232,12 +236,20 @@ def parse(body)
end

def commit_raw(object, action, parameters)
url = "#{(test? ? test_url : live_url)}#{object}/#{action}"

begin
raw_response = ssl_post(url, post_data(parameters), headers)
rescue ResponseError => e
raw_response = e.response.body
if action == 'inquire'
url = "#{(test? ? test_url : live_url)}#{object}/#{parameters}"
begin
raw_response = ssl_get(url, headers)
rescue ResponseError => e
raw_response = e.response.body
end
else
url = "#{(test? ? test_url : live_url)}#{object}/#{action}"
begin
raw_response = ssl_post(url, post_data(parameters), headers)
rescue ResponseError => e
raw_response = e.response.body
end
end

begin
Expand Down
9 changes: 9 additions & 0 deletions test/remote/gateways/remote_paymentez_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,15 @@ def test_unstore_with_elo
assert_success response
end

def test_successful_inquire_with_transaction_id
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response

gateway_transaction_id = response.authorization
response = @gateway.inquire(gateway_transaction_id, @options)
assert_success response
end

def test_invalid_login
gateway = PaymentezGateway.new(application_code: '9z8y7w6x', app_key: '1a2b3c4d')

Expand Down
12 changes: 12 additions & 0 deletions test/unit/gateways/paymentez_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,18 @@ def test_scrub
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end

def test_successful_inquire_with_transaction_id
response = stub_comms(@gateway, :ssl_get) do
@gateway.inquire('CI-635')
end.check_request do |method, _endpoint, _data, _headers|
assert_match('https://ccapi-stg.paymentez.com/v2/transaction/CI-635', method)
end.respond_with(successful_authorize_response)

assert_success response
assert_equal 'CI-635', response.authorization
assert response.test?
end

private

def pre_scrubbed
Expand Down