• France
status page
demonstrations
assistance
FAQContact support
Search
Categories
Tags
English
French
English
Homepage
Use cases
Create a payment
Create an installment payment
Create a multi-card (split) payment
Create a payment by Alias (Token)
Create a payment link
Create a recurring payment
Manage subscriptions
Manage your transactions (refund, cancel...)
Analyze your reports
API docs
Embedded Form
REST API
Hosted payment
Mobile payment
File exchange
Snippets
Payment methods
Plugins
Guides
Merchant Back Office
Functional guides

Example files: ipn.php and paid.php

1. ipn.php

This file allows you to analyze the payment result using the IPN.

It is used for:

  1. vérifier la signature avec le mot de passe (qui commence par testpasswordou prodpassword) pour comparer avec la valeur du kr-hash. (2 ème clé du tableau des clés API REST ).

  2. retrieve information from the kr-answer response (status, order number, unique UUID number ...)

https://github.com/lyra/rest-php-examples/blob/master/www/sample/ipn.php
<?php

   include_once 'config.php';

   

   // STEP 1 : check the signature with the password

   if (!checkHash($_POST, PASSWORD)) {

       echo 'Invalid signature. <br />';

       print_r($_POST, true);

       die();

   }

   

   $answer = array();

   $answer['kr-hash'] = $_POST['kr-hash'];

   $answer['kr-hash-algorithm'] = $_POST['kr-hash-algorithm'];

   $answer['kr-answer-type'] = $_POST['kr-answer-type'];

   $answer['kr-answer'] = json_decode($_POST['kr-answer'], true);

           

   function checkHash($data, $key)

   {

       $supported_sign_algos = array('sha256_hmac');

       if (!in_array($data['kr-hash-algorithm'], $supported_sign_algos)) {

           return false;

       }

       $kr_answer = str_replace('\/', '/', $data['kr-answer']);

       $hash = hash_hmac('sha256', $kr_answer, $key);

       return ($hash == $data['kr-hash']);

   }

   

   /* STEP 2 : get some parameters from the answer */

   $orderStatus = $answer['kr-answer'] ['orderStatus'];

   $orderId = $answer['kr-answer']['orderDetails']['orderId'];

   $transactionUuid = $answer['kr-answer']['transactions'][0]['uuid'] ;

   

   /* I update my database if needed */

   /* Add here your custom code */ 

   

   /**

    * Message returned to the IPN caller

    * You can return want you want but

    * HTTP response code should be 200

    */

   print 'OK! OrderStatus is ' . $orderStatus;

   ?>

2. paid.php

Ce fichier permet d'analyser le résultat du paiement lors du retour à la boutique.

It is used for:

  1. vérifier de la signature avec la Clé HMAC-SHA-256 pour comparer avec la valeur du kr-hash. (4 ème clé du tableau des clés API REST ).

  2. retrieve information from the kr-answer response (status, order number, unique UUID number ...)

https://github.com/lyra/rest-php-examples/blob/master/www/sample/paid.php
<?php



include_once 'config.php';



// STEP 1 : check the signature with the SHA_KEY on the file config.php

if (!checkHash($_POST, SHA_KEY)) {

   echo 'Invalid signature. <br />';

   die();

}



$answer = array();

$answer['kr-hash'] = $_POST['kr-hash'];

$answer['kr-hash-algorithm'] = $_POST['kr-hash-algorithm'];

$answer['kr-answer-type'] = $_POST['kr-answer-type'];

$answer['kr-answer'] = json_decode($_POST['kr-answer'], true);



function checkHash($data, $key)

{

   $supported_sign_algos = array('sha256_hmac');



   if (!in_array($data['kr-hash-algorithm'], $supported_sign_algos)) {



      return false;

   }



   $kr_answer = str_replace('\/', '/', $data['kr-answer']);

   $hash = hash_hmac('sha256', $kr_answer, $key);



   return ($hash == $data['kr-hash']);

}

?>



<html>



<head>

   <meta http-equiv="Pragma" content="no-cache">

   <meta http-equiv="Expires" content="-1">

   <title>Successful payment</title>

</head>



<body>

   <div class="container">

      <h2>Data recevied :</h2>

      <!-- STEP 2 : get some parameters from the 'kr-answer'  -->

      <strong>Numéro de la boutique :</strong>

      <?php echo $answer['kr-answer']['shopId']; ?>

      <br />

      <strong>Le statut de la transaction :</strong>

      <?php echo $answer['kr-answer']['orderStatus']; ?>

      <br />

      <strong>Numéro de la transaction :</strong>

      <?php echo $answer['kr-answer']['transactions'][0]['uuid']; ?>

      <br />

      <strong>Numéro de la commande :</strong>

      <?php echo $answer['kr-answer']['orderDetails']['orderId']; ?>

      <br />

   </div>

</body>



</html>
© 2025 {'|'} All rights reserved to Scellius
25.18-1.11