Skip to content

Commit

Permalink
Fix for endpoint names not working
Browse files Browse the repository at this point in the history
  • Loading branch information
incarnate committed Jan 5, 2016
1 parent 74e2e0a commit 578a18f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes will be documented in this file

## 1.0.1

- Fix for endpoint names ('production' & 'sandbox') not working

## 1.0.0

- First release
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ api_key = 'Rapid API Key'
password = 'Rapid API Password'
endpoint = 'sandbox'

client = RapidSDK::RapidClient.new(api_key, password, endpoint)
client = EwayRapid::RapidClient.new(api_key, password, endpoint)

transaction = EwayRapid::Models::Transaction.new
transaction.customer = EwayRapid::Models::Customer.new
Expand Down
36 changes: 18 additions & 18 deletions lib/eway_rapid/rapid_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,39 @@ def create_transaction(payment_method, transaction)
begin
case payment_method
when Enums::PaymentMethod::DIRECT
url = @rapid_endpoint + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX

request = Message::TransactionProcess::TransDirectPaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransDirectPaymentMsgProcess.send_request(url, @api_key, @password, request)
Message::TransactionProcess::TransDirectPaymentMsgProcess.make_result(response)
when Enums::PaymentMethod::RESPONSIVE_SHARED
url = @rapid_endpoint + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX
url = @web_url + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX

request = Message::TransactionProcess::TransResponsiveSharedMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransResponsiveSharedMsgProcess.send_request(url, @api_key, @password, request)
Message::TransactionProcess::TransResponsiveSharedMsgProcess.make_result(response)
when Enums::PaymentMethod::TRANSPARENT_REDIRECT
url = @rapid_endpoint + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX
url = @web_url + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX

request = Message::TransactionProcess::TransTransparentRedirectMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransTransparentRedirectMsgProcess.send_request(url, @api_key, @password, request)
Message::TransactionProcess::TransTransparentRedirectMsgProcess.make_result(response)
when Enums::PaymentMethod::WALLET
if transaction.capture
url = @rapid_endpoint + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX

request = Message::TransactionProcess::TransDirectPaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransDirectPaymentMsgProcess.send_request(url, @api_key, @password, request)
Message::TransactionProcess::TransDirectPaymentMsgProcess.make_result(response)
else
url = @rapid_endpoint + Constants::CAPTURE_PAYMENT_METHOD
url = @web_url + Constants::CAPTURE_PAYMENT_METHOD

request = Message::TransactionProcess::CapturePaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::CapturePaymentMsgProcess.send_request(url, @api_key, @password, request)
Message::TransactionProcess::CapturePaymentMsgProcess.make_result(response)
end
when Enums::PaymentMethod::AUTHORISATION
url = @rapid_endpoint + Constants::CAPTURE_PAYMENT_METHOD
url = @web_url + Constants::CAPTURE_PAYMENT_METHOD

request = Message::TransactionProcess::CapturePaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::CapturePaymentMsgProcess.send_request(url, @api_key, @password, request)
Expand Down Expand Up @@ -140,7 +140,7 @@ def refund(refund)
end

begin
url = @rapid_endpoint + Constants::TRANSACTION_METHOD
url = @web_url + Constants::TRANSACTION_METHOD

request = Message::RefundProcess::RefundMsgProcess.create_request(refund)
response = Message::RefundProcess::RefundMsgProcess.send_request(url, @api_key, @password, request)
Expand All @@ -160,7 +160,7 @@ def cancel(refund)
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), RefundResponse)
end
begin
url = @rapid_endpoint + Constants::CANCEL_AUTHORISATION_METHOD
url = @web_url + Constants::CANCEL_AUTHORISATION_METHOD

request = Message::RefundProcess::CancelAuthorisationMsgProcess.create_request(refund)
response = Message::RefundProcess::CancelAuthorisationMsgProcess.send_request(url, @api_key, @password, request)
Expand All @@ -184,19 +184,19 @@ def create_customer(payment_method, customer)
begin
case payment_method
when Enums::PaymentMethod::DIRECT
url = @rapid_endpoint + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX

