Skip to content

Commit

Permalink
OpenPay: Update url endpoint
Browse files Browse the repository at this point in the history
Updated endpoint from `.mx` to `.co` along with slight change in error message for the declined transactions as returned by the gateway. Added unit test to verify that the correct url is being hit for the gateway.

SER-304

Unit:
5334 tests, 76512 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Rubocop:
749 files inspected, no offenses detected

Remote:
24 tests, 80 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95.8333% passed
  • Loading branch information
ajawadmirza committed Sep 14, 2022
1 parent 4a2b3da commit 794c375
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/active_merchant/billing/gateways/openpay.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class OpenpayGateway < Gateway
self.live_url = 'https://api.openpay.mx/v1/'
self.test_url = 'https://sandbox-api.openpay.mx/v1/'
self.live_url = 'https://api.openpay.co/v1/'
self.test_url = 'https://sandbox-api.openpay.co/v1/'

self.supported_countries = %w(CO MX)
self.supported_cardtypes = %i[visa master american_express carnet]
Expand Down
4 changes: 2 additions & 2 deletions test/remote/gateways/remote_openpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_successful_purchase_with_email
def test_unsuccessful_purchase
assert response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
assert_equal 'The card was declined', response.message
assert_equal 'The card was declined by the bank', response.message
end

def test_successful_refund
Expand Down Expand Up @@ -69,7 +69,7 @@ def test_successful_authorize_with_email
def test_unsuccessful_authorize
assert response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
assert_equal 'The card was declined', response.message
assert_equal 'The card was declined by the bank', response.message
end

def test_successful_capture
Expand Down
8 changes: 8 additions & 0 deletions test/unit/gateways/openpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ def setup
}
end

def test_endpoint_for_the_gateway
stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |_method, endpoint, _data, _headers|
assert endpoint.include?('.co')
end.respond_with(successful_purchase_response)
end

def test_successful_purchase
@gateway.expects(:ssl_request).returns(successful_purchase_response)

Expand Down

0 comments on commit 794c375

Please sign in to comment.