commit c7a0b6164d25cb5865bcc1ac4135055dfa392f98
parent 3fec48a375df0a40753fec09a4826bc072751c77
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Thu, 17 Nov 2016 23:23:57 +0100
Testing track-transaction 202
Diffstat:
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/php/backend.php b/php/backend.php
@@ -24,14 +24,13 @@
array('Content-Type: application/json'));
curl_setopt_array($c, $options);
$r = curl_exec($c);
- file_put_contents("/tmp/php.out", print_r($r, true));
return array("status_code" => curl_getinfo($c, CURLINFO_HTTP_CODE),
"body" => $r);
}
- function get_to_backend($backend_uri, $args){
+ function get_to_backend($backend_url, $args){
$path = sprintf("%s?%s", $backend_url, http_build_query($args));
- $c = curl_init(url_join ($GLOBALS['BACKEND'], $path));
+ $c = curl_init(url_join($GLOBALS['BACKEND'], $path));
$options = array(CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
diff --git a/php/track-input.php b/php/track-input.php
@@ -8,12 +8,12 @@
</head>
<body>
<form action='/track-transaction.php' method='GET'>
- <input type='text' name='tid'></input>
+ <input type='text' name='tid' placeholder='Transaction ID'></input>
<input type='submit' value='Track transaction'></input>
</form>
<form action='/track-transfer.php' method='GET'>
- <input type='text' name='wtid'></input>
- <input type='text' name='exchange'></input>
+ <input type='text' name='wtid' placeholder='Wire transfer ID'></input>
+ <input type='text' name='exchange' placeholder='Exchange URL'></input>
<input type='submit' value='Track transfer'></input>
</form>
</body>
diff --git a/php/track-transaction.php b/php/track-transaction.php
@@ -13,8 +13,8 @@
}
$response = get_to_backend("/track/transaction",
- array("id" => intval($_GET['id'])));
- if (!in_array(array(200, 202)) $response["status_code"]){
+ array("id" => intval($_GET['tid'])));
+ if (!in_array($response["status_code"], array(200, 202))){
echo build_error($response,
"Backend error",
$response["status_code"]);
@@ -23,20 +23,21 @@
// Render HTML
http_response_code($response["status_code"]);
+ $decoded = json_decode($response["body"]);
if (202 == $response["status_code"]){
+ $pretty_date = get_pretty_date($decoded->details->execution_time);
echo "<p>The exchange accepted the transactioin.
The estimated time for when the related wire transfer
- is to be performed is: $pretty_time</p>";
+ is to be performed is: $pretty_date</p>";
return;
}
echo "<ul>";
- foreach (json_decode($response["body"]) as $entry){
- $pretty_date = get_pretty_date($entry->date);
+ foreach ($decoded as $entry){
+ $pretty_date = get_pretty_date($entry->execution_time);
echo sprintf("<li>Wire transfer ID: %s, date: %s</li>",
$entry->wtid,
$pretty_date);
}
echo "</ul>";
-
?>