var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { default as ApplePayBase } from './ApplePay.base';
export default class ApplePayWeb extends ApplePayBase {
    constructor(merchantIdentifier) {
        super(merchantIdentifier);
        this.theWindow = window;
    }
    isEnabled() {
        return this.theWindow && this.theWindow.ApplePaySession;
    }
    canCallSetup() {
        return this.theWindow
            && this.theWindow.ApplePaySession
            && this.theWindow.ApplePaySession.openPaymentSetup;
    }
    hasActiveCard() {
        return __awaiter(this, void 0, void 0, function* () {
            if (this.theWindow && this.theWindow.ApplePaySession) {
                const ApplePaySession = this.theWindow.ApplePaySession;
                return ApplePaySession.canMakePaymentsWithActiveCard(this.merchantIdentifier);
            }
            else {
                return Promise.reject(new Error('Apple Pay is not enabled on this device.'));
            }
        });
    }
    setupApplePay() {
        return __awaiter(this, void 0, void 0, function* () {
            if (this.theWindow && this.theWindow.ApplePaySession) {
                const ApplePaySession = this.theWindow.ApplePaySession;
                return ApplePaySession.openPaymentSetup(this.merchantIdentifier);
            }
            else {
                return Promise.reject(new Error('Apple Pay is not enabled on this device.'));
            }
        });
    }
}
//# sourceMappingURL=ApplePay.web.js.map