summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <dold@inria.fr>2015-12-23 22:13:55 +0100
committerFlorian Dold <dold@inria.fr>2015-12-23 22:13:55 +0100
commit86b26a1e1044ba19af51eda6adf2a382a8a0a734 (patch)
tree47d1bed91681941dacbd4a0a33bec6679d50ee11
parent8cd1502eb8ffc4d44657d8260311e8fef1cbce4e (diff)
downloadmerchant-86b26a1e1044ba19af51eda6adf2a382a8a0a734.tar.gz
merchant-86b26a1e1044ba19af51eda6adf2a382a8a0a734.tar.bz2
merchant-86b26a1e1044ba19af51eda6adf2a382a8a0a734.zip
Fix URLs
-rw-r--r--src/frontend/generate_taler_contract.php27
-rw-r--r--src/frontend/pay.php11
2 files changed, 27 insertions, 11 deletions
diff --git a/src/frontend/generate_taler_contract.php b/src/frontend/generate_taler_contract.php
index ababa832..14add359 100644
--- a/src/frontend/generate_taler_contract.php
+++ b/src/frontend/generate_taler_contract.php
@@ -35,10 +35,10 @@
$cli_debug = false;
$backend_test = true;
-if ($_GET['cli_debug'] == 'yes')
+if (isset($_GET['cli_debug']) && $_GET['cli_debug'] == 'yes')
$cli_debug = true;
-if ($_GET['backend_test'] == 'no')
+if (isset($_GET['backend_test']) && $_GET['backend_test'] == 'no')
{
$cli_debug = true;
$backend_test = false;
@@ -90,6 +90,9 @@ $teatax = array ('value' => 1,
// Take a timestamp
$now = new DateTime('now');
+$PAY_URL = "pay.php";
+$EXEC_URL = "execute.php";
+
// pack the JSON for the contract
// --- FIXME: exact format needs review!
$contract = array ('amount' => array ('value' => $amount_value,
@@ -110,8 +113,8 @@ $contract = array ('amount' => array ('value' => $amount_value,
'delivery_date' => "Some Date Format",
'delivery_location' => 'LNAME1')),
'timestamp' => "/Date(" . $now->getTimestamp() . ")/",
- 'pay_url' => "/taler/pay",
- 'exec_url' => "http://example.com/exec-url",
+ 'pay_url' => $PAY_URL,
+ 'exec_url' => $EXEC_URL,
'expiry' => "/Date(" . $now->add(new DateInterval('P2W'))->getTimestamp() . ")/",
'refund_deadline' => "/Date(" . $now->add(new DateInterval('P3M'))->getTimestamp() . ")/",
'merchant' => array ('address' => 'LNAME2',
@@ -140,19 +143,21 @@ $contract = array ('amount' => array ('value' => $amount_value,
'region' => 'Test Region',
'province' => 'Test Province',
'ZIP code' => 4908)));
-$json = json_encode (array ('contract' => $contract), JSON_PRETTY_PRINT);
+$json = json_encode (array ('contract' => $contract, 'exec_url' => $EXEC_URL, 'pay_url' => $PAY_URL), JSON_PRETTY_PRINT);
if ($cli_debug && !$backend_test)
{
echo $json . "\n";
exit;
}
-// Craft the HTTP request, note that the backend
-// could be on an entirely different machine if
-// desired.
-$req = new http\Client\Request ("POST",
- "http://" . $_SERVER["SERVER_NAME"] . "/backend/contract",
- array ("Content-Type" => "application/json"));
+
+$url = (new http\URL("http://".$_SERVER["HTTP_HOST"]))
+ ->mod(array ("path" => "backend/contract"), http\Url::JOIN_PATH);
+
+$req = new http\Client\Request("POST",
+ $url,
+ array ("Content-Type" => "application/json"));
+
$req->getBody()->append ($json);
// Execute the HTTP request
diff --git a/src/frontend/pay.php b/src/frontend/pay.php
index 7f7a8bc9..11725c63 100644
--- a/src/frontend/pay.php
+++ b/src/frontend/pay.php
@@ -48,6 +48,17 @@ 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("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"))
+ $url = (new http\URL("http://$_SERVER[HTTP_HOST]"))
+ ->mod(array ("path" => "fulfillment.php"), http\Url::JOIN_PATH);
+ header("Location: $url");
+ die();
+}
+
$post_body = file_get_contents('php://input');
$now = new DateTime('now');