Me da el siguiente error, cuando quiero probar la api: https://sandbox.api.visa.com/vbs/dapi/v1/transaction_enhanced
{
"responseStatus": {
"status": 400,
"code": "9125",
"severity": "ERROR",
"message": "Expected input credential was not present",
"info": ""
}
}
¿alguien sabe cómo se soluciona?
Saludos cordiales
Hey @JorgeTigre,
I understand that you are encountering issues with the `https://sandbox.api.visa.com/vbs/dapi/v1/transactionEnhanced` endpoint and receiving a 403 Forbidden error. Here are some steps to help you troubleshoot and resolve this issue:
1. Verify Mutual SSL Configuration:
Ensure that mutual SSL (mSSL) is properly configured. The Visa API requires a client certificate for secure communication. Make sure that:
- The client certificate and private key are correctly installed and are being sent with the request.
- The client certificate is not expired.
- The certificate is correctly associated with your Visa Developer project.
2. Check API Key:
Ensure that the `apiKey` parameter in the query string matches the API key provided in your Visa Developer project. The API key should be correctly included in your request's query parameters.
3. Review Request Headers:
Ensure that all required headers are included in your request. The typical headers for Visa API requests include:
```plaintext
Content-Type: application/json
Accept: application/json
Authorization: Basic <base64-encoded-credentials>
x-client-transaction-id: <unique-transaction-id>
```
4. Authorization Header:
Ensure that your `Authorization` header is correctly formed. It should contain the base64-encoded credentials in the format `Basic base64(userId:password)`. Ensure that the `userId` and `password` are correct and match those in your Visa Developer project.
5. Check Endpoint URL:
Verify that you are using the correct endpoint URL: `https://sandbox.api.visa.com/vbs/dapi/v1/transactionEnhanced`. Double-check the URL for any typos or errors.
6. Payload Structure:
Verify that the JSON payload being sent in the request body adheres to the structure expected by the API. Refer to the Visa Direct API documentation for the correct payload structure and required fields.
7. Firewall and Network Configuration:
Ensure that there are no firewalls or network configurations blocking access to the Visa API endpoint. Sometimes, network restrictions can cause 403 errors.
Here is an example of what your request might look like:
```plaintext
POST https://sandbox.api.visa.com/vbs/dapi/v1/transactionEnhanced
Headers:
Content-Type: application/json
Accept: application/json
Authorization: Basic <base64-encoded-credentials>
x-client-transaction-id: <unique-transaction-id>
Body:
{
"primaryAccountNumber": "4111111111111111",
"queryStartDate": "2023-01-01",
"queryEndDate": "2023-01-31",
...
}
```
Hola Diana, buen día: muchas gracias por tu respuesta.
Quisiera saber cual de todos estos certificados, es el que hay que usar para pruebas en sandbox.
1. Certificado raíz de la plataforma de desarrollo de visas - CA raíz de Sandbox
2. Certificado intermedio de la plataforma de desarrollo de visas - CA emisora de Sandbox
3. Para certificados que vencen el/antes del 21 de julio de 2025 a las 04:27:37 GMT - VDPCA
4. certificado que está dentro de Cartas credenciales ("cert.pem")
5. Certificado de CA raíz global de DigiCert - Certificado de CA raíz global de DigiCert
Estoy en sandbox, y estoy usando el del punto 4. , cert.pem, tal vez sea que estoy usando un certificado incorrecto
Agradezco mucha la ayuda que me estoy dando, dado que si no resuelvo este tema, no puedo avanzar en el desarrollo que mi Empresa necesita, y no tengo otro medio a quién acudir.
Saludos cordiales
Hey @JorgeTigre,
To perform tests in the sandbox environment of the Visa Developer platform, you need to use the correct certificate to establish a secure connection with the Visa APIs. Based on the information you provided, the certificate you should use is the following:
4. Certificate included in the Credentials ("cert.pem")
The `cert.pem` file is the certificate specifically provided for use in the sandbox environment. This certificate is necessary to authenticate your application when making calls to the Visa APIs in the test environment.
If you are still experiencing issues, ensure that you are also using the private keys and any other credential files provided in the credential package you downloaded from the Visa Developer portal. Additionally, verify that your TLS/SSL configuration is correctly set up to use this certificate.
If you need further assistance or if the issue persists, I recommend reviewing the official documentation on the Visa Developer platform or contacting technical support for direct assistance.
Hey @JorgeTigre,
The error you're encountering indicates that an expected credential is missing in your request to the Visa API. This typically means that a necessary header or parameter for authentication has not been included.
To resolve this issue, ensure that you are including all required credentials in your request. Here are some steps you can follow:
1. Authentication: Make sure you are using the correct authentication method. Visa APIs usually support two methods of authentication: `mutual SSL` and `API Key - Shared Secret (x-pay-token)`. Ensure you are correctly implementing one of these methods.
2. Required Headers:
- x-pay-token: If you are using the `API Key - Shared Secret` method, you need to include a correctly generated `x-pay-token` header.
- Mutual SSL Authentication: If you are using mutual SSL, ensure your certificate and private key are correctly configured in your request.
3. API Key: Make sure the API Key is included in the URL of the request as a query parameter.
Here is an example of how a request using `x-pay-token` should look:
```python
# START
import requests
import time
import hmac
import hashlib
import base64
# Your API Key and Shared Secret
api_key = 'YOUR_API_KEY'
shared_secret = 'YOUR_SHARED_SECRET'
# Generate the x-pay-token
def generate_x_pay_token(api_key, shared_secret, resource_path, query_string, request_body):
timestamp = str(int(time.time() * 1000))
pre_hash_string = timestamp + resource_path + query_string + request_body
hash_string = hmac.new(shared_secret.encode('utf-8'), pre_hash_string.encode('utf-8'), hashlib.sha256).digest()
x_pay_token = api_key + ':' + timestamp + ':' + base64.b64encode(hash_string).decode()
return x_pay_token
resource_path = '/vbs/dapi/v1/transaction_enhanced'
query_string = 'apikey=' + api_key
request_body = '{}'
x_pay_token = generate_x_pay_token(api_key, shared_secret, resource_path, query_string, request_body)
headers = {
'Content-Type': 'application/json',
'x-pay-token': x_pay_token
}
url = 'https://sandbox.api.visa.com' + resource_path + '?' + query_string
response = requests.post(url, headers=headers, data=request_body)
print(response.status_code)
print(response.json())
# END
```
Make sure to replace `'YOUR_API_KEY'` and `'YOUR_SHARED_SECRET'` with your actual credentials.
If you are using mutual SSL authentication, make sure to properly configure your certificate and private key in the HTTP request.