Authorize the payment with authentication
#
Function esitefDoPaymentAfter the customer fills in all the fields on the store's screen, they should click a button to complete the payment. In the onclick event, a JavaScript function should be called, filling the request with nit, payToken, merchantId, authenticate, onSuccess callback function, onProcessing, onFailure, onInvalid, and subsequently invoking the esitefDoPayment function, passing the request as a parameter. The esitefDoPayment function performs 3DS authentication, which may display a challenge involving security code checks, token validation, approvals on the buyer's mobile device, or other verifications. Following authentication, payment authorization takes place with the acquirer. It is important to clarify that, according to the parameterization provided during the transaction creation (authenticate field), the transaction authorization behavior may change:
- If the transaction is submitted with authenticate =
1
, then the transaction will only be authorized if the authentication is approved. - If the transaction is submitted with authenticate =
2
, then the transaction will only be authorized if the authentication is approved, but for card networks not supported by 3DS, the authentication step will be skipped. - If the transaction is submitted with authenticate =
3
, then the transaction will go through the authentication flow, but if there is a negative result, the flow proceeds to authorization.
#
Calling the Carat scriptWhen the buyer fills in the card details and clicks 'pay,' the merchant's page should call the JavaScript function esitefDoPayment
, passing as an argument a request with the following fields:
Parameter | Description | Format | Mandatory |
---|---|---|---|
nit | Transaction identifier in Carat. Field nit received during the transaction creation step. | = 64 AN | YES |
payToken | Field pay_token received during the transaction creation step. This token can only be used once. | = 66 AN | YES |
merchantId | Merchant code in Carat. Production and certification codes will be different. | < 15 N | YES |
onSuccess | Callback function that will be called after a successful payment in Carat. This function takes the payment response as an argument, as described in - Response from success and failure callbacks. | F | YES |
onProcessing | Callback function that will be called after a challenge requested by the issuer in the 3DS authentication flow or late confirmation. | F | YES |
onFailure | Callback function that will be called after an unsuccessful payment in Carat. This function takes the payment response as an argument, as described in - Response from success and failure callbacks. | F | YES |
onInvalid | Callback function that will be called after a JavaScript validation error. This function takes the list of errors as an argument, as described in - Response from validation error callback. | F | YES |
authenticate | Boolean field to indicate that the JavaScript payment includes 3DS authentication, pass 'true' if the payment is with 3DS. | = 4 AN | YES |
challengeWindowSize | Field that represents the size for the presentation of the challenge: 01 - 250 x 400, 02 - 390 x 400, 03 - 500 x 600. If not passed, JavaScript will determine a value to be used. | = 2 AN | NO |
#
Response from success and failure callbacks.The callback functions onSuccess
and onFailure
receive an object as an argument containing information related to the payment. Below are the descriptions of these fields:
Parameter | Description | Format |
---|---|---|
code | Carat response code. Any code other than 0 (zero) indicates failure. For more information, refer to the Response Codes. | < 4 N |
message | Carat response message. | < 500 AN |
payment | ||
authorizer_code | Authorization response code. | < 10 AN |
authorizer_message | Authorization response message. | < 500 AN |
status | Payment transaction status in Carat. | = 3 AN |
nit | Identification number of the payment transaction in Carat. | = 64 AN |
order_id | Order code sent by the store during the creation of the transaction. | < 40 AN |
customer_receipt | Coupon (via customer). | < 4000 AN |
authorizer_id | Code of the acquirer used in the transaction. | < 4 N |
#
Validation error callback response.The onInvalid
callback function receives, as an argument, a list of objects representing validation errors, containing the following fields:
Parameter | Description | Format |
---|---|---|
field | Name of the field with an error. | < 30 AN |
cause | Error message. | <100 AN |
#
ExampleBelow is an example of a JavaScript function calling esitefDoPayment: