Recharge creation service

Authenticity POST x signature#

Carat Portal has two methods of merchant authentication on the REST recharge interface: authenticity POST or signature.

In the authenticity POST method, Carat Portal will send the data of the newly created recharge transaction to the registered authenticity URL of the merchant.

In the signature method, the merchant must have a public RSA encryption key registered on Carat Portal and prepare a JWT signature (JSON Web Tokens) to be sent in the Authorization header. In this case, the recharge transaction information will be returned directly in the response. Learn more.

Call details#

  • Resource: /v3/recharge
  • HTTP Method: POST
  • Request format: JSON
  • Response format: JSON
  • Header parameters:
ParameterDescriptionFormatMandatory
Content-TypeIt must be sent with the value application/json.= 15 ANYES
AuthorizationMerchant's signature in the Bearer {signature} format. Example: Bearer JHVGytfdgauygdauiw78264284527852897hagdg.< 2000 ANNO

Examples#

Below are some examples of the recharge creation service call using the cURL tool.

Creating a recharge transaction sending all parameters#

Request:

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

curl
--request POST "https://{{url}}/e-sitef/v3/recharge"
--header "Content-Type: application/json"
--data-binary
{
"begin_recharge_request":{
"merchant_key":"XXXXXXXX",
"merchant_usn":"2398",
"order_id":"023748",
"general_hash":"0000000000000000",
"recharge_type":"normal"
}
}
--verbose

Response:

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

Authenticity POST:

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

curl -X POST \
https://dominiodaloja.com.br \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'cache-control: no-cache' \
-d 'merchantUSN=987654321&merchantId=LOJAFATURAT&orderId=123456789&nit=e009886843920c5173104557c9f6cd66b1481557fb3f4d88daca072eb8a50c97&generalHash=85E791AD85E791AD'

Creating a recharge transaction sending only the required parameters#

Request:

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

curl
--request POST "https://{{url}}/e-sitef/v3/recharge"
--header "Content-Type: application/json"
--data-binary
{
"begin_recharge_request":{
"merchant_key":"XXXXXXXX"
}
}
--verbose

Response:

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

Creating a recharge transaction with signature#

Request:

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

curl
--request POST "https://{{url}}/e-sitef/v3/recharge"
--header "Content-Type: application/json"
--header "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjaGFudF9pZCI6IkxPFGFURVNURSIsIm1lcmNoYW50X2tleSI6IkYxOURFMDAxNzdDMzAxREYyNEE4NjVGMTFBQTlCMjU2N0Y2MDQ4OTFGMEY0NEREQUVGRDY5RTMzOTlFMEI3RTEiLCJvcmRlcl9pZCI6IjEzMDE0ODU4NjYzIiwibWVyY2hhbnRfdXNuIjoiMTQ0NjY4MTAxNiIsInRpbWVzdGFtcCI6IjE2MDUzMDM1ODA5MzEifQ.JoYz8mQ8PZ8MCr5QXygbivAy2x9fvdUEGu_jSeOYF-BtSGm7ZSYWFVokyowabk1FM2NCklubb5eEB_-g9lCi1ntRQ9iqKhdldm-U8pl0V98u7Mv_hR-pcp6MHfqql0T-mhkOv1WkfYO1igck4N6EfsNu9iO126BwgvJQC456WjAUW5jgjRHboc6htvaak9NBs6yRVLNZY03cR9gKtQXMoHeXiCGeNU55_2W1SOeRJPk-OsyBzvVlZBX5RdfUjB2BOdRI7H2TDBBS-GZaMV3b2eS5_84JTySFnriCTXJ-Y1FzBnH60e4fTfAiYy1P_J-j9hyXjLYgtRu8jQd8ITfiFG3h4ZIysb4CA_lJNg_d4YuCqhBiZcpculcbfXlcrcfPV-CpDytfiLz34FDWH0Q7Vlna1YuSNOKPzDIUx1MOMZO9bpwaE6Q3kClkqri92-42yeLoUKH6PUrlMpE3JrfuBelALE4ce7QzCrNjcvoqR_KVmCm6ozBjPn9qY0s7x7qe6ZLur7hNUoX79JdWGZy1-bx8dSqqpLrU0SXbMBqtvch5FvdUkktbkJpZAr7q6e0nR13_mK3RTV7adOEw03E_ocUk__rEmjGDAHMSWGmiPowu14jD1-VZ2Yf8FeoKzHYcXmIbEReTVHshk9faBICMQzMS3SXaqow4WXqULZiLTwc"
--data-binary
{
"begin_recharge_request":{
"merchant_key":"XXXXXXXX",
"merchant_usn":"1446681016",
"order_id":"13014858663",
"general_hash":"0000000000000000"
}
}
--verbose

