Quick start

This guide shows the process of cancelling a payment, using Carat Portal's REST web service interface.

What you'll need#

  • esitef_usn of a payment confirmed on Carat Portal. Learn more.
  • A tool capable of performing HTTP calls, such as Postman, REST Client or cURL
  • An application capable of receiving POST HTTPS calls

Creating a cancel transaction#

HTTP method: POST

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

Headers:

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

Request: Fill the <payment_usn> field in the request below with the esitef_usn obtained in the payment response.

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

{
"esitef_usn": "<payment_usn>"
}
curl
--request POST "https://{{url}}/e-sitef/api/v1/cancellations"
--header "Content-Type: application/json"
--header "merchant_id: xxxxxxxxxxx"
--header "merchant_key: xxxxxxxxxxx"
--data-binary
{
"esitef_usn":"<payment_usn>"
}
--verbose

Receiving the authenticity POST:

@RestController
public class MyAuthenticityController {
@PostMapping(value = "/myauthenticity",
consumes = "application/x-www-form-urlencoded; charset=utf-8")
public ResponseEntity<String> myAuthenticity(@RequestParam Map<String, String> request) {
Log.info("nit = " + request.get("nit"));
// ...
// stores the cancel NIT
// ...
return new ResponseEntity<>("OK", HttpStatus.OK);
}
}

Response:

{
"code": "0",
"message": "OK. Transaction successful."
}

Learn more about this service.

Cancelling the payment#

HTTP method: PUT

URL: https://esitef-homologacao.softwareexpress.com.br/e-sitef/api/v1/cancellations/<nit>

Replace the <nit> field in the URL above with the NIT obtained on the authenticity POST.

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

{
"card": {
"number": "5555555555555555",
"expiry_date": "1222",
"security_code": "601"
},
"amount": "1"
}
curl
--request PUT "https:{{url}}/e-sitef/api/v1/cancellations/<nit>"
--header "Content-Type: application/json"
--header "merchant_id: xxxxxxxxxxx"
--header "merchant_key: xxxxxxxxxxx"
--data-binary
{
"card":{
"number":"5555555555555555",
"expiry_date":"1222",
"security_code":"601"
},
"amount":"1"
}
--verbose

Response:

{
"code": "0",
"message": "OK. Transaction successful.",
"cancellation": {
"authorizer_code": "000",
"authorizer_message": "Transacao OK",
"status": "CON",
"nit": " <nit>",
"order_id": "09062259711",
"customer_receipt": "=== COMPROVANTE ===",
"merchant_receipt": "=== COMPROVANTE ===",
"authorizer_id": "2",
"acquirer_id": "229",
"acquirer_name": "Bin",
"authorizer_date": "09/11/2017T18:23",
"authorization_number": "092423",
"merchant_usn": "9062259711",
"esitef_usn": "171109108051261",
"sitef_usn": "092424",
"host_usn": "999092424 ",
"amount": "1",
"payment_type": "C",
"issuer": "2",
"authorizer_merchant_id": "000000000000005",
"esitef_date": "09/11/2017T18:23",
"is_host_cancel": "false"
}
}

Learn more about this service.

Checking the cancel status#

HTTP method: GET

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

Replace the <nit> field in the URL above with the NIT obtained on the authenticity POST.

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

curl
--request GET "https://{{url}}/e-sitef/api/v1/transactions/<nit>"
--header "merchant_id: xxxxxxxxxxxxxxx"
--header "merchant_key: xxxxxxxxxxx"
--verbose

Response:

{
"code": "0",
"message": "OK. Transaction successful.",
"cancellation": {
"authorizer_code": "000",
"authorizer_message": "Transacao OK",
"status": "CON",
"nit": " <nit>",
"order_id": "09062259711",
"customer_receipt": "=== COMPROVANTE ===",
"merchant_receipt": "=== COMPROVANTE ===",
"authorizer_id": "2",
"acquirer_id": "229",
"acquirer_name": "Bin",
"authorizer_date": "09/11/2017T18:23",
"authorization_number": "092423",
"merchant_usn": "9062259711",
"esitef_usn": "171109108051261",
"sitef_usn": "092424",
"host_usn": "999092424 ",
"amount": "1",
"payment_type": "C",
"issuer": "2",
"authorizer_merchant_id": "000000000000005",
"esitef_date": "09/11/2017T18:23",
"is_host_cancel": "false"
}
}

Learn more about this service.