[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant-frontend-examples] branch master updated: a
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant-frontend-examples] branch master updated: adapting (~60%) php backoffice to latest changes |
Date: |
Mon, 27 Mar 2017 02:02:34 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository merchant-frontend-examples.
The following commit(s) were added to refs/heads/master by this push:
new 16742e7 adapting (~60%) php backoffice to latest changes
16742e7 is described below
commit 16742e787e4071c1108eb328a5256c2b8d8850c4
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Mar 27 02:01:52 2017 +0200
adapting (~60%) php backoffice to latest changes
---
php/backend.php | 2 --
php/backoffice.html | 15 ++++-----------
php/generate-order.php | 2 +-
php/history.js | 10 ++++------
php/history.php | 12 ++----------
php/order.php | 1 +
php/track-transaction.php | 16 ++++------------
python/example/example.py | 1 +
8 files changed, 17 insertions(+), 42 deletions(-)
diff --git a/php/backend.php b/php/backend.php
index bd70feb..56b6e5d 100644
--- a/php/backend.php
+++ b/php/backend.php
@@ -37,6 +37,4 @@
return array("status_code" => curl_getinfo($c, CURLINFO_HTTP_CODE),
"body" => $r);
}
-
-
?>
diff --git a/php/backoffice.html b/php/backoffice.html
index 665107c..4350179 100644
--- a/php/backoffice.html
+++ b/php/backoffice.html
@@ -7,7 +7,8 @@
</head>
<body>
<form action='/track-transaction.php' method='GET'>
- <input type='text' name='tid' placeholder='Transaction ID'></input>
+ <input type='text' name='order_id' placeholder='Order ID'></input>
+ <input type='text' name='instance' value='tutorial' hidden></input>
<input type='submit' value='Track transaction'></input>
</form>
<form action='/track-transfer.php' method='GET'>
@@ -16,23 +17,15 @@
<input type='submit' value='Track transfer'></input>
</form>
<form id="history_form" action="" method="GET">
- Get transactions up to
- <select name="days">
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="7">7</option>
- <option value="0">∞</option>
- </select>
- days back: <input type="button" onclick="submit_history();" value="Get!">
+ <a href="#" onclick="submit_history()">Get transactions list</a>
<br>
<small>Works only if JavaScript enabled</small>
</form>
<br/>
<table id="history" style="visibility: hidden;">
<tr>
- <th>Transaction ID</th>
+ <th>Order ID</th>
<th>Date</th>
- <th>Contract</th>
<th>Amount</th>
</tr>
</table>
diff --git a/php/generate-order.php b/php/generate-order.php
index 1a0e4a1..4d57998 100644
--- a/php/generate-order.php
+++ b/php/generate-order.php
@@ -15,7 +15,7 @@
"no nonce given",
400);
$order = make_order($_GET["nonce"],
- $order_id,
+ strval($order_id),
new DateTime('now'));
// Here the frontend POSTs the proposal to the backend
$response = post_to_backend("/proposal", $order);
diff --git a/php/history.js b/php/history.js
index 3db11be..50629f6 100644
--- a/php/history.js
+++ b/php/history.js
@@ -29,7 +29,6 @@ function submit_history(){
/* We don't want to kill the first child */
for (var i = 2; i < table.childNodes.length; i++)
table.removeChild(table.childNodes[i]);
- var days = document.getElementById("history_form").days.value;
var req = new XMLHttpRequest();
var get_column = function(value){
var column = document.createElement("td");
@@ -39,9 +38,10 @@ function submit_history(){
var on_error = function(){
table.innerHTML = "<p>Could not get transactions list from server</p>"
};
- req.open("GET", `/history.php?days=${days}`, true);
+ req.open("GET", "/history.php?instance=tutorial", true);
req.onload = function(){
if(req.readyState == 4 && req.status == 200){
+ console.log("Got history:", req.responseText);
var history = JSON.parse(req.responseText);
if(!history)
console.log("Got invalid JSON");
@@ -51,12 +51,10 @@ function submit_history(){
for (var i=0; i<history.length; i++){
var entry = history[i];
var tr = document.createElement("tr");
- tr.appendChild(get_column(entry.transaction_id));
+ tr.appendChild(get_column(entry.order_id));
var date = get_date(entry.timestamp);
tr.appendChild(get_column(date.toLocaleDateString()));
- var contract = entry.h_contract.substr(0, 5);
- tr.appendChild(get_column(contract + "..."));
- tr.appendChild(get_column(parse_amount(entry.total_amount)))
+ tr.appendChild(get_column(parse_amount(entry.amount)))
table.appendChild(tr);
}
table.style.visibility = "";
diff --git a/php/history.php b/php/history.php
index 93ac315..360e695 100644
--- a/php/history.php
+++ b/php/history.php
@@ -2,22 +2,14 @@
include 'helpers.php';
include 'backend.php';
+ include 'error.php';
- if (!isset($_GET['days'])) {
- echo "<p>Please give 'days' parameter.</p>";
- return;
- }
-
- $now = new DateTime();
- $now->sub(new DateInterval(sprintf("P%sD", $_GET['days'])));
- $response = get_to_backend("/history",
- array("date"=>$now->getTimestamp()));
+ $response = get_to_backend("/history", $_GET);
if (200 != $response["status_code"]){
echo build_error($response,
"Backend error",
$response["status_code"]);
return;
}
-
echo $response["body"];
?>
diff --git a/php/order.php b/php/order.php
index fdcd228..aa77b3e 100644
--- a/php/order.php
+++ b/php/order.php
@@ -51,6 +51,7 @@
'merchant' =>
array('address' =>
'LNAME2',
+ 'instance' => "tutorial",
'name' =>
"Charity donation shop",
'jurisdiction' =>
diff --git a/php/track-transaction.php b/php/track-transaction.php
index e51d1a1..c1c4ba6 100644
--- a/php/track-transaction.php
+++ b/php/track-transaction.php
@@ -5,15 +5,8 @@
include 'backend.php';
- if (!isset($_GET['tid'])){
- build_error(array("body" => "No transaction ID given"),
- "tid argument missing",
- 400);
- return;
- }
+ $response = get_to_backend("/track/transaction", $_GET);
- $response = get_to_backend("/track/transaction",
- array("id" => intval($_GET['tid'])));
if (!in_array($response["status_code"], array(200, 202, 424))){
echo build_error($response,
"Backend error",
@@ -24,11 +17,10 @@
// Report conflict
if (424 == $response["status_code"]){
$body = json_decode($response["body"]);
- echo sprintf("<p>Coin '%s', related to transaction '%s',
- is conflicting: what claimed by the exchange does
+ echo sprintf("<p>Exchange provided conflicting information about
+ transaction '%s': what claimed by the exchange does
not match what stored in our DB.</p>",
- $body->coin_pub,
- $_GET['tid']);
+ $_GET["order_id"]);
return;
}
diff --git a/python/example/example.py b/python/example/example.py
index 988652d..df6b038 100644
--- a/python/example/example.py
+++ b/python/example/example.py
@@ -62,6 +62,7 @@ def generate_proposal():
fulfillment_url=make_url("/fulfillment"),
pay_url=make_url("/pay"),
merchant=dict(
+ instance="tutorial",
address="nowhere",
name="Donation tutorial",
jurisdiction="none",
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-merchant-frontend-examples] branch master updated: adapting (~60%) php backoffice to latest changes,
gnunet <=