stripe-react-native-apple-pay
Version:
React Native wrapper around Stripe Apple Pay
56 lines • 1.31 kB
JavaScript
import NativeStripeSdk from './NativeStripeSdk';
import { ApplePayError } from './types/ApplePay';
export function initStripe(params) {
return NativeStripeSdk.initialise(params);
}
export function isApplePaySupported() {
return NativeStripeSdk.isApplePaySupported();
}
const APPLE_PAY_NOT_SUPPORTED_MESSAGE = 'Apple pay is not supported on this device';
export async function presentApplePay(params, clientSecret) {
if (!(await NativeStripeSdk.isApplePaySupported())) {
return {
error: {
code: ApplePayError.Canceled,
message: APPLE_PAY_NOT_SUPPORTED_MESSAGE
}
};
}
try {
const {
result,
error
} = await NativeStripeSdk.presentApplePay(params, clientSecret);
if (error) {
return {
error
};
}
return {
result
};
} catch (error) {
return {
error
};
}
}
export const confirmApplePayPayment = async clientSecret => {
if (!(await NativeStripeSdk.isApplePaySupported())) {
return {
error: {
code: ApplePayError.Canceled,
message: APPLE_PAY_NOT_SUPPORTED_MESSAGE
}
};
}
try {
await NativeStripeSdk.confirmApplePayPayment(clientSecret);
return {};
} catch (error) {
return {
error
};
}
};
//# sourceMappingURL=functions.js.map