Guide d'intégration (mode expert)
1. Initier une demande d'authentification du porteur
Appelez le Web Service PCI/Charge/Authenticate en utilisant les champs ci-dessous :
NOM | DESCRIPTION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
amount | entier | Longueur : 1-12 | requis Montant de la transaction exprimé dans la plus petite fraction de la devise (par exemple : 30050 pour 30050 XPF). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
currency | chaine | Longueur : 3 | requis Code de la devise selon la norme ISO 4217 alpha-3 (par exemple : "XPF" pour le franc CFP). Valeurs possibles
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
productType | énumération | optionnel Type de produit concerné par la transaction. Valeurs possibles
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
transactionCategory | énumération | requis Catégorie de la transaction. Doit être valorisé à PAYMENT . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
transactionInitiator | énumération | optionnel Initiateur de la transaction. Doit être valorisé à CUSTOMER . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
paymentSource | énumération | optionnel Source du paiement. Doit être valorisé à EC . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
customer | objet JSON | recommandé Objet contenant les informations sur l'acheteur. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
device | objet JSON | requis Objet contenant les informations sur le navigateur. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
paymentForm | objet JSON | requis Objet contenant les données de la carte. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
protocolRequest | objet JSON | requis Objet contenant les informations sur le protocole d'authentification. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
merchant | objet JSON | requis Objet contenant les informations sur le contrat. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
recurring | objet JSON | optionnel Objet contenant les informations sur l'abonnement. Détails de l'objet
|
Retrouvez la description des champs dans notre playground : PCI/Charge/Authenticate.
Exemple de requête
{ "amount": 1230, "currency": "XPF", "transactionCategory": "PAYMENT", "productType": "GOODS_OR_SERVICE_PURCHASE", "merchant": { "mid": "1234567" }, "paymentForm":{ "cardHolderName": "John Doe", "pan": "4970110000000013", "expiryMonth": "02", "expiryYear": "24", "networkPreference": "VISA" }, "customer": { "email": "sample@example.com" }, "device": { "deviceType": "BROWSER", "acceptHeader": "application/json", "ip": "89.249.65.28", "javaEnabled": true, "language": "en", "colorDepth": "1", "screenHeight": 1024, "screenWidth": 768, "timeZoneOffset": 0, "userAgent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0" }, "protocolRequest": { "name": "THREEDS", "version": "2", "challengePreference": "NO_PREFERENCE" } }
/** * I initialize the PHP SDK */ require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/keys.php'; require_once __DIR__ . '/helpers.php'; /** * Initialize the SDK * see keys.php */ $client = new Lyra\Client(); /** * I create a formToken */ $store = array("amount" => 250, "currency" => "EUR", "orderId" => uniqid("MyOrderId"), "customer" => array( "email" => "sample@example.com" )); $response = $client->post("V4/Charge/CreatePayment", $store); /* I check if there are some errors */ if ($response['status'] != 'SUCCESS') { /* an error occurs, I throw an exception */ display_error($response); $error = $response['answer']; throw new Exception("error " . $error['errorCode'] . ": " . $error['errorMessage'] ); } /* everything is fine, I extract the formToken */ $formToken = $response["answer"]["formToken"]; ?>
Exemple de réponse
La suite du processus dépend de l'objet contenu dans la réponse : AuthenticationResponseData :
- Objet
AuthenticationResult
:
- Procédez directement à la demande d'autorisation (pas d'authentification du porteur)
- Exemple, avec une demande de FRICTIONLESS :
{ "webService":"PCI/Charge/Authenticate", "version":"V4", "applicationVersion":"5.23.0", "serverDate":"2021-05-05T09:33:32+00:00", "ticket":"3b68064f80f346919828dee761bd22b5", "applicationProvider":"", "metadata":null, "status":"SUCCESS", "mode":"TEST", "serverUrl":"https://api.secure.osb.pf", "_type":"V4/WebService/Response", "answer":{ "id":"1fec4a93-3208-4602-be55-803261bdbccc", "protocol":{ "name":"THREEDS", "version":"2.1.0", "network":"VISA", "challengePreference":"NO_PREFERENCE", "simulation":true, "_type":"V4/Charge/Authenticate/Protocol" } ,"value":{ "authenticationType":"FRICTIONLESS", "authenticationId":{ "authenticationIdType":"dsTransId", "value":"cd85dd04-4bd8-47e4-b42a-708ded17b3cf", "_type":"V4/Charge/Authenticate/AuthenticationId" }, "authenticationValue":{ "authenticationValueType":"CAVV", "value":"udjlTuaT4fHRNwKRifj1t+Zn/6k=", "_type":"V4/Charge/Authenticate/AuthenticationValue" }, "status":"SUCCESS", "commerceIndicator":"05", "extension":{ "authenticationType":"THREEDS_V2", "threeDSServerTransID":"1fec4a93-3208-4602-be55-803261bdbccc", "dsTransID":"cd85dd04-4bd8-47e4-b42a-708ded17b3cf", "acsTransID":"a11081a6-268f-42bc-8356-0aacf74d2565", "_type":"V4/Charge/Authenticate/AuthenticationResultExtensionThreedsV2" }, "reason":{ "_type":"V4/Charge/Authenticate/AuthenticationResultReason" }, "_type":"V4/Charge/Authenticate/AuthenticationResult" }, "_type":"V4/AuthenticationResponseData" } }
- Objet
AuthenticationInstruction
:
- Procédez à l'authentification du porteur (voir étape 2: Traitement des instructions).
- Exemple, avec une instruction
FINGERPRINT
(3DS Method).
{ "webService":"PCI/Charge/Authenticate", "version":"V4", "applicationVersion":"5.22.0", "serverDate":"2021-05-03T15:02:56+00:00", "ticket":"c295ad67f65341529c1db6760df400fd", "applicationProvider":"", "metadata":null, "status":"SUCCESS", "mode":"TEST", "serverUrl":"https://api.secure.osb.pf", "_type":"V4/WebService/Response", "answer":{ "id":"b5bdf588-df35-4d56-8852-a68bd9c20147", "protocol":{ "name":"THREEDS"," version":"2.1.0", "network":"VISA", "challengePreference":"NO_PREFERENCE", "simulation":true, "_type":"V4/Charge/Authenticate/Protocol" }, "value":{ "instructionType":"FORM", "name":"FINGERPRINT", "timeout":10, "target":{ "element":"IFRAME", "visible":false, "_type":"V4/Charge/Authenticate/InstructionTarget" }, "http":{ "method":"POST", "url":"<https://acs.sg.com/acs/v2/3dsMethod>", "body":{ "threeDSMethodData":"eyJ0aHJlZURzTW..." }, "_type":"V4/Charge/Authenticate/HttpRequest" }, "_type":"V4/Charge/Authenticate/AuthenticationInstruction" }, "_type":"V4/AuthenticationResponseData" } }
2. Traitement des instructions
La réponse à l'appel au service PCI/Charge/Authenticate contient un objet AuthenticationInstruction
:
- si la réponse contient une instruction
CHALLENGE
, vous créez une iFrame **visible** pour afficher la page d'authentification. - si la réponse contient une instruction
FINGERPRINT
, vous créez une iFrame **invisible** pour afficher la page d'exécution du code JavaScript de l'ACS.
2.1. Création de l'iFrame
Quel que soit le type d'instruction reçue (CHALLENGE
ou FINGERPRINT
), vous devez construire une iFrame en utilisant les données reçues dans l'objet target
.
Exemples de données transmises en fonction du type d'instruction
Instruction "CHALLENGE" | "target":{ "element":"IFRAME", "visible":true, "width":500, "height":600, "_type":"V4/Charge/Authenticate/InstructionTarget" } |
Instruction "FINGERPRINT" (3DS Method) | "target":{ "element":"IFRAME", "visible":false, "_type":"V4/Charge/Authenticate/InstructionTarget" } |
2.2. Soumission du formulaire de demande d'authentification
Une fois l'iFrame créée, utilisez les données reçues dans l'objet http
pour permettre :
- soit l'affichage de la page d'authentification de l'émetteur du moyen de paiement, pour une instruction de type
CHALLENGE
, - soit l'exécution du code JavaScript de l'ACS de l'émetteur de moyen de paiement, pour une instruction de type
FINGERPRINT
.
Exemples de données transmises dans l'objet http :
Challenge 3DS2 | "http":{ "method":"POST", "url":"https://acs.sg.com/v2/creq", "body":{ "creq":"eyJ0aHJlZURTU2Vy...", "threeDSSessionData":"H4sIAAAAAAAAAC2OyZK..." }, "_type":"V4/Charge/Authenticate/HttpRequest" }, |
Fingerprint | "http":{ "method":"POST", "url":"https://acs.sg.com/v2/3dsMethod", "body":{ "threeDSMethodData":"eyJ0aHJlZURzTW..." }, "_type":"V4/Charge/Authenticate/HttpRequest" }, |
Exemple d'implémentation JavaScript
function createInstructionIframe(instruction) { // Get instruction container element container = document.getElementById('instructionContainer'); // Clean instruction container container.innerHTML = ''; // Create iframe element var iframe = document.createElement('iframe'); iframe.id = 'instructionIframe'; iframe.name = 'instructionIframe'; iframe.src = 'about:blank'; iframe.style.width = instruction.value.target.width+"px"; iframe.style.height = instruction.value.target.height+"px"; iframe.style.visibility = instruction.value.target.visible ? 'visible' : 'hidden'; // Handle timeout if(instruction.value.timeout){ setTimeout(() => { const instructionResultTimeout = { eventName: 'LYRA_AUTH_INSTRUCTION_RESULT', value: { name: instruction.value.name, value: 'TIMEOUT', protocol: { name: instruction.protocol.name, version: instruction.protocol.version, network: instruction.protocol.network, challengePreference: instruction.protocol.challengePreference, simulation: instruction.protocol.simulation }, }, }; window.postMessage(JSON.stringify(instructionResultTimeout), '*'); }, instruction.value.timeout * 1000); } // Add iframe to container container.appendChild(iframe); // Create form to post var form = document.createElement('form'); form.id = 'instructionForm'; form.name = 'instructionForm'; form.target = 'instructionIframe'; form.method = instruction.value.http.method; form.action = instruction.value.http.url; form.style = 'visibility: hidden'; // Create form body Object.keys(instruction.value.http.body).forEach(function (name) { form.innerHTML += '<input name="' + name + '" value="' + instruction.value.http.body[name] + '">'; }); var body = document.createElement('form'); // Add form to container container.appendChild(form); // Triger form submit form.submit(); }
Exemple d'appel de la fonction createInstructionIframe en PHP
//Call the charge/Authenticate method
$obj = authenticate($data);
if ($obj['answer']['_type']== 'V4/AuthenticationResponseData'){
$response= $obj['answer'];
//Test if anwser contains an instruction
if($response['value']['_type'] == 'V4/Charge/Authenticate/AuthenticationInstruction'){
$_SESSION['RequestParams']= $param_request;
$_SESSION['requestId'] = $response['id'];
//create an iFrame to proceed to the payer authentication
echo '<script>window.onload = function(){ var instruction =JSON.parse(\''. json_encode($response) .'\'); createInstructionIframe(instruction);}</script>';
}
}
3. Mise en place d'un listener d'événement
Après authentification du porteur du moyen de paiement ou après exécution du 3DS Method, le navigateur du client transmet une réponse sous forme d'événement JavaScript.
Utilisez le code suivant pour capter l'événement :
window.addEventListener('message', function (messageEvent) { var data = messageEvent.data; try { var messageData = JSON.parse(data); if (messageData.eventName === 'LYRA_AUTH_INSTRUCTION_RESULT') { try { // callback call with messageData.value content container = document.getElementById('instructionContainer'); var form = document.createElement('form'); form.method = 'POST'; form.action = "https://myhost.com/payment/authentication/result.php"; form.style = 'visibility: hidden'; form.innerHTML += "<input name='messageData' value='" + data + "'>"; var body = document.createElement('form'); container.appendChild(form); form.submit(); } catch (err) { // error callback call } finally { // always close the iFrame/popin container = document.getElementById('instructionContainer'); container.remove(); } } } catch (err) { // process eventual exceptions during callbacks } }, false);
Exemples d'événements "LYRA_AUTH_INSTRUCTION_RESULT"
après une authentification Challenge 3DS2 |
|
après exécution du code 3DS Method de l'ACS (authentification 3DS2) |
|
en cas de timeout durant un challenge (3DS2) |
|
4. Gestion des événements "LYRA_AUTH_INSTRUCTION_RESULT"
Lorsqu'un événement LYRA_AUTH_INSTRUCTION_RESULT
est reçu, appelez le Web Service PCI/Charge/Authenticate afin de décoder son contenu.
Utilisez les champs suivants dans votre requête :
NOM | DESCRIPTION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
amount | entier | Longueur : 1-12 | requis Montant de la transaction exprimé dans la plus petite fraction de la devise (par exemple : 30050 pour 30050 XPF). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
currency | chaine | Longueur : 3 | requis Code de la devise selon la norme ISO 4217 alpha-3 (par exemple : "XPF" pour le franc CFP). Valeurs possibles
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
productType | énumération | optionnel Type de produit concerné par la transaction. Valeurs possibles
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
transactionCategory | énumération | requis Catégorie de la transaction. Doit être valorisé à PAYMENT . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
customer | objet JSON | recommandé Objet contenant les données de l'acheteur. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
device | objet JSON | requis Objet décrivant les informations sur le navigateur. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
paymentForm | objet JSON | requis Objet contenant les données de la carte. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
protocolRequest | objet JSON | requis Objet décrivant le mode d'authentification souhaité. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
merchant | objet JSON | requis Objet contenant les informations sur le contrat. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
recurring | objet JSON | optionnel Objet contenant les informations sur l'abonnement. Détails de l'objet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | chaine | Longueur : 36 | requis Identifiant de la requête d'authentification fourni dans la réponse à l'appel initial. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
instructionResult | objet JSON | requis Objet contenant le détail de l'instruction reçu dans l'événement JavaScript LYRA_AUTH_INSTRUCTION_RESULT . |
Exemple de requête
{ "amount": 1230, "currency": "XPF", "transactionCategory": "PAYMENT", "productType": "GOODS_OR_SERVICE_PURCHASE", "merchant": { "mid": "1234567" }, "paymentForm":{ "pan": "4970110000000013", "expiryMonth": "02", "expiryYear": "24", "networkPreference": "VISA" }, "device": { "deviceType": "BROWSER", "acceptHeader": "application/json", "ip": "89.249.65.28", "javaEnabled": true, "language": "en", "colorDepth": "1", "screenHeight": 1024, "screenWidth": 768, "timeZoneOffset": 0, "userAgent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0" }, "protocolRequest": { "name": "THREEDS", "version": "2", "challengePreference": "NO_PREFERENCE" }, "id": "c82794e9-9c20-44a8-9297-b70e1e7c4006", "instructionResult": { "name" : "CHALLENGE", "protocol" : { "name" : "THREEDS", "version" : "1.0.2", "network" : "VISA", "challengePreference": "NO_PREFERENCE", "simulation": false }, "value": "eyJhbGciOiJIUz..." } }
/** * I initialize the PHP SDK */ require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/keys.php'; require_once __DIR__ . '/helpers.php'; /** * Initialize the SDK * see keys.php */ $client = new Lyra\Client(); /** * I create a formToken */ $store = array("amount" => 250, "currency" => "EUR", "orderId" => uniqid("MyOrderId"), "customer" => array( "email" => "sample@example.com" )); $response = $client->post("V4/Charge/CreatePayment", $store); /* I check if there are some errors */ if ($response['status'] != 'SUCCESS') { /* an error occurs, I throw an exception */ display_error($response); $error = $response['answer']; throw new Exception("error " . $error['errorCode'] . ": " . $error['errorMessage'] ); } /* everything is fine, I extract the formToken */ $formToken = $response["answer"]["formToken"]; ?>
AuthenticationInstruction
dans la
réponse :
* La réponse contient un objet AuthenticationInstruction
: vous devez traiter l'instruction pour continuer le processus d'authentification du porteur.
* La réponse contient un objet Payment
: le procesus est terminé.
5. Analyse du résultat de l'authentification
Le processus d'authentification est terminé. La réponse contient les données nécessaires pour procéder à la demande d'autorisation.
Ci-dessous quelques exemples de données retournées après l'authentification du porteur :
Authentification Frictionless 3DS2 (avec ou sans 3DS Method) | ```json "answer":{ "id":"3b25e3ed-5d48-4f99-af61-0d5db9e3b18e", "protocol":{ "name":"THREEDS", "version":"2.1.0", "network":"VISA", "challengePreference":"NO_PREFERENCE", "simulation":true, "_type":"V4/Charge/Authenticate/Protocol" }, "value":{ "authenticationType":"FRICTIONLESS", "authenticationId":{ "authenticationIdType":"dsTransId", "value":"18e46ff7-b882-4102-9af4-aef9f40ee6a6", "_type":"V4/Charge/Authenticate/AuthenticationId" }, "authenticationValue":{ "authenticationValueType":"CAVV", "value":"PdY1V9f/aHxC2wbZt4/7Z6Q9f44=", "_type":"V4/Charge/Authenticate/AuthenticationValue" }, "status":"SUCCESS", "commerceIndicator":"05", "extension":{ "authenticationType":"THREEDS_V2", "threeDSServerTransID":"3b25e3ed-5d48-4f99-af61-0d5db9e3b18e", "dsTransID":"18e46ff7-b882-4102-9af4-aef9f40ee6a6", "acsTransID":"410d9fb4-8db1-483e-9a80-f94c3a79017e", "_type":"V4/Charge/Authenticate/AuthenticationResultExtensionThreedsV2" }, "reason":{ "_type":"V4/Charge/Authenticate/AuthenticationResultReason" }, "_type":"V4/Charge/Authenticate/AuthenticationResult" }, "_type":"V4/AuthenticationResponseData" } ``` |
Authentification challenge 3DS2 réussie |
|
Authentification challenge 3DS2 en échec |
|
Authentification challenge 3DS2 en timeout |
|
Erreur technique |
|
Authentification OTP OSB réussie |
|