Virtual store's page

The merchant's page must contain the Carat Portal's script. Below are the URL's for download:

URL for Production environment:


https://esitef.softwareexpress.com.br/js/esitefstore-1.0.min.js

URL for Homologation environment:


https://esitef-homologacao.softwareexpress.com.br/js/esitefstore-1.0.min.js

Fields with card data#

The card fields must contain the classes specified below:

ParameterDescriptionFormatMandatory
esitef-cardnumberCustomer's card number (PAN).< 19 NYES
esitef-cardexpirydateCard expiry date in MMYY format.= 4 NYES
esitef-cardexpirymonth
& esitef-cardexpiryyear
Card expiry month and year, in MM and YY format, respectively. These fields can be sent instead of esitef-cardexpirydate. If all these fields are sent at the same time, the split date (esitef-cardexpirymonth and esitef-cardexpiryyear) will have priority.= 2 NYES

Calling Carat Portal's script#

When the customer fills the card data and submit, the merchant's page must call the "esitefStore" JavaScript function, passing as argument a request with the following fields:

ParameterDescriptionFormatMandatory
nitaEncrypted store transaction identifier number returned to the store by Carat Portal.= 65 ANYES
store_tokenToken related to the JavaScript store.= 66 ANYES
merchantIdMerchant code on Carat Portal. The production and certification codes will be different.< 15 ANYES
localeLanguage of the messages returned in validation errors (onInvalid callback). It can receive the following values:
pt - Portuguese
en - English
es - Spanish
If the locale is not sent, pt will be used.
= 2 ANO
authorizer_idCode of the authorizer on Carat Portal. Learn more.< 3 NYES
onSuccessCallback function the will be called after a successful payment on Carat Portal. This function receives as argument the payment response described in Success and failure callbacks response.FYES
onFailureCallback function the will be called after an unsuccessful payment on Carat Portal. This function receives as argument the payment response described in Success and failure callbacks response.FYES
onInvalidCallback function that will be called after a JavaScript validation error. This function receives as argument the error list described in Validation error callback responseFYES

Success and failure callbacks response#

The onSuccess and onFailure callback functions receive as argument an object containing information related to the store. Below are the descriptions of these fields:

ParameterDescriptionFormat
codeCarat Portal response code. Any code different from 0 (zero) means failure. For further information, refer to the Response codes.< 4 N
messageCarat Portal response message.< 500 AN
store
statusStatus of the payment transaction on Carat Portal.= 3 AN
nitaEncrypted store transaction identifier number returned to the store by Carat Portal.= 65 AN
merchant_usnUnique sequential number generated by the merchant.< 12 N

Validation error callback response#

The onInvalid callback function receives as argument a list of error objects, containing the fields below:

ParameterDescriptionFormat
fieldName of the field in error.< 30 AN
causeError message.< 100 AN

Example#

Below is an example of a page integrated with Carat Portal's JavaScript store:

To use this example, don't forget to define the variable {{url}} to the value
esitef-homologacao.softwareexpress.com.br

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script
type="text/javascript"
src="https://{{url}}/js/esitefstore-1.0.min.js"
></script>
<script>
function myStore() {
var request = {
onSuccess: function (response) {
console.log(response.code);
console.log(response.message);
console.log(response.store.status);
console.log(response.store.nita);
console.log(response.store.merchant_usn);
},
onFailure: function (response) {
console.log(response.code);
console.log(response.message);
console.log(response.store.status);
console.log(response.store.nita);
console.log(response.store.merchant_usn);
},
onInvalid: function (errors) {
for (var i = 0; i < errors.length; i++) {
console.log(errors[i].field);
console.log(errors[i].cause);
}
},
nita: 'Zdn2482f8924jh8fh842390hfef2fij20fj40jf024jf9j240hf4hjf0h243f84jf',
storeToken:
'123456789012345678901234567890123456789012345678901234567890123456',
merchantId: 'xxxxxxxx',
locale: 'pt',
authorizerId: '2',
};
esitefStore(request);
}
</script>
</head>
<body>
<form method="POST">
<input type="text" class="esitef-cardnumber" />
<input type="text" class="esitef-cardexpirymonth" />
<input type="text" class="esitef-cardexpiryyear" />
<input type="button" onclick="myStore()" />
</form>
</body>
</html>