merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 1108f7ca4dbe418c4e641ba07b6d14316daa1f1d
parent 8782d4352ee6bd7f2a5acafe3c8b28fa969e946f
Author: Florian Dold <florian.dold@gmail.com>
Date:   Wed,  2 Mar 2016 04:36:04 +0100

parse json before giving it to wallet

Diffstat:
Mexamples/blog/essay_cc-form.html | 7++++++-
Mexamples/shop/checkout.php | 7++++++-
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/examples/blog/essay_cc-form.html b/examples/blog/essay_cc-form.html @@ -46,7 +46,12 @@ if (contract_request.status == 200) { console.log("response text:", contract_request.responseText); - handle_contract(contract_request.responseText); + var contract_wrapper = JSON.parse(contract_request.responseText); + if (!contract_wrapper) { + console.error("response text was invalid json"); + return; + } + handle_contract(contract_wrapper); } else { alert("Failure to download contract from merchant " + "(" + contract_request.status + "):\n" + diff --git a/examples/shop/checkout.php b/examples/shop/checkout.php @@ -157,7 +157,12 @@ function taler_pay(form) { /* display contract_requestificate (i.e. it sends the JSON string to the extension) alert (contract_request.responseText); */ console.log("response text:", contract_request.responseText); - handle_contract(contract_request.responseText); + var contract_wrapper = JSON.parse(contract_request.responseText); + if (!contract_wrapper) { + console.error("response text is invalid JSON"); + return; + } + handle_contract(contract_wrapper); } else { /* There was an error obtaining the contract from the merchant, obviously this should not happen. To keep it simple, we just