summaryrefslogtreecommitdiff
path: root/php/fulfillment.php
blob: ce4174db89de781b9556be23722555e69bfd30bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
  // This file is in the public domain.

  include 'helpers.php';

  session_start();

  if(pull($_SESSION, 'paid', false)){
    echo sprintf("<p>Thanks for your donation!</p>
                  <br><p>The order ID is: <b>%s</b>; use it to
                  <a href=\"backoffice.html\">track</a> your money,
                  or make <a href=\"/\">another donation!</a></p>",
                  $_SESSION['order_id']);
    session_destroy();
    return;
  }

  // The user needs to pay, instruct the wallet to send the payment.
  http_response_code(402);
  header('X-Taler-Contract-Url: ' . url_rel('/generate-order.php'));
  header('X-Taler-Contract-Query: ' . "fulfillment_url");
  header('X-Taler-Offer-Url: ' . url_rel('/donate.php'));
  return;
?>