Response:

{
"begin_recharge_response":{
"esitef":{
"message":"OK. Transaction successful.",
"code":"0"
},
"nit": "jhadafsafhjhasdfghiyuw43u8785345jksjknsmnnsjkfkiu34u98ynksnn3535",
"merchant_id": "XXXXXXXX",
"order_id": "13014858663",
"merchant_usn": "1446681016",
"general_hash": "AF32810AAF32810A"
}
}

Request parameters#

The table below describes the request parameters of the recharge creation service:

ParameterDescriptionFormatMandatory
merchant_keyMerchant key registered on Carat Portal< 80 AYES
merchant_usnUnique sequential number generated by the merchant< 12 NNO
order_idOrder identification code generated by the merchant< 20 ANNO
general_hashIdentification code of the table with the data related to the recharges (dealers, branches, amount ranges, expiration periods, among others).

If the store hadn't performed a recharge previously or hadn't saved a previously received value from Carat Portal, the value: 0000000000000000 can be passed to Carat Portal. If the general_hash is not sent, the store will be obliged to make all queries to obtain the data necessary for the next steps of the recharge.
= 16 ANO
recharge_typeType of the recharge to be performed.

Values:
  • normal – Cell phone top-up
  • others – Recharge for other types of products, such as games PIN, donations, iUSNrance or even cell phone recharge by other modalities.
  • invoice – Signature invoice payment
Default value: normal
= 6 ANO

Response parameters#

In case of success, the HTTP response code will be 200. Any other code must be interpreted as an error. The table below describes de response parameters of the recharge creation service:

ParameterDescriptionFormat
nitIdentification of the recharge transaction on Carat Portal= 64 AN
merchant_idMerchant ID on Carat Portal< 15 AN
order_idOrder code generated by the merchant< 20 AN
merchant_usnUnique sequential number generated by the merchant< 12 N
general_hashIdentification code of the table with the data related to the recharges (carriers, subsidiaries, ranges of values, validity of credits, among others).= 16 AN
esitef Element that describes Carat Portal's response.
codeCarat Portal response code. Any code different from 0(zero) means failure. Learn more.< 4 N
messageCarat Portal response message.< 500 AN

Authenticity POST parameters#

The table below describes the parameters sent by Carat Portal on the authenticity POST:

ParameterDescriptionFormat
nitIdentifier of the cancel transaction to be used in the next step of the flow.= 64 AN
merchantIdMerchant code on Carat Portal.< 15 AN
orderIdOrder ID of the payment created by merchant< 20 AN
merchantUSNUSN generated by the merchant for the payment< 12 N
generalHashIdentification code of the table with the data related to the recharges (dealers, branches, amount ranges, expiration periods, among others).= 16 AN

Carat Portal can also send new parameters without previous warning, which means that the merchant’s application must be prepared to receive extra fields and just ignore them.

Parameters sent by Carat Portal on HTTPS POST#

Important:

Carat Portal uses the x-www-form-urlencoded media type to send the HTTPS POST. Therefore, the server must accept this type of media on the merchant's registered URL to receive POST HTTPS.

ParameterDescriptionFormat
nitIdentification of the recharge transaction on Carat Portal= 64 AN
merchantIdMerchant ID on Carat Portal< 15 AN
orderIdOrder code generated by the merchant< 20 AN
merchantUSNUnique sequential number generated by the merchant< 12 N
generalHashIdentification code of the table with the data related to the recharges (carriers, subsidiaries, ranges of values, validity of credits, among others).= 16 AN