#colman1000

1 messages · Page 1 of 1 (latest)

old starBOT
worthy vapor
#

Can you share your code?

dusky vault
#

The entire component?

worthy vapor
#

Well, the Stripe relevant parts yes

#

Also are there any errors in your browser console when viewing the page you expect to see the Element on

dusky vault
#
<template>

...
<div v-if="showCardOverlay" class="h-screen w-screen flex fixed z-50" style="background: #0f172add">
      <form id="payment-form"
            class="container mx-auto align-middle flex flex-col justify-center items-center px-4 my-auto w-2/5 h-2/4 bg-slate-100 rounded-lg">
        <div
            class="align-middle flex flex-col justify-center items-center bg-amber-100 text-amber-800 px-40 py-5 mb-10 rounded-lg">
          <div class="my-2">This Event is a paid event</div>
          <div class="">You have to pay to get access</div>
        </div>

        <div class="space-x-1">{{ event.title }}</div>
        <div class="space-x-1">{{ event.description }}</div>
        <div class="mb-10">{{ event.creator.name }}</div>
        <div id="card-element"></div>
        <div id="card-errors" role="alert" class="text-red-500 text-sm mb-10 italic"></div>
        <button v-if="isPayingForEvent" class="ring ring-blue-300 hover:ring-blue-500 rounded-md p-2 mx-auto">
          Paying ...
        </button>
        <button v-else class="ring ring-blue-300 hover:ring-blue-500 rounded-md p-2 mx-auto" @click="payForEventNow">
          Pay Now - {{ event.price }} USD
        </button>
      </form>
    </div>
...

</template>

#

<script setup lang="ts">

import {loadStripe, Stripe, StripeCardElement} from "@stripe/stripe-js";

const stripeKey = ref('pk_test_51...') // test key
const instanceOptions = ref({})
const elementsOptions = ref({
  appearance: {
    theme: 'night',
    labels: 'floating',
    variables: {
      colorPrimary: '#0570de',
    }
  }
})
let showCardOverlay: Ref<boolean> = ref(false);
let cardElement: Ref<StripeCardElement> = ref(null);
let stripe: Ref<Stripe> = ref(null);
...

async function startPaymentFlow() {
  stripe.value = await loadStripe(stripeKey.value);
  const el = stripe.value.elements();
  const style = {
    base: {
      color: "#32325d",
    }
  };

  cardElement.value = el.create("card", {style: style});
  // Set up Stripe.js and Elements to use in checkout form
  cardElement.value.mount('#card-element');
  cardElement.value.focus();
  cardElement.value.on('change', ({error}) => {
    let displayError = document.getElementById('card-errors');
    if (error) {
      displayError.textContent = error.message;
    } else {
      displayError.textContent = '';
    }
  });
}

</script>
worthy vapor
#

I'd recommend looking at vue-stripe as linked which has specific Vue bindings

dusky vault
#

I see thanks... Does it have support for Vue3 though?

worthy vapor
#

I don't know I'm afraid it's not an official library

dusky vault
worthy vapor
#

Sorry, not very familiar with Vue. Is there somewhere I can reproduce the issue?

dusky vault
worthy vapor
dusky vault
dusky vault
worthy vapor
#

Yeah, not sure unfortunately