Edenred Direct Payment Services icon

Edenred Direct Payment Services

(0 reviews)

Use Case: Turkey

1. Generalities

In Turkey, with the Ticket Restaurant Card, a user can spend the amount requested in the limit of the balance available on his account (i.e. balance canโ€™t be negative) and with some daily limitations (to be detailed)

Please note that all amounts in our API are given in cents (example: 100โ‚บ = 10000).

The regulation(s) are handled on the Edenred side.

2. User Security Tokens

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

2.1. Login Process

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

https://sso.sbx.edenred.io/connect/authorize?response_type=code&client_id=989acfb423ba4f9f944f1819da89abe7&scope=openid%20edg-xp-mealdelivery-api%20offline_access&redirect_uri=http://nowhere.edenred.com/callback&state=abc123&nonce=456azerty&acr_values=tenant:tr-ben&ui_locales=tr

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

  Username: edps@edps.com
  Password: 258067
  OTP: 123456
Login Page

At this step, provide the username and password of the user's account

Verify OTP code

At this step, enter the OTP

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 :

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

'authentication-URL' = https://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

3. Direct Payment API

If you use the postman collection, the access_token will automatically be placed in your HTTP. The postman configuration available here is set in auto-clearing mode. Manual clearing mode is not supported.

Run in Postman

Token Management:

OperationsEndpointsDescription
Get Refresh_token from authorization codePOST /connect/tokenGet a new set of tokens
Get access_token from refresh tokenPOST /connect/tokenRefresh the access token

Users Management:

OperationsEndpointsDescription
Get BalancesGET /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 (+ Capture)POST /v2/transactionsAuthorize and Capture in one call
RefundNot supported in the local backend-

3.1. Get Balances

Use the Get balances to get all the available user vouchers including the full sum of their values.

The Authorization header is mandatory for this request.

Please keep in mind that for {{username}} parameter, you need to retrieve the information provided in the id_token via an introspection (the data to retrieve is an ID which corresponds to an encrypted token).

Request:

 GET /v2/users/{{username}}/balances 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": 46969,
    "product_class": "ETR",
    "currency": "TRY"
  }
}

3.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}}
 Content-Type: application/json
 X-Client-Id: {{payment-clientId}}
 X-Client-Secret: {{payment-clientSecret}}

Response:

{
    "meta": {
        "status": "succeeded",
        "messages": []
    },
    "data": {
        "available_amount": 2300,
        "currency": "TRY"
    }
}

3.3. Authorize a payment

A transaction can only be processed via auto-capture mode (authorization and capture are done in the same call)

The amount must be provided in cents.

The authorization header is mandatory for this operation.

Please be advised that the order_ref field should be incremented with every request and it should contain only numbers and should be inferior to 2 147 483 647, not characters. The tstamp should be the current date and current hour of the request. (YYYY-MM-DD and hh:mm should be the same as the Turkish one, so in GMT+3).

The extra_field is composed of BatchNo|ServiceId|TerminalNo|TransactionSource|Hash.

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": "17",
    "amount": 1,
    "security_level": "standard",
    "capture_mode": "auto",
    "order_ref": "1229192039",
    "tstamp": "2021-03-12T15:30:54Z",
    "currency": "TRY",
    "extra_field": "1000|300051|17|WCE6nGxCKdxtCR(|af8f3b39552a6eed90fe0e6a824fe48acd4d4f6cc559c117af64b4e8443394d4"
}

Response:

{
    "meta": {
        "status": "succeeded"
    },
    "data": {
        "mid": "17",
        "status": "captured",
        "authorization_id": "1229192039",
        "authorized_amount": 1,
        "capture_id": "1229192039",
        "captured_amount": 1
    }
}

3.3. Refund a transaction

This process is not supported on the local back-end

Mapped status codes

