#bernz-ece-subscription
1 messages · Page 1 of 1 (latest)
@atomic wind not sure I follow, ExpressCheckoutElement specifically does not need a client_secret upfront.
bernz-ece-subscription
That's what I thought, but currently when I attempt to load it, it throws an error
Uncaught (in promise) Error: Unable to select session. Make sure Elements is initialized with clientSecret or use the nullableSessionSelector() instead.
Can you share some exact code?
Sure, give me a moment
async function loadStripeFields() {
// Load Stripe fields
try {
if(!stripe) throw 'Cannot load stripe'
const elements = stripe.elements()
// Initiate the elements
cardNumberElement.value = elements.create('cardNumber',{
classes: {
base: 'payment-number card-input'
}
})
cardExpiryElement.value = elements.create('cardExpiry', {
classes: {
base: 'payment-expiration card-input'
}
})
cardSecurityCodeElement.value = elements.create('cardCvc', {
classes: {
base: 'payment-cvc card-input'
}
})
// Still works and is supported despite documentation
cardPostalCodeElement.value = elements.create('postalCode', {
classes: {
base: 'payment-zip card-input'
}
})
expressCheckoutElement.value = elements.create('expressCheckout')
// Set ready handlers
// If all refs are available, mount the elements
if(cardRefsAvailable.value) {
cardNumberElement.value.mount(card_number.value)
cardExpiryElement.value.mount(card_expiry.value)
cardSecurityCodeElement.value.mount(card_security_code.value)
cardPostalCodeElement.value.mount(card_postal_code.value)
expressCheckoutElement.value.mount(express_checkout.value)
}
} catch (e) {
console.error("Error loading stripe fields -> ", e)
return null
}
}```
hum what guide are yo ufollowing exactly?
You have ExpressCheckoutElement (quite new) in the middle of the really old/legacy CardElement with split fields
Yeah, this comes from an older integration on another project that we want to include expressCheckout on, but I've been told to maintain the separated fields look as opposed to the singular card or payment element
sure but what exact doc are you following to integrate ExpressCheckoutElement.
okay so the first code example right there has options
did you maybe miss that because you mirrored the legacy code you had?
I know and have tried to set {mode: subscription, currency: 'usd', price: 9.99}
Fair, but you never shared any of that
Okay so can you share exact code that isn't working and remove all the unrelated things about CardElement? You can add it back later but we should focus on debugging your real question only first
Sure, give me a moment.
const elements = stripe.elements({
mode: 'subscription',
currency: 'usd',
amount: 999
})
// Initiate the elements
expressCheckoutElement.value = elements.create('expressCheckout')
// If all refs are available, mount the elements
if(cardRefsAvailable.value) {
expressCheckoutElement.value.mount(express_checkout.value)
}
Okay so that exact code works totally fine for me and renders the Link button right now
Weird, I might have to go over this more in the morning to see if anything about our dev environment is preventing this from working, but its a help to know that this part of the code is correct, so thank you for your time