Edenred Direct Payment Services icon

Edenred Direct Payment Services

(0 reviews)

Use Case: Brazil

Generalities

In Brazil, a user can spend the exact amount requested, with limitations.

These regulations are handled on the Edenred side. Please note that all amounts in our API are given in centavos (example: 9BRL = 900).

Ticket Restaurant local regulation

In Brazil, for the Ticket Restaurant product, a user can :

  • Perform a transaction up to 500 BRL (which meaning that a transaction of 501 BRL will be declined). Note that the amount of the transaction can't be below 0,01cts
  • Perform 5 transactions per day (which mean that the 6th transaction request of the day will be declined)

Note that all those checks are performed by the local authorization platform itself. Error code related to those limits are described in the specification of the transaction processing.

Ticket Alimentaçao local regulation (for grocery players)

In Brazil, for the Ticket Alimentaçao product, a user can :

  • Perform a transaction up to 2000 BRL (which meaning that a transaction of 2001 BRL will be declined). Note that the amount of the transaction can't be below 0,25cts
  • Perform 5 transactions per day (which meaning that the 6th transaction request of the day will be declined)

Note that all those checks are performed by the local authorization platform itself.

User Security Tokens

Please refer to this section for more details about security tokens.

1) To test the API in sandbox, you can get an authorization_code by clicking on the link bellow:

https://sso.sbx.edenred.io/connect/authorize?response_type=code&client_id=8085b1d4894e4e0ebbbd2bfe32e903d4&scope=openid%20edg-xp-mealdelivery-api%20offline_access&redirect_uri=http://nowhere.edenred.net/oauth/callback&state=abc123&nonce=456azerty&acr_values=tenant:br-ben&ui_locales=en

Example of account that can be used to test the API:

 Username: StgEdps@Ticket.com.br
 Password: Stg@2023
 CVV: 046 (for card ending with ******6111)
Login Page

resources/login_page-5d93fd66-c2ab-4968-9653-e6cf38c78aaa.PNG

Card selector

resources/select_card-454a8863-a018-4519-bcbf-5954b4f07f39.PNG

Confirm CVV code from the back of the card

resources/CVV_Validation-d0be2992-d366-4dad-ab2b-03c939e6170c.PNG

Accept Agreement

resources/agreement-80369fe7-19ce-4f0c-8ac1-27a7c5ca7c2f.PNG

2) After login, you'll be redirected to a url like :

http://nowhere.edenred.net/?code={authorization_code}&...

3) Copy the authorization_code and use the request "Get access_token from authorization_code" in the following collection of API calls : postman collection

Please note that an authorization_code is burned every time you try to use it. If your API call fails, you must get a new authorization_code.

Logout

Logout the Edenred account from your platform. All tokens are then invalid

GET /connect/endsession?id_token_hint=<idToken>=<postLogoutRedirectUri> HTTP/1.1
Host: {{authentication-URL}}

Where

'authentication-URL' = sso.sbx.edenred.io

And idToken is retrieved from the refreshing token response

And postLogoutRedirectUri is a callback URL whitelisted on our side (to be provided in the configuration request)

