Edenred Direct Payment Services icon

Edenred Direct Payment Services

(0 reviews)

Use Case: France

I. Generalities

In France, a user can spend the exact amount requested up to 19€ per day, i.e. he can’t spend more than 19€ in a given day (or 38 euros in some cases).

These regulations are handled on the Edenred side.

Please note that all amounts in our API are given in cents (9€ = 900)

II. Login Process

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=bf79413250f449948ce12b98b08e3fc0&scope=openid%20edg-xp-mealdelivery-api%20offline_access&redirect_uri=http://nowhere.edenred.net/oauth/callback&state=abc123&nonce=456azerty&acr_values=tenant%3Afr-ctrtku&ui_locales=fr

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

Account: lerouxpablo@yopmail.com
Password: Edenred2021*
Masked PAN : 4475

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

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

3) Copy the authorization_code and paste it in the body of the request "Get Token by authorization_code" (in the "code" parameter) in the following collection of API calls (Please note the environment is set up in capture mode auto) :

Run in Postman

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 by requesting the user to follow the authentication flow again.

2.2. Logout Process

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

'xp-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/oauth/callback

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.

II.1. Get Balance

Get the available amount to spend available on the user account. This amount is the one available at the given moment to manage a payment

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": 1900,
   "currency": "EUR"
    }
}

II.2. 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": 1800,
        "currency": "EUR"
    }
}

II.3. Transactions

EDPS manages two kinds of transaction mode, auto and manual. The postman collection is set up in capture mode auto. If you want to test an environment in capture mode manual, please request a dedicated environment.

In the next sections, we will explain the difference between those two modes.

II.3.1. Capture Mode - Auto

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
II.3.1.1. Authorize & Capture a payment

An auto capture 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
 {
  "order_ref": "order-001",
  "mid": "1999224",
  "amount": 1,
  "capture_mode": "auto",
  "extra_field": "order-fr-001",
  "tstamp": "2018-08-31T14:22:00Z"
 }

Response:

{
    "meta": {
        "status": "succeeded"
    },
    "data": {
        "order_ref": "order-fr-002",
        "mid": "1999224",
        "status": "captured",
        "authorization_id": "MTU5MjM3NjcyNzE5OTkyMjQ4MDAwM-642338",
        "authorized_amount": 1,
        "capture_id": "MTU5MjM3NjcyNzE5OTkyMjQ4MDAwM-642338",
        "captured_amount": 1
    }
}
II.3.1.2. Refund a Captured payment

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

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

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": 1,
   "capture_mode": "auto",
   "tstamp": "2019-05-21T14:04:00Z"
 }

Refund Response:

{
    "meta": {
        "status": "succeeded"
    },
    "data": {
        "mid": "1999224",
        "status": "refunded",
        "refund_id": "MTU5MjM3NjcyNzE5OTkyMjQ4MDAwM",
        "refunded_amount": 1,
        "order_ref": "order-fr-002",
        "authorization_id": "MTU5MjM3NjcyNzE5OTkyMjQ4MDAwM-642338",
        "authorized_amount": 1,
        "capture_id": "MTU5MjM3NjcyNzE5OTkyMjQ4MDAwM-642338",
        "captured_amount": 1
    }
}

II.3.2. 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
II.3.2.1. Authorize a payment

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
  {
    "order_ref": "order-fr-001",
    "mid": "1999224",
    "amount": 1,
    "currency": "EUR"
    "capture_mode": "manual",
    "extra_field": "order-fr-001",
    "tstamp": "2019-05-27T10:02:50Z"
 }

Response:

{
    "meta": {
        "status": "succeeded"
    },
    "data": {
        "order_ref": "order-fr-001",
        "mid": "1999224",
        "status": "authorized",
        "authorization_id": "MTU5MjMyMzI2NzE5OTkyMjQ4MDAwM-199570",
        "authorized_amount": 1
    }
}
II.3.2.2. Cancel OR Capture a payment

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": 1,
   "tstamp": "2019-05-21T12:10:12Z"
 }

Cancel Response:

