Exploiter résultat notif - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of Exploiter résultat notif.php

  1. <?php
  2.  
  3. // $HTTP_RAW_POST_DATA contient le JSON ci dessous
  4. $contenu_recu = '{
  5. "data":{
  6.    "payer":{
  7.       "email":"[email protected]"
  8.    },
  9.    "items":[
  10.       {
  11.          "name":"Test adh\u00e9sion",
  12.          "user":{
  13.             "firstName":"Wally",
  14.             "lastName":"DIALLO-TEST"
  15.          },
  16.          "priceCategory":"Free",
  17.          "customFields":[
  18.             {
  19.                "name":"Num\u00e9ro de t\u00e9l\u00e9phone",
  20.                "type":"TextInput",
  21.                "answer":"0675604332"
  22.             },
  23.             {
  24.                "name":"Email",
  25.                "type":"TextInput",
  26.                "answer":"[email protected]"
  27.             },
  28.             {
  29.                "name":"Adresse",
  30.                "type":"TextInput",
  31.                "answer":"181 Bis avenue Jean Cordier"
  32.             },
  33.             {
  34.                "name":"Code Postal",
  35.                "type":"TextInput",
  36.                "answer":"33600"
  37.             },
  38.             {
  39.                "name":"Date de naissance",
  40.                "type":"Date",
  41.                "answer":"28/01/1968"
  42.             },
  43.             {
  44.                "name":"Ville",
  45.                "type":"TextInput",
  46.                "answer":"Pessac"
  47.             }
  48.          ],
  49.          "id":24238991,
  50.          "amount":0,
  51.          "type":"Membership",
  52.          "initialAmount":0,
  53.          "state":"Processed"
  54.       }
  55.    ],
  56.    "amount":{
  57.       "total":0,
  58.       "vat":0,
  59.       "discount":0
  60.    },
  61.    "id":24238991,
  62.    "date":"2021-06-28T10:55:03.1970346+00:00",
  63.    "formSlug":"test-notif",
  64.    "formType":"Membership",
  65.    "organizationSlug":"le-canot-13"
  66. },
  67. "eventType":"Order"
  68. }';
  69.  
  70. $resultat = json_decode($contenu_recu);
  71. $datas = $resultat->data;
  72.  
  73. echo "Type d'evenement : " . $resultat->eventType;
  74. echo "<br/> ID : " . $datas->id;
  75. echo "<br/> Date : " . $datas->date;
  76. echo "<br /> Payeur : ";
  77. echo "<br/> - email : " . $datas->payer->email;
  78.  
  79. echo "<br/> Montant : ";
  80. echo "<br/> - Total : " . $datas->amount->total;
  81. echo "<br/> - Taxe : " . $datas->amount->vat;
  82. echo "<br/> - Remise : " . $datas->amount->discount;
  83.  
  84. if(!empty($datas->items)) {
  85.     echo "<br/> Items : ";
  86.     foreach($datas->items as $item) {
  87.         echo "<br/> Nom : " . $item->name;
  88.         echo "<br/> User : " . $item->user->firstName . " " . $item->user->lastName;
  89.         echo "<br/> Categorie de prix : " . $item->priceCategory;
  90.         echo "<br/> ID : " . $item->id;
  91.         echo "<br/> Type : " . $item->type;
  92.         echo "<br/> Montant initial : " . $item->initialAmount;
  93.         echo "<br/> Etat : " . $item->state;
  94.  
  95.         if(!empty($item->customFields)) {
  96.             echo "<br/> Champs personnalises : ";
  97.             foreach($item->customFields as $customField) {
  98.                 echo "<br/> Nom  : " . $customField->name;
  99.                 echo "<br/> Type  : " . $customField->type;
  100.                 echo "<br/> Valeur  : " . $customField->answer;
  101.             }
  102.         }
  103.     }
  104. }