UNPKG

stripe-react-native-apple-pay

Version:

React Native wrapper around Stripe Apple Pay

67 lines (66 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.confirmApplePayPayment = void 0; exports.initStripe = initStripe; exports.isApplePaySupported = isApplePaySupported; exports.presentApplePay = presentApplePay; var _NativeStripeSdk = _interopRequireDefault(require("./NativeStripeSdk")); var _ApplePay = require("./types/ApplePay"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function initStripe(params) { return _NativeStripeSdk.default.initialise(params); } function isApplePaySupported() { return _NativeStripeSdk.default.isApplePaySupported(); } const APPLE_PAY_NOT_SUPPORTED_MESSAGE = 'Apple pay is not supported on this device'; async function presentApplePay(params, clientSecret) { if (!(await _NativeStripeSdk.default.isApplePaySupported())) { return { error: { code: _ApplePay.ApplePayError.Canceled, message: APPLE_PAY_NOT_SUPPORTED_MESSAGE } }; } try { const { result, error } = await _NativeStripeSdk.default.presentApplePay(params, clientSecret); if (error) { return { error }; } return { result }; } catch (error) { return { error }; } } const confirmApplePayPayment = async clientSecret => { if (!(await _NativeStripeSdk.default.isApplePaySupported())) { return { error: { code: _ApplePay.ApplePayError.Canceled, message: APPLE_PAY_NOT_SUPPORTED_MESSAGE } }; } try { await _NativeStripeSdk.default.confirmApplePayPayment(clientSecret); return {}; } catch (error) { return { error }; } }; exports.confirmApplePayPayment = confirmApplePayPayment; //# sourceMappingURL=functions.js.map