#bernz-ece-subscription

1 messages · Page 1 of 1 (latest)

severe questBOT
forest current
#

@atomic wind not sure I follow, ExpressCheckoutElement specifically does not need a client_secret upfront.

#

bernz-ece-subscription

atomic wind
#

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.

forest current
#

Can you share some exact code?

atomic wind
#

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
    }
}```
forest current
#

hum what guide are yo ufollowing exactly?

#

You have ExpressCheckoutElement (quite new) in the middle of the really old/legacy CardElement with split fields

atomic wind
#

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

forest current
#

sure but what exact doc are you following to integrate ExpressCheckoutElement.

atomic wind
forest current
#

okay so the first code example right there has options

#

did you maybe miss that because you mirrored the legacy code you had?

atomic wind
#

I know and have tried to set {mode: subscription, currency: 'usd', price: 9.99}

forest current
#

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

atomic wind
#

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)
        }
forest current
#

Okay so that exact code works totally fine for me and renders the Link button right now

atomic wind
#

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

forest current
#

Are you sure you get the error from where you think?

#

Add logs before/after that mount() call to confirm

atomic wind
#

Ah, just got it I think. You telling me that the code was legacy had me go looking for where we were loading stripe from. Conflict with older loaded package vs Stripe script call it looks like.

#

Thank you for your help.