diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-01-21 14:46:28 +0100 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-01-21 14:46:28 +0100 |
commit | 9dfc748208f259a254b4a6eeade917122005f104 (patch) | |
tree | a010675f81568b55d261b8a4e1eb65cc0de8667d | |
parent | 1e936a747b2c3380332f0b3dda410261fb97a2b0 (diff) | |
download | merchant-9dfc748208f259a254b4a6eeade917122005f104.tar.gz merchant-9dfc748208f259a254b4a6eeade917122005f104.tar.bz2 merchant-9dfc748208f259a254b4a6eeade917122005f104.zip |
Removing payment method choice from article purchase,
adding form in case Taler wallet not present
-rw-r--r-- | src/frontend_blog/essay_checkout.php | 58 | ||||
-rw-r--r-- | src/frontend_blog/essay_pay.php | 21 |
2 files changed, 29 insertions, 50 deletions
diff --git a/src/frontend_blog/essay_checkout.php b/src/frontend_blog/essay_checkout.php index c013d7c5..44f6bce3 100644 --- a/src/frontend_blog/essay_checkout.php +++ b/src/frontend_blog/essay_checkout.php @@ -36,11 +36,11 @@ <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> + <text x="19" y="82" font-family="Verdana" font-size="90" fill="darkcyan">B</text> </svg> </div> - <h1>Blog - Select payment method</h1> + <h1 id="main-head">Blog - Fill out required information</h1> </header> <aside class="sidebar" id="left"> @@ -49,46 +49,18 @@ <section id="main"> <article> - <h1>Select your payment method</h1> + <h1>Taler Not Installed</h1> <p> - This is an example for a "checkout" page of a Web shop. - On the previous page, you have created the shopping cart - and decided which product to buy (i.e. which project to - donate KUDOS to). Now in this page, you are asked to - select a payment option. As Taler is not yet universally - used, we expect merchants will offer various payment options. - </p> - <p> - The page also demonstrates how to only enable (or show) the Taler - option if Taler is actually supported by the browser. For example, - if you disable the Taler extension now, the Taler payment option - will be disabled in the page. Naturally, you could also trivially - hide the Taler option entirely by changing the visibility instead. - </p> - <p> - Note that you MUST select Taler here for the demo to continue, - as the other payment options are just placeholders and not - really working in the demonstration. Also, it is of course - possible to ask the user to make this choice already on the - previous page (with the shopping cart), we just separated the - two steps to keep each step as simple as possible. + Please proceede paying with your credit card, and fill the form + below. </p> <form name="tform" action="" method="POST"> - <div id="opt-form" align="left"><br> - <input type="radio" name="payment_system" value="lisa" - id="lisa-radio-button-id">Lisa</input> - <br/> - <input type="radio" name="payment_system" value="ycard">You Card</input> - <br/> - <input type="radio" name="payment_system" value="cardme">Card Me</input> - <br/> - <input type="radio" name="payment_system" value="taler" - id="taler-radio-button-id" disabled="true">Taler</input> - <br/> - <input type="button" onclick="pay(this.form)" value="Ok"></input> - </div> + First name <input type="text"></input><br> + Family name <input type="text"></input><br> + Age <input type="text"></input><br> + <input type="button" value="Ok"></input> </form> </article> @@ -181,13 +153,15 @@ function pay(form) whether or not to display/enable Taler as a payment option in the dialog. */ function has_taler_wallet_cb(aEvent) { - // enable the Taler payment option from the form - var tbutton = document.getElementById("taler-radio-button-id"); - tbutton.removeAttribute("disabled"); - tbutton.setAttribute("checked", "true"); + console.log("has taler wallet"); + // make credit card form disappear + var cc = document.getElementById("main"); + var mainHead = document.getElementById("main-head") + mainHead.firstChild.nodeValue = "Processing payment..."; + cc.setAttribute("style", "display:none;"); + taler_pay(null); }; - /* Function called when the Taler extension was unloaded; here we disable the Taler option and check "Lisa", as some "valid" option should always be selected. */ diff --git a/src/frontend_blog/essay_pay.php b/src/frontend_blog/essay_pay.php index 6d906b74..f162a609 100644 --- a/src/frontend_blog/essay_pay.php +++ b/src/frontend_blog/essay_pay.php @@ -29,6 +29,16 @@ if (!isset($_SESSION['H_contract'])) return; } +if (isset($_SESSION['payment_ok']) && $_SESSION['payment_ok'] == true) +{ + $_SESSION['payment_ok'] = true; + http_response_code (301); + $url = (new http\URL($_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])) + ->mod(array ("path" => "essay_fulfillment.php"), http\Url::JOIN_PATH); + header("Location: $url"); + die(); +} + $article = $_SESSION['article']; $post_body = file_get_contents('php://input'); $deposit_permission = json_decode ($post_body, true); @@ -45,7 +55,6 @@ $resp = give_to_backend($_SERVER['HTTP_HOST'], $status_code = $resp->getResponseCode(); // Our response code is the same we got from the backend: http_response_code ($status_code); - // Now generate our body if ($status_code != 200) { @@ -60,16 +69,12 @@ if ($status_code != 200) else { $_SESSION['payment_ok'] = true; - if (!isset($_SESSION['allowed_articles'])){ + if (!isset($_SESSION['allowed_articles'])) $_SESSION['allowed_articles'] = array ($_SESSION['article'] => true); - else $_SESSION['allowed_articles'] = - array_push($_SESSION['allowed_articles'], array ($article => true)); - } - + else $_SESSION['allowed_articles'] = array_merge($_SESSION['allowed_articles'], array ($article => true)); http_response_code (301); $url = (new http\URL($_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])) - ->mod(array ("path" => "essay_fulfillment.php?article=$article"), http\Url::JOIN_PATH); + ->mod(array ("path" => "essay_fulfillment.php"), http\Url::JOIN_PATH); header("Location: $url"); die(); } - |