quick3.3 iap二次验证

 

https://github.com/RyanCopley/Express-iAP-Verifier/blob/2faf13b6f247f071babc48476c878f267e252c29/app.js https://www.npmjs.com/search?q=body-parser

  • storeProvider.setReceiptVerifyMode(cc.CCStoreReceiptVerifyModeNone, sandbox)
  • storeProvider.setReceiptVerifyServerUrl(“”)
  • storeProvider.setReceiptVerifyMode(cc.CCStoreReceiptVerifyModeServer, sandbox)
  • storeProvider.setReceiptVerifyServerUrl(“http://115.28.54.145:8080/validate”)

//The rest is good from here

var express = require("express");
  var app = express();
  var IAPVerifier = require("iap_verifier");
  var bodyParser = require("body-parser")
  app.use( bodyParser.json() );
  app.use( bodyParser.urlencoded() );
  var client = new IAPVerifier("blahblah");
  var appBundles = ["com.tt.t"];
  app.post("/validate", function(req, res){
     if (typeof req.body.receipt !== "undefined"){
         var receiptData = req.body.receipt.receipt;
          console.log(receiptData);
          var bundleId = req.body.receipt.bundleId;
          if (appBundles.indexOf(bundleId) != -1){
              client.verifyReceipt(req.body.receipt, function(valid, msg, data) {
                  res.json({valid:valid});
              });
          }else{
              res.json({valid:false});
          }
      }else{
          res.json({valid:false});
      }
  });

  var server = app.listen(8080, function() {
      console.log("Listening on port %d", server.address().port);