commit 04dcab347402c1aca1029e80bd05556e2f1641fb
parent d0b8cc5ad517c445f591c7f1cb7ca43212fa169e
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Fri, 22 Apr 2016 20:52:40 +0200
wallet-less testing #4452
Diffstat:
6 files changed, 12 insertions(+), 51 deletions(-)
diff --git a/copylib/util.php b/copylib/util.php
@@ -42,7 +42,7 @@ function article_state_to_str($article_state){
}
function log_string($str){
- file_put_contents("/tmp/blog.dbg", $str . "\n", FILE_APPEND);
+ file_put_contents("/tmp/frontend.dbg", $str . "\n", FILE_APPEND);
}
function get_full_uri(){
diff --git a/examples/shop/fulfillment.php b/examples/shop/fulfillment.php
@@ -98,7 +98,7 @@ if (array() === $my_payment || true !== get($my_payment["is_payed"], false)) {
}
$hc = json_decode($resp->body->toString(), true)['H_contract'];
- $my_payment['ispayed'] = false;
+ $my_payment['is_payed'] = false;
$my_payment['hc'] = $hc;
echo "<p>you have not payed for this contract: " . $hc . "</p>";
echo "<p>Asking the wallet to re-execute it ... </p>";
diff --git a/examples/shop/generate_taler_contract.php b/examples/shop/generate_taler_contract.php
@@ -69,6 +69,8 @@ $contract = generate_contract(array(
"fulfillment_url" => $fulfillment_url)
);
+file_put_contents("/tmp/ff.link", $fulfillment_url . "\r\n");
+
$resp = give_to_backend("backend/contract", $contract);
// Our response code is the same we got from the backend:
diff --git a/examples/shop/index.php b/examples/shop/index.php
@@ -16,6 +16,7 @@
-->
<?php
require_once "../../copylib/config.php";
+session_destroy();
?>
<html lang="en">
<head>
diff --git a/examples/shop/nginx_example.conf b/examples/shop/nginx_example.conf
@@ -1,40 +0,0 @@
-server {
- listen 80; ## listen for ipv4; this line is default and implied
- # listen [::]:80 default_server ipv6only=on; ## listen for ipv6
- server_name example.com;
-
- # WARNING the 'shop' directory can't be freely moved in your filesystem
- # because it includes some PHP files via relative path (../../copylib)
- root /path/to/merchant/examples/shop;
- index index.php;
-
- # Make site accessible from http://localhost/
-
- location / {
- try_files $uri $uri/ =404;
- rewrite /taler/pay /pay.php;
- rewrite /taler/contract /generate_taler_contract.php;
-
- }
-
- location /fullfillment {
- rewrite /(.*) /$1.php;
-
- }
-
- location ~ \.php$ {
-
- fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
-
- }
-
- location /backend {
- rewrite /backend/(.*) /$1 break;
- proxy_pass http://127.0.0.1:19966;
- proxy_redirect off;
- proxy_set_header Host $host;
- }
-
-}
diff --git a/examples/shop/pay.php b/examples/shop/pay.php
@@ -30,10 +30,10 @@ if (empty($receiver))
return;
}
+session_start();
$payments = &pull($_SESSION, "payments", array());
-$my_payment = get($payments[$receiver]);
-if (null === $my_payment)
+if (!isset($payments[$receiver]))
{
http_response_code(400);
echo json_encode(array(
@@ -42,12 +42,15 @@ if (null === $my_payment)
return;
}
+echo 'recognized session';
+echo 'with hash ' . $payments[$receiver]['hc'];
+die();
$post_body = file_get_contents('php://input');
$deposit_permission = json_decode ($post_body, true);
// Check if the receiver is actually *mentioned* in the contract
-if ($my_payment['hc'] != $deposit_permission['H_contract']) {
+if ($payments[$receiver]['hc'] != $deposit_permission['H_contract']) {
$json = json_encode(
array(
@@ -96,12 +99,7 @@ if ($status_code != 200)
die();
}
-session_start();
-
$payments = &pull($_SESSION, "payments", array());
-$payments[$hc] = array(
- 'receiver' => $receiver,
- 'is_payed' => true
-);
+$payments[$receiver]['is_payed'] = true;
?>