2020-05-22 19:46:22 +00:00
|
|
|
import { EventEmitter } from 'events';
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2020-05-22 19:46:22 +00:00
|
|
|
let _inAppPurchase;
|
2019-03-13 20:56:01 +00:00
|
|
|
|
2018-04-02 23:55:44 +00:00
|
|
|
if (process.platform === 'darwin') {
|
2020-06-23 03:32:45 +00:00
|
|
|
const { inAppPurchase, InAppPurchase } = process._linkedBinding('electron_browser_in_app_purchase');
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2018-04-02 23:55:44 +00:00
|
|
|
// inAppPurchase is an EventEmitter.
|
2020-03-20 20:28:31 +00:00
|
|
|
Object.setPrototypeOf(InAppPurchase.prototype, EventEmitter.prototype);
|
|
|
|
EventEmitter.call(inAppPurchase);
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2020-05-22 19:46:22 +00:00
|
|
|
_inAppPurchase = inAppPurchase;
|
2018-04-02 23:55:44 +00:00
|
|
|
} else {
|
2020-05-22 19:46:22 +00:00
|
|
|
_inAppPurchase = new EventEmitter();
|
|
|
|
Object.assign(_inAppPurchase, {
|
|
|
|
purchaseProduct: () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
throw new Error('The inAppPurchase module can only be used on macOS');
|
2018-04-02 23:55:44 +00:00
|
|
|
},
|
|
|
|
canMakePayments: () => false,
|
|
|
|
getReceiptURL: () => ''
|
2020-05-22 19:46:22 +00:00
|
|
|
});
|
2018-04-02 23:55:44 +00:00
|
|
|
}
|
2020-05-22 19:46:22 +00:00
|
|
|
|
|
|
|
export default _inAppPurchase;
|