pay.php (815B)
1 <?php 2 // This file is in the public domain. 3 4 include "backend.php"; 5 include "error.php"; 6 7 session_start(); 8 if(!isset($_SESSION["paid"])){ 9 echo "<p>No session active. Aborting.</p>"; 10 return; 11 } 12 // Get coins. 13 $body = json_decode(file_get_contents("php://input")); 14 15 $response = post_to_backend("/pay", $body); 16 $body = json_decode($response["body"]); 17 $_SESSION["order_id"] = $body->contract_terms->order_id; 18 http_response_code($response["status_code"]); 19 header("Content-Type: application/json"); 20 21 if (200 != $response["status_code"]){ 22 echo build_error($response, 23 "Could not send payment to backend", 24 $response["status_code"]); 25 return; 26 } 27 // Payment went through! 28 $_SESSION["paid"] = true; 29 echo json_encode($body); 30 return; 31 ?>