summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-01-25 15:59:16 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-01-25 15:59:16 +0100
commit3a4e0743d9891683fbf035f18742d8b65d07e232 (patch)
tree82187b63ca6e7c4cb8603d49550383b782fda6e7
parentd46b7f5566f736ddc0263fe3969e0b56b25976ad (diff)
downloadmerchant-3a4e0743d9891683fbf035f18742d8b65d07e232.tar.gz
merchant-3a4e0743d9891683fbf035f18742d8b65d07e232.tar.bz2
merchant-3a4e0743d9891683fbf035f18742d8b65d07e232.zip
execute contract from fulfillment page
-rw-r--r--src/frontend/execute.php56
-rw-r--r--src/frontend/execute.tsx41
-rw-r--r--src/frontend/fulfillment.php16
3 files changed, 15 insertions, 98 deletions
diff --git a/src/frontend/execute.php b/src/frontend/execute.php
deleted file mode 100644
index 33021fd3..00000000
--- a/src/frontend/execute.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <title>Toy Store - Taler Demo</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- <script> /* @licstart The following is the entire license notice for the
- JavaScript code in this page.
-
- Copyright (C) 2015 GNUnet e.V.
-
- The JavaScript code in this page is free software: you can
- redistribute it and/or modify it under the terms of the GNU
- Lesser General Public License (GNU LGPL) as published by the Free Software
- Foundation, either version 2.1 of the License, or (at your option)
- any later version. The code is distributed WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU LGPL for more details.
-
- As additional permission under GNU LGPL version 2.1 section 7, you
- may distribute non-source (e.g., minimized or compacted) forms of
- that code without the copy of the GNU LGPL normally required by
- section 4, provided you include this license notice and a URL
- through which recipients can access the Corresponding Source.
-
- @licend The above is the entire license notice
- for the JavaScript code in this page.
- */
- </script>
- <script type="text/javascript">
-<?php
-session_start();
-echo "var h_contract=\"$_SESSION[H_contract]\";\n";
-?>
- </script>
- <script type="text/javascript" src="execute.js"></script>
-</head>
-
-<body>
- <header>
- <div id="logo">
- <svg height="100" width="100">
- <circle cx="50" cy="50" r="40" stroke="darkcyan" stroke-width="6" fill="white" />
- <text x="19" y="82" font-family="Verdana" font-size="90" fill="darkcyan">S</text>
- </svg>
- </div>
- <h1>Toy Store - Taler Demo</h1>
- </header>
-
- <aside class="sidebar" id="left">
- </aside>
-
- <section id="main">
- <h1>Executing Payment ...</h1>
- <div id="loading">Loading...</div>
-</body>
-</html>
diff --git a/src/frontend/execute.tsx b/src/frontend/execute.tsx
deleted file mode 100644
index 67cf8e06..00000000
--- a/src/frontend/execute.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-"use strict";
-
-
-// JSX literals are compiled to calls to React.createElement calls.
-let React = {
- createElement: function(tag, props, ...children) {
- let e = document.createElement(tag);
- for (let k in props) {
- e.setAttribute(k, props[k]);
- }
- for (let child of children) {
- if ("string" === typeof child || "number" == typeof child) {
- child = document.createTextNode(child);
- }
- e.appendChild(child);
- }
- return e;
- }
-};
-
-declare var h_contract: string;
-
-document.addEventListener("DOMContentLoaded", function (e) {
- var eve = new CustomEvent('taler-execute-payment', {detail: {H_contract: h_contract}});
- document.dispatchEvent(eve);
-});
-
-function replace(el, r) {
- el.parentNode.replaceChild(r, el);
-}
-
-document.addEventListener("taler-payment-result", function (e: CustomEvent) {
- if (!e.detail.success) {
- alert("Payment failed\n" + JSON.stringify(e.detail));
- return;
- }
- console.log("finished payment");
- let msg =
- <div>Payment successful. View your <a href={e.detail.fulfillmentUrl}>product</a>.</div>;
- replace(document.getElementById("loading"), msg);
-});
diff --git a/src/frontend/fulfillment.php b/src/frontend/fulfillment.php
index 43517709..595ccc60 100644
--- a/src/frontend/fulfillment.php
+++ b/src/frontend/fulfillment.php
@@ -3,6 +3,16 @@
<head>
<title>Taler's "Demo" Shop</title>
<link rel="stylesheet" type="text/css" href="style.css">
+ <script type="application/javascript">
+ function executePayment(H_contract, pay_url) {
+ var detail = {
+ H_contract: H_contract,
+ pay_url: pay_url
+ };
+ var eve = new CustomEvent('taler-execute-payment', {detail: detail});
+ document.dispatchEvent(eve);
+ }
+ </script>
</head>
<body>
@@ -41,7 +51,8 @@
include '../frontend_lib/util.php';
-function generate_msg ($link){
+function generate_msg ($link)
+{
$msg = "<p>Thanks for donating to " . $_SESSION['receiver'] . ".</p>";
if (false != $link)
$msg .= "<p>Check our latest <a href=\"" . $link . "\">news!</a></p>";
@@ -64,7 +75,10 @@ $my_payment = get($payments[$hc]);
if (null === $my_payment)
{
+ $pay_url = url_rel("pay");
echo "<p>you do not have the session state for this contract: " . $hc . "</p>";
+ echo "<p>Asking the wallet to re-execute it ... </p>";
+ echo "<script>executePayment('$hc', '$pay_url');</script?";
return;
}