merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 7c1b3b65b475a47cc74a7fd81fb704defed26c7f
parent 009b131407e5b163f6aaba9217402936d5444db5
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date:   Thu, 21 Jan 2016 17:29:46 +0100

Completing article purchase

Diffstat:
Msrc/frontend/checkout.php | 2+-
Dsrc/frontend_blog/README | 20--------------------
Msrc/frontend_blog/essay_checkout.php | 1+
Msrc/frontend_blog/essay_fulfillment.php | 1+
Msrc/frontend_blog/essay_pay.php | 15++++++++++-----
5 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/src/frontend/checkout.php b/src/frontend/checkout.php @@ -158,7 +158,7 @@ function taler_pay(form) /* display contract_requestificate (i.e. it sends the JSON string to the extension) alert (contract_request.responseText); */ console.log("response text:", contract_request.responseText); - handle_contract(contract_request.responseText); + //handle_contract(contract_request.responseText); } else { diff --git a/src/frontend_blog/README b/src/frontend_blog/README @@ -1,20 +0,0 @@ -This directory contains the files implementing the frontend of the new merchant architecture. - -Only tested on nginx. To run the website, it suffices to have all the .php and .html files -in the same directory, and having PHP (with the extension 'pecl_http' enabled) enabled. - -File |What implements --------------------------------- -o index.html | The homepage. Here it is possible to decide how much donate - to whom you would like. - -o fake_wire_transfer.php | PHP script that takes the wire transfer request and passes it on - | to the /admin/add/incoming API of the demo-mint. - -o checkout.php | The "payment selection" that is the form - that allows the user to choose the payment method he wishes to use. - It also implements the request of certificate and trigger the certificate - viewer in the extension when it arrives in the customer's machine. - -o pay.php | Actual receiving of money, plus it gives back a "fullfillment" page - that informs the user of his well ended deal. diff --git a/src/frontend_blog/essay_checkout.php b/src/frontend_blog/essay_checkout.php @@ -99,6 +99,7 @@ function taler_pay(form) { /* display contract_requestificate (i.e. it sends the JSON string to the extension) alert (contract_request.responseText); */ + console.log("contract here"); console.log("response text:", contract_request.responseText); handle_contract(contract_request.responseText); } diff --git a/src/frontend_blog/essay_fulfillment.php b/src/frontend_blog/essay_fulfillment.php @@ -1,5 +1,6 @@ <?php +include("./blog_lib.php"); session_start(); if (!isset($_GET['article'])){ diff --git a/src/frontend_blog/essay_pay.php b/src/frontend_blog/essay_pay.php @@ -21,7 +21,10 @@ * 2. augment the deposit permission with missin values * 3. forward payment to backend */ +include("../frontend_lib/merchants.php"); +include("./blog_lib.php"); +session_start(); if (!isset($_SESSION['H_contract'])) { echo "No session active."; @@ -33,8 +36,8 @@ 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); + $url = (new http\URL($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])) + ->mod(array ("path" => "essay_fulfillment.php?article=".$_SESSION['article']), http\Url::JOIN_PATH); header("Location: $url"); die(); } @@ -44,15 +47,17 @@ $post_body = file_get_contents('php://input'); $deposit_permission = json_decode ($post_body, true); $to_add = array('max_fee' => array('value' => 3, 'fraction' => 8, - 'currency' => $_SESSION['currency']), + 'currency' => $_SESSION['article_currency']), 'amount' => array('value' => $_SESSION['article_value'], 'fraction' => $_SESSION['article_fraction'], 'currency' => $_SESSION['article_currency'])); $complete_deposit_permission = array_merge($deposit_permission, $to_add); + $resp = give_to_backend($_SERVER['HTTP_HOST'], "backend/pay", - $complete_deposit_permission); + json_encode($complete_deposit_permission, JSON_PRETTY_PRINT)); $status_code = $resp->getResponseCode(); +file_put_contents("/tmp/log", "gotten smth from backend, status: " . $status_code); // Our response code is the same we got from the backend: http_response_code ($status_code); // Now generate our body @@ -74,7 +79,7 @@ else 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"), http\Url::JOIN_PATH); + ->mod(array ("path" => "essay_fulfillment.php?article=$article"), http\Url::JOIN_PATH); header("Location: $url"); die(); }