#alexjoom_code

1 messages Β· Page 1 of 1 (latest)

flint nicheBOT
#

πŸ‘‹ Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

πŸ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1368902167749984278

πŸ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

lilac tendon
#

Hi, let me help you with this.

#

What is the exact issue you're facing?

hushed heart
#

I'm not able to load a custom font in my Stripe Element. I'd like to use the Montserrat font, but it doesn't seem to work.

#
document.addEventListener('DOMContentLoaded', () => {
            const stripe = Stripe('{{ stripePublicKey }}');

            const appearance = {
                variables: {
                    fontSizeSm: '16px',
                    colorText: '#121212',
                    fontFamily: 'Montserrat',
                }
            }

            const elementsCB = stripe.elements({
                clientSecret: '{{ clientSecretCB }}',
                appearance: appearance,
                fonts: [
                    {
                        family: 'Montserrat',
                        weight: '400',
                        src: 'url(https://fonts.gstatic.com/s/montserrat/v29/JTUSjIg1_i6t8kCHKm459W1hyzbi.woff2) format("woff2")',
                    },
                ],
            });
            const paymentElement = elementsCB.create('payment', {
                style: {
                    base: {
                        fontFamily: '"Montserrat", sans-serif',
                        fontSize: '16px',
                        color: '#32325d',
                    },
                },
            });
            paymentElement.mount('#payment-cb');
       })
lilac tendon
#

Where do you see that it doesn't work exactly? Do you have a screenshot?

flint nicheBOT
hushed heart
#

The font doesn't change 😦

hushed heart
#

Ok thx, new code (same problem) :

            const stripe = Stripe('{{ stripePublicKey }}');

            const appearance = {
                variables: {
                    fontSizeSm: '16px',
                    colorText: '#121212',
                    fontFamily: 'Montserrat',
                }
            }

            const elementsCB = stripe.elements({
                clientSecret: '{{ clientSecretCB }}',
                appearance: appearance,
                fonts: [
                    {
                        family: 'Montserrat',
                        weight: '400',
                        src: 'url(https://fonts.gstatic.com/s/montserrat/v29/JTUSjIg1_i6t8kCHKm459W1hyzbi.woff2) format("woff2")',
                    },
                ],
            });
            const paymentElement = elementsCB.create('payment');
            paymentElement.mount('#payment-cb');
wild cape
#

Let me do a quick test...

hushed heart
#

Thx

wild cape
#

I just did a test with your code and I see the front updated

#

With font

#

Without font

hushed heart
#

Wtf

#

You are using HTTPS ? HTTP ? Wamp server ?

wild cape
#

Https

hushed heart
#

I use http with localhost

wild cape
#

I don't think that's an issue..

hushed heart
#

Ok

wild cape
# hushed heart

But wait, the font here is applied.. check the character N

hushed heart
#

Here is an uppercase 'N' with Montserra

wild cape
#

Can you comment the line fontFamily: 'Montserrat', and see the difference ?

hushed heart
#

CSS variable :
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif

wild cape
#

The font seems to be applied or at least there is a change...

hushed heart
#

I don't think so, because if I don't use any code to change the font, I get exactly the same result.

wild cape
#

Well, if you check the two screenshots you've shared, you'll see a difference

#

Check the N char

hushed heart
#

Yes, but i think sans-serif is use

#

Because if I remove the sans-serif, Montserrat alone doesn't work.

wild cape
#

Sorry, I'm not sure I understand the link between commenting the line fontFamily: 'Montserrat' in Stripe and the change with sans-serif ?

hushed heart
#

No problem, if i use this code :

            const appearance = {
                variables: {
                    fontSizeSm: '16px',
                    colorText: '#121212',
                    fontFamily: 'Montserrat, sans-serif',
                }
            }

It's the same result with :

            const appearance = {
                variables: {
                    fontSizeSm: '16px',
                    colorText: '#121212',
                    fontFamily: 'sans-serif',
                }
            }

And if i use only Montserrat, the font doesnt work :

            const appearance = {
                variables: {
                    fontSizeSm: '16px',
                    colorText: '#121212',
                    fontFamily: 'Montserrat',
                }
            }
#

So that's why I think Montserrat is not being loaded correctly, and I don't understand why.

wild cape
#

What about using:

const appearance = {
                variables: {
                    fontSizeSm: '16px',
                    colorText: '#121212',
                }
            }

and what is the difference between it and with fontFamily: 'Montserrat',

hushed heart
#

I would like to use Montserrat on the Stripe elements because I want to use the same font as the rest of my project.

wild cape
#

Yeah I understand that, but my point is according to the scrrenshots you've shared, there is a font change by adding fontFamily: 'Montserrat',

hushed heart
#

Look :

With my code :

            const stripe = Stripe('{{ stripePublicKey }}');

            const elementsCB = stripe.elements({
                clientSecret: '{{ clientSecretCB }}',
            });
            const paymentElement = elementsCB.create('payment');
            paymentElement.mount('#payment-cb');

I have this result :

#

And with that :

            const stripe = Stripe('{{ stripePublicKey }}');

            const appearance = {
                variables: {
                    fontSizeSm: '16px',
                    colorText: '#121212',
                    fontFamily: 'Montserrat',
                }
            }

            const elementsCB = stripe.elements({
                clientSecret: '{{ clientSecretCB }}',
                appearance: appearance,
                fonts: [
                    {
                        family: 'Montserrat',
                        weight: '300',
                        src: 'url(https://fonts.gstatic.com/s/montserrat/v29/JTUSjIg1_i6t8kCHKm459W1hyzbi.woff2) format("woff2")',
                    },
                ],
            });
            const paymentElement = elementsCB.create('payment');
            paymentElement.mount('#payment-cb');
wild cape
#

Yes exactly, see there is a difference in the font in these screenshots

#

Isn't that Montserrat? or at least the font of that url you are specifying ?

hushed heart
#

No its the default font 😦

wild cape
#

You mean in both screenshots you've just shared, it's the same (default) font πŸ€”

#

I'm seeing difference fonts actually πŸ˜…

hushed heart
#

Yes, me too x)

But in the first screenshot, it's the default Stripe font that's being used:
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif

And in the second one, it's the browser's default font because Montserrat fails to load.

wild cape
#

because Montserrat fails to load.
Ah do you see any logs for this ?

hushed heart
#

I have only :
v3/:1 You may test your Stripe.js integration over HTTP. However, live Stripe.js integrations must use HTTPS.

wild cape
#

Ok, this issue will require an in-depth investigation from our team in order to figure out the root cause. Can we ask that you write in to us via https://support.stripe.com/contact, providing as much detail and context as possible (you can also reference this thread).

flint nicheBOT
#

Hello @hushed heart, we have sent you a direct message, please check it at https://discord.com/channels/@me/1368931267483144343

  • πŸ”—The message has instructions on how to open a direct support case with our Developer Support team, in order to help you more effectively.
hushed heart
#

Thanks ! πŸ™‚