This repository has been archived by the owner on Mar 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
55 lines (46 loc) · 1.66 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(function() {
"use strict";
function showResult(result, error) {
$('#error').text(error ? error.toString(): "");
$('#results span').text(result);
}
function logProductInfo(productInfo) {
console.log('productInfo:', productInfo);
if (productInfo && productInfo.receiptInfo) {
console.log('receipt status:', productInfo.receiptInfo.status);
if (productInfo.receiptInfo.reason) {
console.log('receipt status reason:', productInfo.receiptInfo.reason);
}
}
}
fxpay.configure({
allowTestReceipts: true,
receiptCheckSites: [
// Allow the production service.
'https://receiptcheck.marketplace.firefox.com',
'https://marketplace.firefox.com',
// The following would not be needed in a live app. These our some test
// services for development of the fxpay library only.
// Allow our test servers.
'https://receiptcheck-dev.allizom.org',
'https://receiptcheck-marketplace-dev.allizom.org',
'https://receiptcheck-payments-alt.allizom.org',
'https://marketplace-dev.allizom.org',
'https://marketplace.allizom.org',
'https://payments-alt.allizom.org',
// Allow some common local servers..
'http://mp.dev',
'http://fireplace.loc',
],
});
fxpay.validateAppReceipt().then(function(productInfo) {
logProductInfo(productInfo);
console.log('receipt is valid; app was purchased');
console.log('product URL:', productInfo.productUrl);
showResult('VALID');
}).catch(function(reason) {
logProductInfo(reason.productInfo);
showResult('INVALID', reason.error || reason);
});
console.log('initialized hosted paid app');
})();