merchant-frontend-examples

ZZZ: Inactive/Deprecated
Log | Files | Refs

track-transaction.php (1328B)


      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/transaction", $_GET);
      9 
     10   if (!in_array($response["status_code"], array(200, 202, 424))){
     11     echo build_error($response,
     12                      "Backend error",
     13                      $response["status_code"]);
     14     return;
     15   }
     16 
     17   // Report conflict
     18   if (424 == $response["status_code"]){
     19     $body = json_decode($response["body"]);
     20     echo sprintf("<p>Exchange provided conflicting information about
     21                   transaction '%s': what claimed by the exchange does
     22                   not match what stored in our DB.</p>",
     23                   $_GET["order_id"]);
     24     return;
     25   }
     26 
     27   // Render HTML
     28   http_response_code($response["status_code"]);
     29   $decoded = json_decode($response["body"]);
     30   if (202 == $response["status_code"]){
     31     $pretty_date = get_pretty_date($decoded->details->execution_time);
     32     echo "<p>The exchange accepted the transaction.
     33           The exchange will attempt the payment on: $pretty_date</p>";
     34     return;
     35   }
     36 
     37   echo "<ul>";
     38   foreach ($decoded as $entry){
     39     $pretty_date = get_pretty_date($entry->execution_time);
     40     echo sprintf("<li>Wire transfer ID: %s, date: %s</li>",
     41                  $entry->wtid,
     42                  $pretty_date);
     43   }
     44   echo "</ul>";
     45 ?>