pagamento-js-quickstart

--- id: pagamento-js-quickstart title: Quick start

sidebar_label: Quick start#

Creating a transaction#

HTTP method: POST

URL: https://esitef-homologacao.softwareexpress.com.br/e-sitef/api/v1/transactions

Headers:

  • Content-Type: application/json
  • merchant_id: {your merchant id}
  • merchant_key: {your merchant key}

Request:

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

{
"merchant_usn": "12042142155",
"order_id": "12042142155",
"installments": "1",
"installment_type": "4",
"authorizer_id": "2",
"amount": "1000",
"payment_js": "true"
}
curl
--request POST "https://{{url}}/e-sitef/api/v1/transactions"
--header "Content-Type: application/json"
--header "merchant_id: xxxxxxxx"
--header "merchant_key: xxxxxxxx"
--data-binary
{
"merchant_usn":"12042142155",
"order_id":"12042142155",
"installments":"1",
"installment_type":"4",
"authorizer_id":"2",
"amount":"1000",
"payment_js":"true"
}
--verbose

Response:

{
"code": "0",
"message": "OK. Transaction successful.",
"payment": {
"status": "NOV",
"nit": "1234567890123456789012345678901234567890123456789012345678901234",
"order_id": "12042142155",
"merchant_usn": "12042142155",
"amount": "1000",
"pay_token": "123456789012345678901234567890123456789012345678901234567890123456"
}
}

Learn more about this service.

Payment page of virtual merchant#

The merchant's payment 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/esitefpayment-1.0.min.js

URL for Homologation environment:


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

Example

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

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/esitefpayment-1.0.min.js"
></script>
<script>
function myPay() {
var request = {
onSuccess: function(response) {
console.log(response.code);
console.log(response.message);
console.log(response.payment.authorizer_code);
console.log(response.payment.authorizer_message);
console.log(response.payment.status);
console.log(response.payment.nit);
console.log(response.payment.order_id);
console.log(response.payment.customer_receipt);
console.log(response.payment.authorizer_id);
},
onFailure: function(response) {
console.log(response.code);
console.log(response.message);
console.log(response.payment.authorizer_code);
console.log(response.payment.authorizer_message);
console.log(response.payment.status);
console.log(response.payment.nit);
console.log(response.payment.order_id);
console.log(response.payment.authorizer_id);
},
onInvalid: function(errors) {
for (var i = 0; i < errors.length; i++) {
console.log(errors[i].field);
console.log(errors[i].cause);
}
},
nit:1234567890123456789012345678901234567890123456789012345678901234',
payToken:123456789012345678901234567890123456789012345678901234567890123456',
merchantId: 'xxxxxxxx',
locale: 'pt',
isCardSecurityCodeOptional: false
};
esitefDoPayment(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="text" class="esitef-cardsecuritycode" />
<input type="button" onclick="myPay()" />
</form>
</body>
</html>