{
    "meta": {
        "status": "succeeded"
    },
    "data": {
        "mid": "1999224",
        "status": "cancelled",
        "cancel_id": "MTU4ODY2MzI0NTE5OTkyMjQ4MDAwM",
        "cancelled_amount": 1,
        "order_ref": "order-fr-001",
        "authorization_id": "MTU5MjMyMzI2NzE5OTkyMjQ4MDAwM-199570",
        "authorized_amount": 1
    }
}

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": 1,
   "tstamp": "2019-05-21T12:15:29Z"
 }

Capture Response:

{
  "meta": {
     "status": "succeeded",
     "messages": []
  },
  "data": {
      "order_ref": "order-fr-001",
      "mid": "1999224",
      "capture_id": "MTU5MjM3NTg1MjE5OTkyMjQ4MDAwM-520011",
      "capture_amount": 1,
      "status": "captured",
      "authorization_id": "MTU5MjM3NTg1MjE5OTkyMjQ4MDAwM-520011",
      "authorized_amount": 1
    }
}
II.3.2.3. Refund a captured payment

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": 1,
    "capture_mode": "manual",
    "tstamp": "2019-05-21T12:17:53Z"
 }

Refund Response:

{
    "meta": {
        "status": "succeeded"
    },
    "data": {
        "mid": "1999224",
        "status": "refunded",
        "refund_id": "MTU4ODY2MzI0NTE5OTkyMjQ4MDAwM-520011",
        "refunded_amount": 1,
        "order_ref": "order-fr-001",
        "capture_id": "MTU5MjM3NTg1MjE5OTkyMjQ4MDAwM-520011",
        "capture_amount": 1,
        "authorization_id": "MTU5MjM3NTg1MjE5OTkyMjQ4MDAwM-520011",
        "authorized_amount": 1
    }
}

IV Error Codes

Status CodeStatusCodeLevelDescription
200succededOKSuccessOK
200succededAUTHSuccessThe transaction has been authorized.
200succededAUTH_PENDINGSuccessThe transaction authorization is pending.
200succededPARTIAL_AUTHSuccessThe transaction has been partially authorized.
400failedINVALID_EMAILErrorEmail is already in use by another user.
400failedINVALID_CARDErrorInvalid card information provided
400failedINVALID_MERCHANTErrorInvalid Merchant
400failedINVALID_AMOUNTErrorInvalid Amount
400failedINVALID_AMOUNTErrorINSUFFICIENT FUNDS
400failedTRANSACTION_DUPLICATEDErrorTransaction Duplicated
400failedDECLINEDErrorDeclined
400failedLIMIT_EXCEEDEDErrorLimit exceeded
400failedPARTIAL_REVERSALS_NOT_ALLOWEDErrorPartial resversals not allowed
400failedTRANSACTION_NOT_AUTHORISEDErrorTransaction not authorised
400failedTEMPORARY_HOLDErrorTemporary hold
400failedINVALID_VOUCHERErrorInvalid Voucher
400failedLOCKOUTErrorlockout
400failedINCORRECT_PINErrorIncorrect PIN
400failedPARTIAL_AUTH_NOT_SUPPORTEDErrorPartial authorization not supported
400failedINVALID_CARDErrorInvalid card
400failedCARD_NOT_ACTIVATEDErrorCard is not activated
400failedACCOUNT_BLOCKEDErrorAccount blocked
400failedCARD_BLOCKEDErrorCard blocked
400failedINVALID_ACCOUNTErrorInvalid account
400failedCARD_ALREADY_ACTIVATEDErrorCard is already activated
400failedINVALID_CURRENCY_CODEErrorInvalid currency
400failedINVALID_TRANSACTION_TYPEErrorInvalid transaction type
400failedINVALID_CAPTURE_MODEErrorYou are not allowed to capture transaction
400failedTOPTP_VALIDATION_FAILEDErrortoptp validation failed
400failedCARD_NOT_FOUNDErrorCard not found
400failedNO_ACTIVE_CARDErrorNo Active Card found
400failedACCOUNT_NOT_FOUNDErrorAccount not found
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
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)
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_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.
500failedCARD_TEMPORARILY_BLOCKEDErrorThis card is temporarily blocked
500failedINTERNAL_ERRORErrorInternal Server Error
500failedCARD_EXPIREDErrorCard expired
500failedINTERNAL_ERRORErrorInvalid Message :Field: [value.amt] must be numeric
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_IMPLEMENTEDErrorFor the context of the current business unit, this feature is not supported.
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.

Reviews