How to use the @stripe/stripe-js.loadStripe function in @stripe/stripe-js

To help you get started, we’ve selected a few @stripe/stripe-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 3scale / porta / app / javascript / packs / invoice_payment.js View on Github external
document.addEventListener('DOMContentLoaded', async () => {
  const dataset = document.querySelector('.stripe-form').dataset
  const stripePublishableKey = dataset.publishableKey
  const clientSecret = dataset.clientSecret
  const form = document.querySelector('#payment-form')
  const callbackForm = document.querySelector('#payment-callback-form')
  const payButton = document.querySelector('#submit-payment')
  const cardError = document.querySelector('#card-error')
  const errorMsg = document.querySelector('#card-error')
  const spinner = document.querySelector('#spinner')
  const buttonText = document.querySelector('#button-text')

  const stripe = await loadStripe(stripePublishableKey)
  const elements = stripe.elements()
  const card = elements.create('card', { style })

  const payWithCard = (stripe, card, clientSecret) => {
    setLoading(true)
    stripe.confirmCardPayment(clientSecret, {
      payment_method: {
        card: card
      }
    }).then(function (result) {
      if (result.error) {
        showError(result.error.message)
      } else {
        orderComplete(result.paymentIntent)
      }
    })
github Automattic / newspack-plugin / assets / wizards / payment / index.js View on Github external
.then( async data => {
				const { stripe_publishable_key: stripePublishableKey, session_id: sessionId } = data;
				const stripe = await loadStripe( stripePublishableKey );
				stripe.redirectToCheckout( { sessionId } );
			} )
			.catch( error => {
github 3scale / porta / app / javascript / src / PaymentGateways / stripe / components / StripeFormWrapper.jsx View on Github external
const StripeElementsForm = ({ stripePublishableKey, setupIntentSecret, billingAddressDetails, successUrl, isCreditCardStored }: Props): React.Node => {
  const stripePromise = loadStripe(stripePublishableKey)

  return (
    
      
    
  )
}

@stripe/stripe-js

Stripe.js loading utility

MIT
Latest version published 20 days ago

Package Health Score

92 / 100
Full package analysis

Popular @stripe/stripe-js functions