Hey @arthur,
Thanks for the update. I have relayed this information to the engineering team who is currently investigating the issue. Someone will get back to you soon. Please don't hesitate to reach out to us if you have other questions and someone will be happy to help!
Hey @arthur,
Thanks for your patience! The engineering team is currently investigating the issue. I've followed up with them and hopefully I'll be able to provide you with an update soon. You can reach out to us at any time if you have questions. I'd be happy to help!
Hey @arthur,
Here's the information that we currently have for Java sample code for the Foreign Exchange Rates API. I know that you are inquiring about the PHP sample code but our engineering team is still investigating your issue. I'm thinking that this Java sample code might come in handy for you. Please see the .zip file attachment.
You can run the test to verify your VDP app credentials allow connectivity to the FX api via running the following class using junit, after decompressing the zip and editing the file with your VDP app credentials.
File:
foreign_exchange_rates_api/src/test/java/com/visa/developer/sample/foreign_exchange_rates_api/api/FxApiTest.java
Edits to lines 57 – 66 would be enough to properly query the foreign exchange rate api:
// Configure HTTP basic authorization: basicAuth
apiClient.setUsername("YOUR USERNAME");
apiClient.setPassword("YOUR PASSWORD");
apiClient.setKeystorePath("YOUR KEYSTORE PATH");
apiClient.setKeystorePassword("YOUR KEYSTORE PASSWORD");
apiClient.setPrivateKeyPassword("YOUR PRIVATEKEY PASSWORD");
// To set proxy uncomment the below lines
// apiClient.setProxyHostName("proxy.address@example.com");
// apiClient.setProxyPortNumber(0000);
You only need to uncomment and edit the proxy lines if your current connection requires a proxy to send external queries.
Once your app credentials have been updated, you can use maven “build project” or “mvn clean install” to import the required maven dependencies into your development environment and run the FxApiTest.java file as a junit test. You will be able to see a proper query response, assuming your credentials allow for proper connectivity.
Hi Diana,
You are given instruction for java to follow.
Based on the instruction given we have implemented in php there is no positive solutions.
we have tried both with and without host/port. there were two different error.
Error Messages :
Without host/port
-- 400 -- Exception when calling FxApi->postforeignexchangelookup: [400] Error connecting to the API (https://sandbox.api.visa.com/forexrates/v1/foreignexchangerates)
With host/port
Exception when calling FxApi->postforeignexchangelookup: API call to https://sandbox.api.visa.com/forexrates/v1/foreignexchangerates failed: Recv failure: Connection reset by peer
we have attached screenshot of our code and error, Please check the attachment for your reference.
Please help us to fix the issues.
Thanks
Arthur
Hi Team,
Is there any direct api to get the currency conversion like this.
https://www.xe.com/currencyconverter/convert/?Amount=1&From=MYR&To=INR
If you have any api with username and password and we will do it using CURL function in PHP
Thanks,
Arthur.
Hey @arthur,
The 400 is indicative of a malformed request, but it might not be due to your string/json request.
The engineering team is determining what the involved issue is. It might well still be a data mapping issue.
However, considering the results of the your attempts, you should not need to use the proxy when querying the foreign exchange api.
Your results for “With host/port” are suggesting your proxy is abandoning the attempted connection to the api.
Considering the non-proxy option is receiving the 400 from the request, a logical assessment from the foreign exchange api that the sent data can’t resolve into a proper response, than it’s expected that your app/project actually has proper connectivity to the “/forexrates/v1/foreignexchangerates” endpoint. However, this is an assumption, as we can not unequivocally determine that the connectivity to the api is fully functional without CRID verification.
So, if your connectivity is in place, which is an assumption, we’ll provide the schema for the api and a working query and see if that covers your current gap to achieve a proper working query to the api.
Below is a functional json string representaiton for the api’s foreignexchangelookuppost_payload:
"{\"sourceCurrencyCode\": \"643\", \"retrievalReferenceNumber\": \"201010101031\", \"cardAcceptor\": {\"idCode\": \"ABCD1234ABCD123\", \"address\": {\"county\": \"San Mateo\", \"country\": \"RU\", \"state\": \"CA\", \"zipCode\": \"94404\", \"city\": \"Foster City\"}, \"terminalId\": \"ABCD1234\", \"name\": \"ABCD\"}, \"sourceAmount\": \"100\", \"destinationCurrencyCode\": \"840\", \"systemsTraceAuditNumber\": \"350421\", \"markUpRate\": \"1\"}"
This would be a solution if the only issue you are facing was “Actually” only a 400 error due to a malformed payload body due to a json string body which was non-resolvable for the foreign exchange api.
Attached is a text document called, "ForeignExchange_API_Schema_min.txt", with the proper object structure of the request and response.
The goal is to verify the data storage methods the sample code are using properly map the schema above. The provided json structure does, so if you still receive a 400 request, the most logical expectation as that the PHP data structure of the foreignexchangelookuppost_payload doesn’t reflect the proper foreign exchange api payload.
Please let us know if this helps and if the issue is resolved.
Hey @arthur,
For your question on currency conversion, I'll check with the product team and someone will get back to you soon on this!
Hey @arthur,
Did you try the code that I provided to you on November 4? Are you still experiencing an issue after utilizing that code?