<script>
import { onMount } from 'svelte';
let stripeReady = false;
let mounted = false;
function stripeSourceHandler(source) {
// Redirect the customer to the authorization URL.
document.location.href = source.redirect.url;
}
onMount(() => {
mounted = true;
if (stripeReady) {
loadStripeElements();
}
});
function stripeLoaded() {
stripeReady = true;
if (mounted) {
loadStripeElements();
}
}
function loadStripeElements() {
// await sleep(500);
// Create a Stripe client.
// Note: this merchant has been set up for demo purposes.
const stripe = Stripe('pk_test_6pRNASCoBOKtIshFeQd4XMUh');
// Create an instance of Elements.
var elements = stripe.elements();
// Custom styling can be passed to options when creating an Element.