summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-11-19 14:29:59 +0100
committerChristian Grothoff <christian@grothoff.org>2016-11-19 14:29:59 +0100
commite066b10f725bed1b723d9942b81a48bb496e4a46 (patch)
tree3a2c6cb5362d6c558190f27d05ced99ccf5247c3
parent9341de5a31d57aa0498725976e5d413c8e7e3428 (diff)
downloadmerchant-frontend-examples-e066b10f725bed1b723d9942b81a48bb496e4a46.tar.gz
merchant-frontend-examples-e066b10f725bed1b723d9942b81a48bb496e4a46.tar.bz2
merchant-frontend-examples-e066b10f725bed1b723d9942b81a48bb496e4a46.zip
update chapters 1 and 2 of tutorial
-rw-r--r--php/backend.php13
-rw-r--r--php/config.php6
-rw-r--r--php/contract.php4
-rw-r--r--php/copying.php18
-rw-r--r--php/doc/arch.dot2
-rw-r--r--php/doc/tutorial.texi277
-rw-r--r--php/donate.php2
-rw-r--r--php/error.php3
-rw-r--r--php/fulfillment.php6
-rw-r--r--php/generate-contract.php2
-rw-r--r--php/helpers.php26
-rw-r--r--php/index.html12
-rw-r--r--php/index.php15
-rw-r--r--php/pay.php5
-rw-r--r--php/track-input.html18
-rw-r--r--php/track-input.php21
-rw-r--r--php/track-transaction.php8
-rw-r--r--php/track-transfer.php8
18 files changed, 276 insertions, 170 deletions
diff --git a/php/backend.php b/php/backend.php
index 7ec0402..c3c9b9e 100644
--- a/php/backend.php
+++ b/php/backend.php
@@ -1,6 +1,6 @@
<?php
+ // This file is in the public domain.
- include 'copying.php';
include_once 'config.php';
include_once 'helpers.php';
@@ -20,27 +20,30 @@
// to NOT have certs for taler.net
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
- CURLOPT_HTTPHEADER =>
+ CURLOPT_HTTPHEADER =>
array('Content-Type: application/json'));
curl_setopt_array($c, $options);
$r = curl_exec($c);
return array("status_code" => curl_getinfo($c, CURLINFO_HTTP_CODE),
"body" => $r);
}
-
+
+ /**
+ * Sends a GET request to the backend.
+ */
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));
$options = array(CURLOPT_RETURNTRANSFER => true,
- CURLOPT_CUSTOMREQUEST => "GET",
+ CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false);
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);
+ "body" => $r);
}
diff --git a/php/config.php b/php/config.php
index 33c1783..406f374 100644
--- a/php/config.php
+++ b/php/config.php
@@ -1,9 +1,9 @@
<?php
+ // This file is in the public domain.
- // This config file is in the public domain.
-
+ // Which backend should we use? Must end in "/".
$BACKEND = "https://backend.demo.taler.net/";
+
// The currency must match the one used by the backend.
$CURRENCY = "KUDOS";
-
?>
diff --git a/php/contract.php b/php/contract.php
index b522a94..3af5ebf 100644
--- a/php/contract.php
+++ b/php/contract.php
@@ -1,8 +1,8 @@
<?php
+ // This file is in the public domain.
- include 'copying.php';
- include_once 'helpers.php';
include_once 'config.php';
+ include_once 'helpers.php';
function make_contract($transaction_id, $now){
$contract = array ('amount' =>
diff --git a/php/copying.php b/php/copying.php
deleted file mode 100644
index 5c082d6..0000000
--- a/php/copying.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-/*
- This file is part of GNU TALER.
- Copyright (C) 2014, 2015, 2016 INRIA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
- Foundation; either version 2.1, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License along with
- TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
-
-*/
-?>
diff --git a/php/doc/arch.dot b/php/doc/arch.dot
index d8a3a91..5b6d944 100644
--- a/php/doc/arch.dot
+++ b/php/doc/arch.dot
@@ -8,7 +8,6 @@ digraph G {
Frontend;
Backoffice;
Backend;
- DBMS;
label="Shop server";
}
subgraph cluster_1 {
@@ -19,6 +18,5 @@ digraph G {
admin->Backoffice;
Frontend->Backend;
Backoffice->Backend;
- Backend->DBMS;
Backend->Exchange;
}
diff --git a/php/doc/tutorial.texi b/php/doc/tutorial.texi
index cf11b79..dd8fe96 100644
--- a/php/doc/tutorial.texi
+++ b/php/doc/tutorial.texi
@@ -89,10 +89,18 @@ regulation (such as GDPR).
@section About this tutorial
-This tutorial is for Web developers and addresses how to integrate GNU Taler
-with Web shops. It describes how to create a Web shop that cooperates with
-a GNU Taler merchant @emph{backend}.
-
+This tutorial is for Web developers and addresses how to integrate GNU
+Taler with Web shops. It describes how to create a Web shop that
+processes payments with the help of a GNU Taler merchant
+@emph{backend}. In the second chapter, you will learn how to trigger
+the payment process from the Web site, how to communicate with the
+backend, how to generate a contract and process the payment. The
+third chapter covers the integration of a back office with the
+backend, which includes tracking payments for orders, matching
+payments to orders, and persisting and retrieving contracts.
+
+@cindex examples
+@cindex git
You can download all of the code examples given in this tutorial from
@url{https://git.taler.net/merchant-frontend-examples.git/tree/php/}.
@@ -101,15 +109,18 @@ You can download all of the code examples given in this tutorial from
@section Architecture overview
-The Taler software stack for a merchant consists of four main components:
+The Taler software stack for a merchant consists of the following
+main components:
@itemize
+@cindex frontend
@item A frontend which interacts with the customer's browser. The
frontend enables the customer to build a shopping cart and place
an order. Upon payment, it triggers the respective business logic
to satisfy the order. This component is not included with Taler,
but rather assumed to exist at the merchant. This tutorial
describes how to develop a Taler frontend.
+@cindex back office
@item A back office application that enables the shop operators to
view customer orders, match them to financial transfers, and possibly
approve refunds if an order cannot be satisfied. This component is
@@ -117,20 +128,13 @@ The Taler software stack for a merchant consists of four main components:
merchant. This tutorial will describe how to integrate such a component
to handle payments managed by Taler. Such integration is shown by
adding the back office functionality to the frontend implemented
- in the first part of this tutorial.
+ in the second part of this tutorial.
+@cindex backend
@item A Taler-specific payment backend which makes it easy for the
- frontend to process financial transactions with Taler. Note that
- the frontend implemented in this tutorial is configured by default
- to run against a public backend, which has been set-up at
- @code{http://backend.demo.taler.net/} for testing frontends.
- In order to point the frontend being developed in this tutorial
- to some other backend, it suffices to set the variable @code{$BACKEND}
- in @code{php/config.php} to the desired backend's base URL.
-
-
-@item A DBMS which stores the transaction history for the Taler backend.
- For now, the GNU Taler reference implemenation only supports Postgres,
- but the code could be easily extended to support another DBMS.
+ frontend to process financial transactions with Taler. For this
+ tutorial, you will use a public backend, but for a production
+ deployment a merchant-specific backend will need to be setup
+ by a system administrator.
@end itemize
The following image illustrates the various interactions of these
@@ -140,12 +144,12 @@ key components:
Basically, the backend provides the cryptographic protocol support,
-stores Taler-specific financial information in a DBMS and communicates
+stores Taler-specific financial information and communicates
with the GNU Taler exchange over the Internet. The frontend accesses
the backend via a RESTful API. As a result, the frontend never has to
directly communicate with the exchange, and also does not deal with
sensitive data. In particular, the merchant's signing keys and bank
-account information is encapsulated within the Taler backend.
+account information are encapsulated within the Taler backend.
@node Hello-world
@chapter Setting up a simple Web shop with GNU Taler
@@ -157,7 +161,7 @@ contract offering him the opportunity to make a fixed donation,
for example to donate 1 KUDOS to the charity operating the shop.
Please note the all the code samples shown below in the tutorial
-are contained in @code{php/doc/samples.zip}.
+can be found at @url{https://git.taler.net/merchant-frontend-examples.git/tree/php}.
@c NOTE: include explaining wallet installation to Web developer here!
@@ -166,15 +170,61 @@ they should instead be prompted to proceed with a classic dialog for
credit card payments.
+@section Configuring the backend
+
+@cindex backend
+@cindex configuration
+@cindex currency
+For many critical operations, the frontend we will need to communicate
+with a Taler backend. Assuming that you do not yet have a backend
+configured, you can use the public backend provided by the Taler
+project for testing. This public backend has been set-up at
+@code{https://backend.demo.taler.net/} specifically for testing
+frontends. It uses the currency ``KUDOS'' and all payments will
+go into the XXX account at the Taler ``bank'' running at
+@code{https://bank.demo.taler.net/}.
+
+To point the frontend being developed in this tutorial to some
+backend, it suffices to set the variable @code{$BACKEND} in
+@code{php/config.php} to the desired backend's base URL. You also
+need to specify the currency used by the backend. For example:
+
+@smallexample
+// php/config.php
+@verbatiminclude ../config.php
+@end smallexample
+
+
+@section Talking to the backend
+
+@cindex backend
+Given the above configuration, we can now implement two simple
+functions @code{get_to_backend} and @code{post_to_backend} to
+send requests to the backend. The function @code{get_to_backend},
+is in charge of performing HTTP GET requests to the backend,
+while @code{post_to_backend} will send HTTP POST requests.
+
+@smallexample
+// php/backend.php
+@verbatiminclude ../backend.php
+@end smallexample
+
+The given backend code uses a few helper functions from
+@code{php/helpers.php}, which should be self-explanatory.
+@c But are not yet! Need to comment the code better!
+
+
@section Prompting for payment
+@cindex button
Our goal is to trigger a Taler payment once the customer has clicked
-on a donation button. We will use a button that issues an HTTP POST
+on a donation button. We will use a button that issues an HTTP GET
to the frontend @code{/donate} URL. For this, the HTML would be as
follows:
@smallexample
-@verbatiminclude ../index.php
+// php/index.html
+@verbatiminclude ../index.html
@end smallexample
When the server-side handler for @code{/donate} receives the form submission,
@@ -187,101 +237,95 @@ it will return a HTML page that will take care of:
A minimalistic @code{donate.php} implementation is shown below (in PHP):
+@cindex pay handler
+@cindex 402
+@cindex X-Taler-Contract-Url
@smallexample
// php/donate.php
@verbatiminclude ../donate.php
@end smallexample
Given this response, the Taler wallet will fetch the contract from
-@url{/generate-contract.php} and display it to the user. If the wallet is not
-present, the HTML body will be shown and the Taler headers will be
-ignored by the browser. Instead of specifying the contract via an
-URL, it is also possible to inline short contracts directly.
+@url{/generate-contract.php} and display it to the user.
-Note that we @emph{could} have bypassed the POST request to trigger
-the payment, and performed the interaction with the wallet directly
-from the button via JavaScript.
-@c We will consider this case in a later chapter.
-@c FIXME: not yet ;-)
+@section A helper function to generate the proposed contract
-@section Generating the contract
+We first define a helper function @code{make_contract} that will
+generate a complete Taler contract as a nested PHP array. The
+function takes only the transaction ID and the timestamp as arguments,
+all of the other details of the contract are hardcoded in this simple
+example.
-The server-side handler for @code{/generate-contract.php} now has to
-generate a contract proposal about donating 1 KUDOS to the 'Taler
-charity program'. This proposed contract is then POSTed to the
-backend at @code{/contract}. The main result of POSTing the proposal
-to the backend is that it will be cryptographically signed. This is
-necessary as by design the frontend does not perform any cryptographic
-work.
+The following code generate a contract proposal about donating 1 KUDOS
+to the 'Taler charity program':
+
+@cindex contract
+@smallexample
+// php/contract.php
+@verbatiminclude ../contract.php
+@end smallexample
+
+
+@section Signing and returning the proposal
+
+The server-side handler for @code{/generate-contract.php} has to call
+@code{make_contract} and then POST the result to the backend at
+@code{/contract}. By POSTing the proposal to the backend we get a
+cryptographic signature over its contents. The result is then
+returned to the wallet.
A simple @code{/generate-contract.php} handler may thus look like this:
+@cindex signature
+@cindex backend
+@cindex contract
@smallexample
// php/generate-contract.php
@verbatiminclude ../generate-contract.php
@end smallexample
+If the wallet is not present, the HTML body will be shown and the
+Taler headers and the 402 status code ought to be ignored by the
+browser.
+
+@c FIXME: improve example to do this right?
Note that in practice the frontend might want to generate a monotonically
increasing series of transaction IDs to avoid a chance of collisions.
Transaction IDs must be in the range of @math{[0:2^{51})}.
-The function @code{post_to_backend} is shown below; we will use it
-again in other examples. Note also the function @code{get_to_backend},
-which is in charge of performign HTTP GET requests to the backend;
-it will be used by the back office script, see @ref{Back-office-integration}.
+@section Handling errors
-@smallexample
-@verbatiminclude ../backend.php
-@end smallexample
+In the above example, the helper function @code{build_error} is
+used to generate an error response in the case that the backend
+somehow failed to respond properly to our request.
The function @code{build_error} is shown below, it returns JSON data
matching a particular format for reporting errors,
-see @code{http://api.taler.net/api-common.html#errordetail}.
+see @code{http://api.taler.net/api-common.html#errordetail}:
@smallexample
@c FIXME, build_error() doesn't respect error-reporting format yet!
+// php/error.php
@verbatiminclude ../error.php
@end smallexample
-After the browser has fetched the contract, the user will
-be given the opportunity to affirm the payment.
-
-@section Receiving payments via Taler
-
-The next step for the frontend is to accept the payment from the wallet,
-assuming the user accepts the contract. For this, the frontend must
-implement a payment handler at the URI specified for as the
-@code{X-Taler-Pay-Url} in the example above.
-
-The role of the @code{/pay} handler is to receive the payment from
-the wallet and forward it to the backend. If the backend reports
-that the payment was successful, the handler needs to update the
-session state with the browser to remember that the user paid.
-The following code implements this in PHP:
-
-@smallexample
-// php/pay.php
-@verbatiminclude ../pay.php
-@end smallexample
-
-Do not be confused by the @code{isset} test for the session state. In
-our simple example, it will be set to ``false'' by the fulfillment URL
-which the browser actually always visits first.@footnote{This is for
-technical reasons; the natural logical progression would of course be
-to pay before accessing the fulfillment URL.} We describe how the
-fulfillment URL works in the next section.
+@section Initiating the payment process
-@section The fulfillment page
+@cindex fulfillment URL
+After the browser has fetched the contract proposal, the user will be
+given the opportunity to affirm the payment. Assuming the user
+affirms, the browser will navigate to the ``fulfillment_url'' that
+was specified in the contract.
The fulfillment page can be called by users that have already paid for
the item, as well as by users that have not yet paid at all. The
-fulfillment page must use the HTTP session state to detect if the
+fulfillment page must thus use the HTTP session state to detect if the
payment has been performed already, and if not request payment from
the wallet.
-For our example, we include in the URI of the fulfillment page the data
+For our example, we include in the URI of the fulfillment page the information
which is needed to allow the page to determine which contract the user is
trying to access.
Thus, the fulfillment URL for our example looks like the following:@*
@@ -291,13 +335,68 @@ https://shop.com/fulfillment.php? \
transaction_id=<TRANSACTION_ID>&timestamp=<CONTRACTTIMESTAMP>
@end smallexample
-@* @code{fulfillment.php} will then perform the following actions:
+The fulfillment handler will at @code{/fulfillment.php}
+will use this information to check if the user has already
+paid, and if so confirm the donation. If the user has not yet
+paid, it will instead return another ``402 Payment Required''
+header, requesting the wallet to pay:
@smallexample
// php/fulfillment.php
@verbatiminclude ../fulfillment.php
@end smallexample
+@code 402 payment required
+Here, this second 402 response contains the following Taler-specific
+headers:
+
+@table
+@item X-Taler-Contract-Hash
+@cindex X-Taler-Contract-Hash
+The wallet needs to know which contract we are asking it to pay for.
+To reduce bandwidth consumption, we do not transmit the full contract
+again, but just the hash of it.
+@item X-Taler-Pay-Url
+@cindex X-Taler-Pay-Url
+This URL specifies where we expect the wallet to send the payment.
+@item X-Taler-Offer-Url
+@cindex X-Taler-Offer-Url
+In case that the wallet does not know about this contract already,
+i.e. because a user shared the URL with another user, this tells the
+wallet where to go to retrieve the original offer.
+@c FIXME: do implement offer-URL properly for the tutorial!
+@end table
+
+
+@section Receiving payments via Taler
+
+The final next step for the frontend is to accept the payment from the
+wallet. For this, the frontend must implement a payment handler at
+the URI specified for as the @code{X-Taler-Pay-Url} in the headers
+as explained above.
+
+The role of the @code{/pay} handler is to receive the payment from
+the wallet and forward it to the backend. If the backend reports
+that the payment was successful, the handler needs to update the
+session state with the browser to remember that the user paid.
+
+The following code implements this in PHP:
+
+@smallexample
+// php/pay.php
+@verbatiminclude ../pay.php
+@end smallexample
+
+Do not be confused by the @code{isset} test for the session state. In
+our simple example, it will be set to ``false'' by the fulfillment URL
+which the browser actually always visits first.
+
+After the @code{pay.php} handler has affirmed that the payment was
+successful, the wallet will refresh the fulfillment page, this
+time receiving the message that the donation was successful. If
+anything goes wrong, the wallet will handle the respective error.
+
+
@node Back-office-integration
@chapter Integration of GNU Taler with the back office
@@ -317,11 +416,11 @@ To that regard, the frontend's main task are:
We implement the first point with a simple HTML form. For simplicity, we
have one single page for gathering input data for both tracking directions.
-See below the code sample:
+See below the simple HTML entry page for the back office:
@smallexample
-// php/track-input.php
-@verbatiminclude ../track-input.php
+// php/track-input.html
+@verbatiminclude ../track-input.html
@end smallexample
The @code{track-transaction.php} script is now responsible for taking the
@@ -397,8 +496,22 @@ loop we construct the list of the transaction IDs paid back by @code{wtid}.
@node Advanced topics
@chapter Advanced topics
+@section Inline contracts in HTTP headers
+
+In the example in section FIXME, we told the wallet the URL from where
+it should fetch the contract. Instead of specifying the contract via
+an URL, it is also possible to inline short contracts directly.
+
+FIXME: explain how.
+
+
@section Payments using JavaScript
+In the example in section FIXME, we used a GET request to trigger the
+payment. This section describes how we could have instead performed
+the interaction with the wallet directly from the button via
+JavaScript.
+
The function @code{executePayment} exported by @code{taler-wallet-lib.js} will basically
hand its three parameters to the wallet which implements the following semantics:@*
check in the internal DB if @code{$response['H_contract']} has an entry, and:
diff --git a/php/donate.php b/php/donate.php
index 82c10ab..a844a41 100644
--- a/php/donate.php
+++ b/php/donate.php
@@ -1,4 +1,6 @@
<?php
+ // This file is in the public domain.
+
http_response_code(402); // 402: Payment required
header ('X-Taler-Contract-Url: /generate-contract.php');
echo "<html>
diff --git a/php/error.php b/php/error.php
index 1c3912b..01cff35 100644
--- a/php/error.php
+++ b/php/error.php
@@ -1,6 +1,5 @@
<?php
-
- include 'copying.php';
+ // This file is in the public domain.
function build_error($response, $hint, $http_code){
http_response_code($http_code);
diff --git a/php/fulfillment.php b/php/fulfillment.php
index d7fbafb..b94f2db 100644
--- a/php/fulfillment.php
+++ b/php/fulfillment.php
@@ -1,6 +1,6 @@
-<?php
+<?php
+ // This file is in the public domain.
- include 'copying.php';
include 'contract.php';
include 'backend.php';
include 'error.php';
@@ -17,7 +17,7 @@
}
$_SESSION['transaction_id'] = $_GET['transaction_id'];
-
+
$now = new DateTime();
$now->setTimestamp(intval($_GET["timestamp"]));
diff --git a/php/generate-contract.php b/php/generate-contract.php
index 2e95141..c94ca8b 100644
--- a/php/generate-contract.php
+++ b/php/generate-contract.php
@@ -1,6 +1,6 @@
<?php
+ // This file is in the public domain.
- include 'copying.php';
include 'contract.php';
include 'backend.php';
include 'error.php';
diff --git a/php/helpers.php b/php/helpers.php
index 1f4218d..03652bc 100644
--- a/php/helpers.php
+++ b/php/helpers.php
@@ -1,7 +1,9 @@
<?php
+ // This file is in the public domain.
- include 'copying.php';
-
+ /**
+ * ???
+ */
function &pull(&$arr, $idx, $default) {
if (!isset($arr[$idx])) {
$arr[$idx] = $default;
@@ -9,6 +11,9 @@
return $arr[$idx];
}
+ /**
+ * ???
+ */
function url_join($base, $path) {
// Please note that this simplistic way of joining URLs is
// to avoiding using pecl_http (painful installation!) and
@@ -16,14 +21,19 @@
return $base . $path;
}
- // $path must have a leading '/'.
+ /**
+ * ???
+ * $path must have a leading '/'.
+ */
function url_rel($path){
// Make sure 'REQUEST_SCHEME' is http/https, as in some setups it may
// be "HTTP/1.1".
return $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$path;
}
-
+ /**
+ * Convert ???
+ */
function get_pretty_date($taler_date){
$match = array();
$timestamp = preg_match('/\/Date\(([0-9]+)\)\//', $taler_date, $match);
@@ -31,11 +41,15 @@
$date->setTimestamp(intval($match[1]));
return $date->format('d/M/Y H:i:s');
}
-
+
+ /**
+ * ???
+ */
function get_amount($taler_amount){
$PRECISION = 100000000;
- $fraction = $taler_amount->fraction / $PRECISION;
+ $fraction = $taler_amount->fraction / $PRECISION;
$number = $taler_amount->value + $fraction;
return sprintf("%s %s", $number, $taler_amount->currency);
}
+
?>
diff --git a/php/index.html b/php/index.html
new file mode 100644
index 0000000..4dae40a
--- /dev/null
+++ b/php/index.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+ <!-- This file is in the public domain -->
+ <head>
+ <title>A donation button</title>
+ </head>
+ <body>
+ <form action='/donate.php' method='GET'>
+ <input type='submit' value='Donate!'></input>
+ </form>
+ </body>
+</html>
diff --git a/php/index.php b/php/index.php
deleted file mode 100644
index 6a16803..0000000
--- a/php/index.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
- include 'copying.php';
-
- echo "<html>
- <head>
- <title>Taler tutorial</title>
- </head>
- <body>
- <form action='/donate.php' method='GET'>
- <input type='submit' value='Donate!'></input>
- </form>
- </body>
- </html>";
-?>
diff --git a/php/pay.php b/php/pay.php
index 43c2e6a..7a07cd7 100644
--- a/php/pay.php
+++ b/php/pay.php
@@ -1,5 +1,6 @@
<?php
- include 'copying.php';
+ // This file is in the public domain.
+
include 'backend.php';
include 'error.php';
@@ -15,7 +16,7 @@
if (200 != $response['status_code']){
echo build_error($response,
"Could not send paymnet to backend",
- $response['status_code']);
+ $response['status_code']);
return;
}
// Payment went through!
diff --git a/php/track-input.html b/php/track-input.html
new file mode 100644
index 0000000..27dd955
--- /dev/null
+++ b/php/track-input.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html lang="en">
+ <!-- This file is in the public domain -->
+ <head>
+ <title>Minimal merchant back office</title>
+ </head>
+ <body>
+ <form action='/track-transaction.php' method='GET'>
+ <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' placeholder='Wire transfer ID'></input>
+ <input type='text' name='exchange' placeholder='Exchange URL'></input>
+ <input type='submit' value='Track transfer'></input>
+ </form>
+ </body>
+</html>
diff --git a/php/track-input.php b/php/track-input.php
deleted file mode 100644
index 602abd0..0000000
--- a/php/track-input.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-
- include 'copying.php';
-
- echo "<html>
- <head>
- <title>Taler tutorial</title>
- </head>
- <body>
- <form action='/track-transaction.php' method='GET'>
- <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' placeholder='Wire transfer ID'></input>
- <input type='text' name='exchange' placeholder='Exchange URL'></input>
- <input type='submit' value='Track transfer'></input>
- </form>
- </body>
- </html>";
-?>
diff --git a/php/track-transaction.php b/php/track-transaction.php
index a42ef44..d65842c 100644
--- a/php/track-transaction.php
+++ b/php/track-transaction.php
@@ -1,6 +1,6 @@
<?php
+ // This file is in the public domain.
- include 'copying.php';
include 'error.php';
include 'backend.php';
@@ -8,10 +8,10 @@
if (!isset($_GET['tid'])){
build_error(array("body" => "No transaction ID given"),
"tid argument missing",
- 400);
+ 400);
return;
}
-
+
$response = get_to_backend("/track/transaction",
array("id" => intval($_GET['tid'])));
if (!in_array($response["status_code"], array(200, 202))){
@@ -38,6 +38,6 @@
echo sprintf("<li>Wire transfer ID: %s, date: %s</li>",
$entry->wtid,
$pretty_date);
- }
+ }
echo "</ul>";
?>
diff --git a/php/track-transfer.php b/php/track-transfer.php
index fa54d70..8b0f51d 100644
--- a/php/track-transfer.php
+++ b/php/track-transfer.php
@@ -1,6 +1,6 @@
<?php
+ // This file is in the public domain.
- include 'copying.php';
include 'error.php';
include 'backend.php';
@@ -8,10 +8,10 @@
if (!isset($_GET['wtid']) or !isset($_GET['exchange']))){
build_error(array("body" => "Missing parameter"),
"'wtid' or 'exchange' has not been submitted",
- 400);
+ 400);
return;
}
-
+
$wtid = $_GET['wtid'];
$response = get_to_backend("/track/transfer",
array("wtid" => $wtid,
@@ -41,6 +41,6 @@
echo "<ul>";
foreach ($json_response->deposits as $entry){
echo sprintf("<li>Transaction id: %s", $entry->transaction_id);
- }
+ }
echo "</ul>";
?>