merchant-frontend-examples

ZZZ: Inactive/Deprecated
Log | Files | Refs

commit cac920b79aa3aa5e572ce27b048ded7cf36ba500
parent 3b24f495d02dc9a48f5bbf6512752e7bf60e1bbc
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date:   Wed, 16 Nov 2016 16:48:40 +0100

setting http status code within build_error()

Diffstat:
Mphp/error.php | 3++-
Mphp/fulfillment.php | 4+++-
Mphp/generate-contract.php | 4+++-
Mphp/pay.php | 4+++-
Mphp/track-input.php | 4++--
5 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/php/error.php b/php/error.php @@ -2,7 +2,8 @@ include 'copying.php'; - function build_error($response, $hint){ + function build_error($response, $hint, $http_code){ + http_response_code($http_code); return json_encode(array( 'error' => "internal error", 'hint' => $hint, diff --git a/php/fulfillment.php b/php/fulfillment.php @@ -25,7 +25,9 @@ $response = post_to_backend("/contract", $rec_proposal); http_response_code($response["code"]); if (200 != $response["status_code"]) { - echo build_error($response, "Failed to reconstruct the contract"); + echo build_error($response, + "Failed to reconstruct the contract", + $response['code']); return; } // The user needs to pay, instruct the wallet to send the payment. diff --git a/php/generate-contract.php b/php/generate-contract.php @@ -15,7 +15,9 @@ // We always return verbatim what the backend returned http_response_code($response["status_code"]); if (200 != $response["status_code"]) { - echo build_error($response, "Failed to generate contract"); + echo build_error($response, + "Failed to generate contract", + $response['code']); return; } echo $response["body"]; diff --git a/php/pay.php b/php/pay.php @@ -13,7 +13,9 @@ $response = post_to_backend("/pay", json_decode($body)); http_response_code($response['status_code']); if (200 != $response['status_code']){ - echo build_error($response, "Could not send paymnet to backend"); + echo build_error($response, + "Could not send paymnet to backend", + $response['status_code']); return; } // Payment went through! diff --git a/php/track-input.php b/php/track-input.php @@ -8,11 +8,11 @@ </head> <body> <form action='/track-transaction.php' method='GET'> - <input type='text' name='input'><> + <input type='text' name='tid'><> <input type='submit' value='Track transaction'></input> </form> <form action='/track-transfer.php' method='GET'> - <input type='text' name='input'><> + <input type='text' name='wtid'><> <input type='submit' value='Track transfer'></input> </form> </body>