request = Message::CustomerProcess::CustDirectPaymentMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustDirectPaymentMsgProcess.send_request(url, @api_key, @password, request)
Message::CustomerProcess::CustDirectPaymentMsgProcess.make_result(response)
when Enums::PaymentMethod::RESPONSIVE_SHARED
url = @rapid_endpoint + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX
url = @web_url + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX

request = Message::CustomerProcess::CustResponsiveSharedMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustResponsiveSharedMsgProcess.send_request(url, @api_key, @password, request)
Message::CustomerProcess::CustResponsiveSharedMsgProcess.make_result(response)
when Enums::PaymentMethod::TRANSPARENT_REDIRECT
url = @rapid_endpoint + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX
url = @web_url + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX

request = Message::CustomerProcess::CustTransparentRedirectMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustTransparentRedirectMsgProcess.send_request(url, @api_key, @password, request)
Expand All @@ -222,18 +222,18 @@ def update_customer(payment_method, customer)
begin
case payment_method
when Enums::PaymentMethod::DIRECT
url = @rapid_endpoint + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustDirectUpdateMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustDirectUpdateMsgProcess.send_request(url, @api_key, @password, request)
Message::CustomerProcess::CustDirectUpdateMsgProcess.make_result(response)
when Enums::PaymentMethod::RESPONSIVE_SHARED
url = @rapid_endpoint + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX
url = @web_url + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX

request = Message::CustomerProcess::CustResponsiveUpdateMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustResponsiveUpdateMsgProcess.send_request(url, @api_key, @password, request)
Message::CustomerProcess::CustResponsiveUpdateMsgProcess.make_result(response)
when Enums::PaymentMethod::TRANSPARENT_REDIRECT
url = @rapid_endpoint + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX
url = @web_url + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX

request = Message::CustomerProcess::CustTransparentUpdateMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustTransparentUpdateMsgProcess.send_request(url, @api_key, @password, request)
Expand All @@ -258,7 +258,7 @@ def query_customer(token_customer_id)
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), QueryCustomerResponse)
end
begin
url = @rapid_endpoint + Constants::DIRECT_CUSTOMER_SEARCH_METHOD + Constants::JSON_SUFFIX
url = @web_url + Constants::DIRECT_CUSTOMER_SEARCH_METHOD + Constants::JSON_SUFFIX
url = URI.encode(url)

request = Message::CustomerProcess::QueryCustomerMsgProcess.create_request(token_customer_id.to_s)
Expand Down Expand Up @@ -306,9 +306,9 @@ def query_transaction_with_path(request, request_path)
end
begin
if request.nil? || request == ''
url = @rapid_endpoint + request_path + '/' + '0'
url = @web_url + request_path + '/' + '0'
else
url = @rapid_endpoint + request_path + '/' + request
url = @web_url + request_path + '/' + request
end
url = URI.encode(url)

Expand Down Expand Up @@ -358,7 +358,7 @@ def validate_api_param
@list_error.clear
end
set_valid(true)
@logger.info "Initiate client [#{@rapid_endpoint}] successful!" if @logger
@logger.info "Initiate client using [#{@web_url}] successful!" if @logger
rescue => e
@logger.error "Error setting Rapid endpoint #{e.backtrace.inspect}" if @logger
set_valid(false)
Expand Down
2 changes: 1 addition & 1 deletion lib/eway_rapid/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module EwayRapid
VERSION = '1.0.0'
VERSION = '1.0.1'
end
2 changes: 1 addition & 1 deletion test/eway_rapid/integration/customer/customer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_create_customer_direct_but_wrong_endpoint
invalid_endpoint = 'https://api.sandbox.ewaypayments.com/'
client = EwayRapid::RapidClient.new(IntegrationTest::API_KEY, 'ABCXYZ', invalid_endpoint)
fake_web_url = 'https://hhhhhhh.ggg/'
client.instance_variable_set('@rapid_endpoint', fake_web_url)
client.instance_variable_set('@web_url', fake_web_url)

card_details = EwayRapid::InputModelFactory.create_card_detail('12', '25')
@customer.card_details = card_details
Expand Down

0 comments on commit 578a18f

Please sign in to comment.