eg: postLogoutRedirectUri = [http://nowhere.edenred.net/(http://nowhere.edenred.net/)

Direct Payment API

III. Direct Payment API

If you use the postman collection, the access_token will automatically be placed in your HTTP Authorization header.

Token Management:

OperationsEndpointsDescription
Get access_tokenPOST /connect/tokenGet a new access token
Get refresh_tokenPOST /connect/tokenRefresh the access token

Users Management:

OperationsEndpointsDescription
Get BalanceGET /v2/users/{username}Get user balance
Estimate ChargePOST /v2/users/{username}/actions/estimate-chargeCheck if you can pay with the given amount

Transaction Management

  • Capture Mode auto:
OperationsEndpointsDescription
Authorize + CapturePOST /v2/transactionsAuthorize and Capture in one call
RefundPOST /v2/transactions/{authorization_id}/actions/refundRefund the auto captured transaction
  • Capture Mode Manual:

a- Authorize > Cancel

OperationsEndpointsDescription
Authorize ManualPOST /v2/transactionsAuthorize a new payment
CancelPOST /v2/transactions/{authorization_id}/actions/cancelCancel the authorized payment

b- Authorize > Capture > Refund

OperationsEndpointsDescription
Authorize ManualPOST /v2/transactionsAuthorize a new payment
CapturePOST /v2/transactions/{authorization_id}/actions/captureCapture the authorized payment
RefundPOST /v2/transactions/{authorization_id}/actions/refundRefund the captured payment

The postman configuration available here is set in auto-clearing mode => cancel and capture routes are not available.

You can request an access to our UAT environment in manual-clearing mode if you choose to implement the payment with Edenred this way.

Get Balance

Get the balance which is available on the user's account.

The authorization header is mandatory for this request.

Request:

 GET /v2/users/{username} HTTP/1.1
 Host: directpayment.stg.eu.edenred.io
 Authorization: Bearer {token}
 X-Client-Id: {payment-clientId}
 X-Client-Secret: {payment-clientSecret}

Response:

 {
  "meta": {
     "status": "succeeded",
     "messages": []
   },
  "data": {
     "available_amount": 12000,
     "currency": "BRL"
   }
 }

Estimate Charge

Check if an amount can be spent and answer the possible amount that can be spent. If the requested amount is above the available balance, the service will provide the available amount in the response.

The authorization header is mandatory for this request.

Request:

 POST /v2/users/{username}/actions/estimate-charge HTTP/1.1
 Host: directpayment.stg.eu.edenred.io
 Authorization: Bearer {token}
 X-Client-Id: {payment-clientId}
 X-Client-Secret: {payment-clientSecret}
 Content-Type: application/json
 {
   "amount": 1900
 }

Response:

 {
   "meta": {
      "status": "succeeded",
      "messages": []
    },
   "data": {
      "available_amount": 1500,
      "currency": "BRL"
    }
 }

Capture Mode - Auto

Step 1: Auto Capture a transaction

An auto capture can only be requested with an amount in cents of BRL.

The authorization header should be set for this operation.

In this mode, we can perform only the below operations:

OperationsEndpointsDescription
Authorize & CapturePOST /v2/transactionsCreate a transaction, the capture_mode MUST be auto
RefundPOST /v2/transactions/{authorization_id}/actions/refundRefund a captured transaction. The authorization_id is returned by the Authorize operation

All transactions requests must be sent with the following information to identify the merchant in the transaction : the "MID" and the corresponding "CNPJ". A check is performed during the authorization to validate that the MID belongs to the CNPJ (if not, the authorization will be declined with the reason "400 - The Merchant is invalid").

CNPJ must be provided in the body of the transaction request in the field "extra_field"

CNPJ must contain 14 digits (if CNPJ inferior to 14 digits, it must be fulfilled with “0” on the left). CNPJ must contain only numbers, no special caracters allowed such as “/” “.” or “-“

The idempotency/duplicate check is applied based on the "username / amount / MID / Date" check. Timestamp is not mandatory to trigger the idempotency/duplicate check on the Brazilian authorization platform.

Request:

 POST /v2/transactions HTTP/1.1
 Host: directpayment.stg.eu.edenred.io
 Authorization: Bearer {token}
 X-Client-Id: {payment-clientId}
 X-Client-Secret: {payment-clientSecret}
 Content-Type: application/json
 {
  "order_ref": "order-002",
  "mid": "20290",
  "extra_field"= "15596390000181",
  "amount": 1,
  "capture_mode": "auto",
  "security_mode": "standard",
  "currency": "BRL",
  "tstamp": "2019-05-23T14:02:50Z",
 }

Response:

{
   "meta": {
        "status": "succeeded",
        "messages": []
    }
    "data": {
        "order_ref": "order-002",
        "mid": "20290",
        "authorization_id": "455211",
        "authorized_amount": 1,
        "capture_id": "455211",
        "capture_amount": 1,
        "status": "captured"
    }
}

Step 2: Refund a captured transaction

Once captured, a transaction can be refunded.

The authorization_id provided during the payment process must be provided in this request.

the exact "capture_amount" must be provided in the amount field. No partial refund supported

The authorization header is not for this operation. The authorization_id is used by the platform to retrieve the existing authorization and process the enrichment of the request with the information of this transaction.

Refund Request:

 POST /v2/transactions/{authorization_id}/actions/refund HTTP/1.1
 Host: directpayment.stg.eu.edenred.io
 X-Client-Id: {payment-clientId}
 X-Client-Secret: {payment-clientSecret}
 Content-Type: application/json
 {
   "amount": 1,
   "currency": "BRL",
   "tstamp": "2019-05-23T14:02:50Z"
 }

Refund Response:

 {
   "meta": {
     "status": "succeeded",
     "messages": []
   },
   "data": {
      "refund_id": "786653",
      "refunded_amount": 1,
      "status": "refunded"
    }
 }

Capture Mode - Manual

In this mode, we can perform the below operations:

OperationsEndpointsDescription
AuthorizePOST /v2/transactionsCreate a transaction, the capture_mode MUST be manual
CancelPOST /v2/transactions/{authorization_id}/actions/cancelCancel an authorized transaction. The authorization_id is returned by the Authorize operation
CapturePOST /v2/transactions/{authorization_id}/actions/captureCapture an authorized transaction. A Cancelled transaction can't be captured. The authorization_id is returned by the Authorize operation
RefundPOST /v2/transactions/{authorization_id}/actions/refundRefund a captured transaction. The authorization_id is returned by the Captured operation

Step 1: Autorize a transaction

An authorization is requested with an amount in cents of Euros (19€ = 1900 in the request).

The authorization header should be set for this operation.

The field tstamp MUST be set in order to manage idempotency

Request:

 POST /v2/transactions HTTP/1.1
 Host: directpayment.stg.eu.edenred.io
 Authorization: Bearer {token}
 X-Client-Id: {payment-clientId}
 X-Client-Secret: {payment-clientSecret}
 Content-Type: application/json
 {
    "mid": "{{mid}}",
    "order_ref": "89364043",
    "security_level": "standard",
    "amount": 100,
    "capture_mode": "manual",
    "tstamp": "{{tstamp}}"
 }

Response:

{
    "meta": {
        "status": "succeeded",
        "messages": []
    },
    "data": {
        "order_ref": "89364043",
        "mid": "5423945122",
        "authorization_id": "f4416a5e-f7bc-4dbb-9032-ed683ee775f6",
        "authorized_amount": 100,
        "status": "authorized"
    }
}

###

Step 2.1: Cancel an authorized transaction

An authorized payment can be cancelled or captured.

Cancel and capture are for the full amount authorized

The field tstamp MUST be set in order to manage idempotency

Cancel Request:

 POST /v2/transactions/{authorization_id}/actions/cancel HTTP/1.1
 Host: directpayment.stg.eu.edenred.io
 X-Client-Id: {payment-clientId}
 X-Client-Secret: {payment-clientSecret}
 Content-Type: application/json
 {
   "amount": 100,
   "tstamp": "2019-05-21T12:10:12Z"
 }

Cancel Response:

{
    "meta": {
        "status": "succeeded",
        "messages": []
    },
    "data": {
        "mid": "5423945122",
        "cancel_id": "1c38564c-9986-4e69-b5e0-9c36c37f7cb8",
        "cancelled_amount": 100,
        "status": "cancelled"
    }
}

Step 2.2: Capture an authorized transaction

An authorized payment can be cancelled or captured.

Cancel and capture are for the full amount authorized

The field tstamp MUST be set in order to manage idempotency

Capture Request:

 POST /v2/transactions/{authorization_id}/actions/capture HTTP/1.1
 Host: directpayment.stg.eu.edenred.io
 X-Client-Id: {payment-clientId}
 X-Client-Secret: {payment-clientSecret}
 Content-Type: application/json
 {
   "amount": 100,
   "tstamp": "2019-05-21T12:15:29Z"
 }

Capture Response:

{
    "meta": {
        "status": "succeeded",
        "messages": []
    },
    "data": {
        "mid": "5423945122",
        "capture_id": "1c5743c-9986-4e69-b5e0-9c36c37f7cb8",
        "captured_amount": 100,
        "status": "captured"
    }
}

Step 3: Refund a captured transaction

Once captured, a transaction can't be cancelled but have to be refunded.

The capture_mode is mandatory in the case of dual messaging (Authorize and Capture) and must be set to "manual".

The refund can only be performed for the full amount that has been captured

The field tstamp MUST be set in order to manage idempotency

Refund Request:

 POST /v2/transactions/{authorization_id}/actions/refund HTTP/1.1
 Host: directpayment.stg.eu.edenred.io
 X-Client-Id: {payment-clientId}
 X-Client-Secret: {payment-clientSecret}
 Content-Type: application/json
 {
    "amount": 100,
    "capture_mode": "manual",
    "tstamp": "2019-05-21T12:17:53Z"
 }

Refund Response:

{
    "meta": {
        "status": "succeeded",
        "messages": []
    },
    "data": {
        "mid": "5423945122",
        "refund_id": "314f8e0f-6952-4695-91a7-4f0c11f83da6",
        "refunded_amount": 100,
        "status": "refunded"
    }
}

Mapped status codes

Status CodeStatusCodeLevelDescription
200succededSUCCESSSuccessSUCCEEDED
200succededOKSuccessOK
200succededTRANSACTION_OKSuccessOK
200succededAUTHSuccessThe transaction has been authorized.
200succededAUTH_PENDINGSuccessThe transaction authorization is pending.
200succededPARTIAL_AUTHSuccessThe transaction has been partially authorized.
400failedCARD_NOT_FOUNDErrorCard not found
400failedINVALID_INFORMATIONErrorThe provided information is invalid
400failedINVALID_CARDErrorBlocked card
400failedINVALID_MERCHANTErrorMerchant and DocNumber do not match
400failedINVALID_CARD_NUMBERErrorInvalid card serial number
400failedLIMIT_EXCEEDEDErrorThe Amount is invalid
400failedINVALID_MERCHANTErrorThe Merchant is invalid
400failedTRANSACTION_DUPLICATEDErrorThe transaction is duplicated
400failedINSUFFICIENT_FUNDSErrorInsufficient funds
400failedTRANSACTION_LIMIT_EXCEEDEDErrorExceeded the limit of quantity of transactions per day
400failedCARD_NOT_FOUNDErrorCard not found
400failedTRANSACTION_NOT_FOUNDErrorThe transaction is not found
400failedPARTIAL_REVERSALS_NOT_ALLOWEDErrorThe partial reversal is not allowed
400failedINVALID_CURRENCY_CODEErrorThe currency must be ISO 4217
400failedINVALID_CAPTURE_MODEErrorThe property Capture_Mode must contains (auto / manual)
400failedBAD_REQUESTErrorThe property CardNumberID is required
400failedINVALID_TOKENErrorThe token is not valid
400failedONLINE_TRANSACTIONS_DISABLEDErrorOnline transactions for the card provided is disabled
400failedCARD_NOT_ACTIVATEDErrorThe card status is different from active. The transaction can't be processed with the given default card
400failedBAD_REQUESTErrorThe input doesn't respect the contract expected (required fields, type, etc.)
400failedEMPTY_AUTHORIZATION_TOKENErrorUnable to retrieve the OpenId token from the request. Please verify your request and, if required, contact the API administrator for assistance.
400failedINVALID_SEARCH_PERIODErrorThe search period is longer than 3 months.
400failedBAD_REQUESTErrorThe server cannot or will not process the request due to an apparent client error. Check messages field for more details.
400failedDECLINEDErrorTransaction declined.
400failedINVALID_REQUESTErrorThe configuration allows only single/dual messaging requests.
400failedCARD_NOT_ACTIVEErrorNo active card found for the username.
400failedINVALID_AMOUNTErrorInsufficient funds or amount too small/big.
400failedINVALID_MERCHANTErrorThe merchant is not valid, please check the given mid.
400failedINVALID_VOUCHERErrorVoucher not valid.
400failedLIMIT_EXCEEDEDErrorThe amount is incorrect according your past orders.
400failedLOCKOUTErrorMax PIN tries exceeded.
400failedPARTIAL_REVERSALS_NOT_ALLOWEDErrorPartial refunds are not allowed.
400failedTEMPORARY_HOLDErrorTransaction temprorary hold.
400failedTRANSACTION_DUPLICATEDErrorA same transaction already exists.
400failedTRANSACTION_NOT_AUTHORISEDErrorThe transaction has not been authorized.
400failedTRANSACTION_STATUS_MUST_BE_AUTHORIZEDErrorInvalid operation, the status of the transaction must be authorized
400failedINVALID_AMOUNTErrorEnsure that the amount you want to cancel matches the authorized amount.
400failedTRANSACTION_NOT_AUTHORISEDErrorTransaction not authorised.
400failedTRANSACTION_STATUS_MUST_BE_CAPTUREDErrorInvalid operation, the status of the transaction must be captured
401failedUNAUTHORIZEDErrorUnauthorized User
401failedINVALID_TOKENErrorInvalid, revoked or expired token. You should try to re-authenticate the user.
401failedUNAUTHORIZEDErrorMissing, invalid or expired token. To fix, you should re-authenticate the user.
401failedUSER_INACTIVEErrorUser Inactive.
401failedINVALID_TOKEN_ISSUERErrorThe token has not been issued (tokenUsername) for the current user (username)
403failedENDPOINT_SUSPENDEDErrorCurrently this endpoint is suspended
403failedFORBIDDENErrorBad OAuth request (wrong consumer key, bad nonce, expired timestamp...)
403failedFORBIDDENErrorThe request was valid, but the server is refusing action. The user might not have the necessary permissions for this resource.
404failedTRANSACTION_NOT_FOUNDErrorNo transaction found for the given transaction_id.
404failedORIGIN_TRANSACTION_ID_NOT_FOUNDErrorThe origin transaction_id is not found.
404failedNOT_FOUNDErrorIf no transaction is linked to the transaction_id given as input.
405failedMETHOD_NOT_ALLOWEDErrorA request was made of a resource using a request method not supported by that resource; for example, using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource.
405failedMETHOD_NOT_ALLOWEDErrorA request was made of a resource using a request method not supported by that resource.
406failedNOT_ACCEPTABLEErrorThe requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.
412failedPRECONDITION_FAILEDErrorOne of the user data is not valid to process the given request
412failedPRECONDITION_FAILEDErrorA business precondition has not been; for example, the user has no active cards.
412failedPRECONDITION_FAILEDErrorA business precondition has not been.
415failedUNSUPPORTED_MEDIA_TYPEErrorThe request entity has a media type which the server or resource does not support.
429failedTOO_MANY_REQUESTErrorYour request has been rejected due to rate limitation. Please check your subscribed service level agreement.
500failedINTERNAL_ERRORErrorInternal server error
500failedINTERNAL_ERRORErrorWe had a problem with our server. Please to try again later.
500failedTRANSACTION_MUST_BE_AUTHORIZEDErrorInvalid operation, the status of the transaction must be authorized
501failedNOT_IMPLEMENTEDErrorThe server either does not recognize the request method, or it lacks the ability to fulfill the request
501failedNOT_IMPLEMENTEDErrorFor the context of the current business unit, this feature is not supported.
502failedTIMEOUTErrorSend timeout
502failedBAD_GATEWAYErrorOups... Something wrong on one of the underlying servers! Please contact the administrator to report the issue
502failedBAD_GATEWAYErrorWe had a problem with one of our backends that returns a http 500 status. Please to try again later.
503failedSERVICE_UNAVAILABLEErrorOups... Something wrong on one of the underlying servers! Please contact the administrator to report the issue
503failedCONNECTIVITYErrorIndicates that there was a problem establishing a connection
504failedGATEWAY_TIMEOUTErrorThe server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request.

Reviews