# 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.](pagamento-rest-quickstart.md) - 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\:///e-sitef/api/v1/cancellations **Headers**: - **Content-Type**: application/json - **merchant_id**: {your merchant id} - **merchant_key**: {your merchant key} **Request**: Fill the **\** 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
**** ```json { "esitef_usn": "" } ``` ```curl 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":"" } --verbose ``` **Receiving the authenticity POST:** ```java @RestController public class MyAuthenticityController { @PostMapping(value = "/myauthenticity", consumes = "application/x-www-form-urlencoded; charset=utf-8") public ResponseEntity myAuthenticity(@RequestParam Map request) { Log.info("nit = " + request.get("nit")); // ... // stores the cancel NIT // ... return new ResponseEntity<>("OK", HttpStatus.OK); } } ``` **Response**: ```json { "code": "0", "message": "OK. Transaction successful." } ``` [Learn more about this service.](cancelamento-rest-begin.md) ## Cancelling the payment **HTTP method**: PUT **URL**: https\:///e-sitef/api/v1/cancellations/**\** Replace the **\** 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
**** ```json { "card": { "number": "5555555555555555", "expiry_date": "1222", "security_code": "601" }, "amount": "1" } ``` ```curl curl --request PUT "https:{{url}}/e-sitef/api/v1/cancellations/" --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**: ```json { "code": "0", "message": "OK. Transaction successful.", "cancellation": { "authorizer_code": "000", "authorizer_message": "Transacao OK", "status": "CON", "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.](cancelamento-rest-docancel.md) ## Checking the cancel status **HTTP method**: GET **URL**: https\:///e-sitef/api/v1/transactions/**\** Replace the **\** 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
**** ```curl curl --request GET "https://{{url}}/e-sitef/api/v1/transactions/" --header "merchant_id: xxxxxxxxxxxxxxx" --header "merchant_key: xxxxxxxxxxx" --verbose ``` **Response**: ```json { "code": "0", "message": "OK. Transaction successful.", "cancellation": { "authorizer_code": "000", "authorizer_message": "Transacao OK", "status": "CON", "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.](pagamento-rest-getstatus.md)