Status CodeStatusCodeLevelDescription
200succededSUCCESSSuccessSUCCEEDED
200succededOKSuccessOK
200succededAUTHSuccessThe transaction has been authorized.
200succededAUTH_PENDINGSuccessThe transaction authorization is pending.
200succededPARTIAL_AUTHSuccessThe transaction has been partially authorized.
400failedBAD_REQUESTErrorSYSTEM ERROR 1
400failedBAD_REQUESTErrorSYSTEM ERROR 2
400failedMEMBER_WORKPLACE_NOT_FOUNDErrorMEMBER WORKPLACE NOT FOUND
400failedMEMBER_WORKPLACE_CANNOT_BE_EMPTYErrorMEMBER WORKPLACE CANNOT BE EMPTY
400failedMEMBER_PRODUCT_LIST_NOT_FOUNDErrorMEMBER PRODUCT LIST NOT FOUND
400failedTERMINAL_NOT_FOUNDErrorTERMINAL NOT FOUND
400failedTERMINAL_NO_CANNOT_BE_BLANKErrorTERMINAL NO CANNOT BE BLANK
400failedTERMINAL_PRODUCT_LIST_NOT_FOUNDErrorTERMINAL PRODUCT LIST NOT FOUND
400failedDEVICE_SERIAL_NUMBER_ERRORErrorDEVICE SERIAL NUMBER ERROR
400failedTERMINAL_NOT_ACTIVEErrorTERMINAL NOT ACTIVE
400failedTERMINAL_HANGINGErrorTERMINAL HANGING
400failedTERMINAL_NON_CONTACT_PROCESS_NOT_FOUNDErrorTERMINAL NON-CONTACT PROCESS. NOT FOUND
400failedTERMINAL_WORK_PRM_NOT_FOUNDErrorTERMINAL WORK PRM. NOT FOUND
400failedSERVICE_LIST_NOT_FOUNDErrorSERVICE LIST NOT FOUND
400failedNOT_DEFINED_FOR_SERVICE_TERMINALErrorNOT DEFINED FOR SERVICE TERMINAL
400failedNO_SALES_PERMISSIONS_FOR_TERMINAL_AND_SERVICEErrorNO SALES PERMISSIONS FOR TERMINAL AND SERVICE
400failedCARD_NOT_FOUNDErrorNO CARD FOUND
400failedCARD_TEMPORARY_BLOCKEDErrorCARD TEMPORARY BLOCKED
400failedCARD_IS_DISABLEDErrorCARD IS DISABLED
400failedEXPIRED_DATE_OF_EXPIREDErrorEXPIRED DATE OF EXPIRED
400failedCARD_PRM_ERROR_DAYSErrorCARD PRM. ERROR (DAYS)
400failedCARD_PRM_FAULT_HOURErrorCARD PRM. FAULT (HOUR)
400failedCARD_CANNOT_BE_USED_AT_THIS_HOURErrorTHE CARD CANNOT BE USED AT THIS HOUR
400failedCARD_PRM_ERRORErrorCARD PRM. ERROR (NUMBER OF DAYS)
400failedCARD_DAILY_OPERATION_NUMBER_EXCEEDEDErrorCARD'S DAILY OPERATION NUMBER EXCEEDED
400failedCARD_PRM_ERRORErrorCARD PRM. ERROR (TRANSACTION AMOUNT)
400failedDAILY_TRANSACTION_AMOUNT_EXCEEDEDErrorDAILY TRANSACTION AMOUNT EXCEEDED
400failedCARD_IS_CLOSED_FOR_SALEErrorTHIS CARD IS CLOSED FOR SALE
400failedCARD_DAILY_TRADING_LIMIT_EXCEEDEDErrorCARD'S DAILY TRADING LIMIT EXCEEDED
400failedINADEQUATE_BALANCEErrorINADEQUATE BALANCE
400failedTRANSACTION_FAILEDErrorTRANSACTION FAILED
400failedTRANSACTION_DETAILS_INCOMPATIBLEErrorTRANSACTION DETAILS INCOMPATIBLE
400failedACTION_NOT_FOUNDErrorACTION NOT FOUND
400failedTRY_AGAINErrorTRY AGAIN
400failedNO_PROCESS_THAT_CAN_BE_ROLLBACKEDErrorNO PROCESS THAT CAN BE ROLLBACKED
400failedCANCELLATION_FAILEDErrorCANCELLATION FAILED
400failedCANCELLATION_NOT_AVAILABLEErrorCANCELLATION NOT AVAILABLE
400failedDAILY_TRADING_NUMBER_ERRORErrorDAILY TRADING NUMBER ERROR
400failedTRANSACTION_HAS_NOT_BEEN_APPROVEDErrorTHE TRANSACTION HAS NOT BEEN APPROVED
400failedTERMINAL_TIME_ERRORErrorTERMINAL TIME ERROR, INSTALL PARAMETER
400failedREPEATING_REQUESTErrorREPEATING REQUEST
400failedTERMINAL_MUST_DO_AT_THE_END_OF_THE_DAYErrorTERMINAL MUST DO AT THE END OF THE DAY
400failedSALES_CANNOT_BE_CANCELLEDErrorSALES CANNOT BE CANCELLED
400failedSALES_CANNOT_BE_APPROVEDErrorSALES CANNOT BE APPROVED
400failedSALES_ALREADY_APPROVEDErrorSALES ALREADY APPROVED
400failedINVALID_SALE_REQUESTErrorINVALID SALE REQUEST
400failedCARD_CONTACT_OFF_FOR_SALEErrorCARD CONTACT OFF FOR SALE
400failedCONTACTLESS_SALES_AMOUNT_EXCEEDEDErrorCONTACTLESS SALES AMOUNT EXCEEDED
400failedCONTACTLESS_SALES_PERMISSION_HAS_BEEN_EXCEEDEDErrorCONTACTLESS SALES PERMISSION HAS BEEN EXCEEDED
400failedINVALID_VERIFICATION_CODEErrorThe verification code is invalid or expired
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)
401failedINVALID_TOKEN_ISSUERErrorThe token has been issued for different user.
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_NOT_AVAILABLE_TODAYErrorCARD IS NOT AVAILABLE TODAY
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_GATEWAYErrorWe had a problem with one of our backends that returns a http 500 status. Please to try again later.

Reviews