win-iap

Verifies windows store receipts.

Usage no npm install needed!

<script type="module">
  import winIap from 'https://cdn.skypack.dev/win-iap';
</script>

README

win-iap

Verifies windows store (in app) purchase receipts.

Based on Validating Windows Mobile App Store Receipts Using Node.js.

Developed for ProSiebenSat.1 Digital GmbH.

Install

npm install win-iap

Usage

var receipt = '<receiptXML/>';
var Verifier = require('win-iap');
var verifier = new Verifier();
verifier
  .verify(receipt)
  .then(function(response) {
    console.log('Valid receipt.');
    console.log('id: '+response.id);
    console.log('purchased: '+response.startTimeMillis);
    console.log('expires: '+response.expiryTimeMillis);
  })
  .catch(function(err) {
    console.log('Invalid receipt: ', err);
  });

API

new Verifier(options)

Options is an optional object with the following possible fields:

  • certURL: The url to download certificates from. Defaults to 'https://go.microsoft.com/fwlink/?LinkId=246509&cid=#{ID}'.
  • certCache: An object with a get(id) and set(id, val) method for caching certificates. The methods may return promises for async operation. Defaults to new Verifier.MemoryCache().

verifier.verify(receipt)

Returns a promise for verifying the given receipt XML string. The promise will resolve if the receipt is valid, or raise an error if it is invalid or can't be verified for other reasons.

Errors will have a verifyErr property which can have the following values:

  • 'badsignature': The signature did not match.
  • 'badxml': The receipt XML was invalid.
  • 'badfetch': The certificate could not be fetched.

License

MIT License.