woocommerce/packages/woocommerce-blocks/assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/load-stripe.js

23 lines
486 B
JavaScript
Raw Normal View History

2021-12-10 12:03:04 +00:00
/**
* External dependencies
*/
import { loadStripe } from '@stripe/stripe-js';
/**
* Internal dependencies
*/
import { getApiKey } from './utils';
const stripePromise = () =>
new Promise( ( resolve ) => {
try {
resolve( loadStripe( getApiKey() ) );
} catch ( error ) {
// In order to avoid showing console error publicly to users,
// we resolve instead of rejecting when there is an error.
resolve( { error } );
}
} );
export { stripePromise as loadStripe };