November 2018
Intermediate to advanced
528 pages
13h 21m
English
As defined by the protocol, when the customer clicks on the payment link, its wallet (bitcoin client) will request the /request endpoint to get the merchant's payment request with all the necessary data:
var urlencodedParser = bodyParser.urlencoded({ extended: false }); app.get("/request", urlencodedParser, function(req, res) { var amount = req.query.amount; amount = (amount === undefined) ? 0 : amount; // set amount to 0 if undefined var merchant_outputs = []; // Where payment should be sent var outputs = new PaymentProtocol().makeOutput(); outputs.set('amount', amount); var script = bitcore_lib.Script.buildPublicKeyHashOut(Merchant_address.toString()); outputs.set('script', script.toBuffer()); merchant_outputs.push(outputs.message); ...Read now
Unlock full access