merchant-frontend-examples

ZZZ: Inactive/Deprecated
Log | Files | Refs

track-transfer.php (1161B)


      1 <?php
      2   // This file is in the public domain.
      3 
      4   include 'error.php';
      5   include 'backend.php';
      6 
      7 
      8   $response = get_to_backend("/track/transfer", $_GET);
      9 
     10   if (!in_array($response["status_code"], array(200, 424))){
     11     echo build_error($response,
     12                      "Backend error",
     13                      $response["status_code"]);
     14     return;
     15   }
     16 
     17   // Render HTML
     18   http_response_code($response["status_code"]);
     19   if (424 == $response["status_code"]){
     20     $body = json_decode($response["body"]);
     21     echo sprintf("<p>The backend detected that the amount wire
     22                  transferred by the exchange for coin '%s', differs
     23                  from the coin's original amount.</p>",
     24                  $body->coin_pub);
     25     return;
     26   }
     27 
     28   $json_response = json_decode($response["body"]);
     29   $pretty_date = get_pretty_date($json_response->execution_time);
     30   $amount = get_amount($json_response->total);
     31   echo "<p>$amount transferred on $pretty_date. The list of involved
     32        transactions is shown below:</p>";
     33   echo "<ul>";
     34 
     35   foreach ($json_response->deposits_sums as $entry){
     36     echo sprintf("<li>Order id: %s", $entry->order_id);
     37   }
     38   echo "</ul>";
     39 ?>