Create Pre-Approved Transaction
Introduction
This article explains how to create a pre-approved transaction through the REST API.
This method is used to create a transaction. It also performs a pre-approval of the informed data. Thus, the biometric capture is not necessary in all cases.
This method cannot be used along with Create Transaction.
This option is used:
- When the IDPay is at the top of the funnel;
- In a 100% integrated solution with the biometric capture through Webview;
- When the informed identification (CPF for example) belongs to the cardholder (this flow does not allow the user to share the validation with the real holder or inform a new CPF during the validation);
- Others.
How to use?
Make a POST request to the /credit/transactions/pre-approved
endpoint.
With a valid access token, make a request to the (POST/credit/transactions/pre-approved) endpoint, sending the following parameters:
{
"identity": {
"key": "cpf",
"value": "USER_CPF"
},
"orderNumber": "ORDER_NUMBER",
"company": "COMPANY_ID",
"redirectUrl": "URL",
"card": {
"binDigits": "FIRST_6_OR_8_DIGITS_CARD",
"lastDigits": "LAST_4_DIGITS_CARD",
"expirationDate": "EXPIRATION_DATE_CARD",
"name": "NAME"
},
"value": PURCHASE_VALUE,
"phone": "CELL_PHONE_NOTIFICATION",
"email": "EMAIL_NOTIFICATION"
}
The company é field is provided by Unico.
The redirectUrl field is used to redirect the person to the desired url address. The redirection is done at the end of the flow (webview). This field is optional.
The expirationDate field is also optional.
The phone and email fields are not required. If the phone field is empty, the SMS is not sent. If the email field is empty, the E-mail is also not sent. There is a possibility of not completing these fields. In this case, sending can be done through whatsapp, app push, webview in app.
The other fields are mandatory.
If everything is right in the request, the response is a JSON with the transaction ID, transaction status and the capture link, as follows:
{
"id": "6ab1771e-dfab-4e47-8316-2452268e5481",
"status": "waiting",
"link": "https://aces.so/teste"
}
If the pre-approval decides that it is not necessary to capture the biometrics, the response will have a different status and a link for the capture will not be generated, as follows:
{
"id": "6ab1771e-dfab-4e47-8316-2452268e5481",
"status": "fast-inconclusive"
}
If an error occurs, the response is a JSON with the error and the error code:
{
"error": {
"code": "40004",
"description": "transaction id is invalid"
}
}
The following is a list of possible errors returned by the service:
HTTP Code | Code | Description | Reason |
---|---|---|---|
400 | 40001 | error decoding json | The data sent does not match the service contract |
400 | 40002 | error validating json | Some of the information is badly formatted or not filled in |
400 | 40024 | invalid name | The name is filled with invalid characters or is not a valid name |
400 | 40021 | invalid phone | The phone is invalid. The default to be followed is 55 DDD NUMBER. Example: 5543999999999 |
400 | 40022 | invalid email | The e-mail is invalid |
400 | 40027 | replicated transaction | Sent transaction already exists and cannot be recreated |
403 | 40301 | not allowed | The user does not have permission to perform such an action. |
404 | 40404 | company not found | The company does not exist |
429 | 40001 | too many requests | Ratelimit reached |
500 | 50001 | internal error | Internal service failure |
Any concerns?
Missing something or still need help? If you are already a customer or partner, you can contact us through the Help Center.