commit 2dc1a1002e9b848009628794d7034273d7f78c6c
parent d40f97186cd0e7d8f5fc569fb26b82040fee9ae7
Author: Florian Dold <florian.dold@gmail.com>
Date: Mon, 25 Jan 2016 18:08:12 +0100
update session info on payment
Diffstat:
2 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/src/frontend/fulfillment.php b/src/frontend/fulfillment.php
@@ -82,7 +82,7 @@ if (null === $my_payment)
if (true !== get($my_payment["is_payed"], false))
{
- $pay_url = url_rel("pay.php", true);
+ $pay_url = url_rel("pay.php");
echo "<p>you have not payed for this contract: " . $hc . "</p>";
echo "<p>Asking the wallet to re-execute it ... </p>";
echo "<script>executePayment('$hc', '$pay_url');</script>";
diff --git a/src/frontend/pay.php b/src/frontend/pay.php
@@ -18,29 +18,30 @@
include '../frontend_lib/util.php';
-function respond_success() {
- $_SESSION['payment_ok'] = true;
- $json = json_encode(
- array(
- "fulfillment_url" => url_rel("fulfillment.php")));
- echo $json;
+$hc = get($_GET["uuid"]);
+
+if (empty($hc))
+{
+ http_response_code(400);
+ echo json_encode(array(
+ "error" => "missing parameter",
+ "parameter" => "uuid"
+ ));
+ return;
}
session_start();
-if (!isset($_SESSION['H_contract']))
-{
- $json = json_encode(
- array("error" => "No session active"));
- echo $json;
- http_response_code(401);
- die();
-}
+$payments = get($_SESSION['payments'], array());
+$my_payment = get($payments[$hc]);
-if (isset($_SESSION['payment_ok']) && $_SESSION['payment_ok'] == true)
+if (null === $my_payment)
{
- respond_success();
- die();
+ http_response_code(400);
+ echo json_encode(array(
+ "error" => "no session active",
+ ));
+ return;
}
$post_body = file_get_contents('php://input');
@@ -96,11 +97,9 @@ if ($status_code != 200)
"status" => $status_code,
"detail" => $resp->body->toString()));
echo $json;
+ die()
}
-else
-{
- respond_success();
- die();
-}
+
+$my_payment["is_payed"] = true;
?>