#maciejgolis_klarna-messaging-element
1 messages ยท Page 1 of 1 (latest)
๐ 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/1221879525072175175
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi ๐
Can you share the front-end code you are using to create the Messaging element?
sure
export async function initStripePaymentMethodMessaging() {
//setTimeout(async () => {
paymentMethodMessageElements = queryDocument<HTMLElement>(config.paymentMethodMessageSelector);
if(paymentMethodMessageElements) {
stripe = await loadStripe(config.stripeApiKey, {
stripeAccount: config.stripeAccount
});
const elementOptions: StripeElementsOptionsClientSecret = {};
// appearance: {
// theme: 'stripe'
// },
// fonts: [{
// family: 'ariana-pro',
// src: 'url("https://use.typekit.net/af/1e9eba/00000000000000007735cbdf/30/l?primer=7cdcb44be4a7db8877ffa5c0007b8dd865b3bbc383831fe2ea177f62257a9191&fvd=n5&v=3")',
// weight: '500',
// style: 'normal',
// }]
// };
try {
const elements = stripe.elements(elementOptions);
paymentMethodMessageElements.forEach((paymentMethodMessageElement) => {
const options: StripePaymentMethodMessagingElementOptions = {
amount: parseFloat(paymentMethodMessageElement.dataset.amount) * 100,
currency: 'GBP',
countryCode: 'GB',
paymentMethodTypes: ['klarna', 'afterpay_clearpay', 'affirm'],
//paymentMethodTypes: ['klarna']
};
const paymentMessageElement = elements.create('paymentMethodMessaging', options);
paymentMessageElement.mount(`#${paymentMethodMessageElement.id}`);
});
}
catch(e) {
alert('error')
}
}
//}, 3000);
}
I'm guessing that the backticks for the template literal you are using got coverted to code formatting here.
correct
initially I had only klarna and that started returning empty iframe
I have examined the iframe content
{ "merchant_id": "acct_1J6b7FJojNje4Qu0", "payment_methods": [ "klarna" ], "partner_configs": {}, "api_feature_flags": [ { "key": "enable_demo_pay", "result": false }, { "key": "enable_apple_pay_later", "result": false }, { "key": "enable_affirm_prequalification_modal", "result": true }, { "key": "enable_single_line_view_v1", "result": true }, { "key": "disable_afterpay_payment_intent_confirmation_by_region", "result": false }, { "key": "enable_klarna_api", "result": false } ] }
If you go back to a hard-coded (non-looping) approach, does Klarna re-appear?
give me 2 mins
(it used to...)
`
const elements = stripe.elements(elementOptions);
var paymentMethodMessageElement = paymentMethodMessageElements[0];
const options: StripePaymentMethodMessagingElementOptions = {
amount: parseFloat(paymentMethodMessageElement.dataset.amount) * 100,
currency: 'GBP',
countryCode: 'GB',
//paymentMethodTypes: ['klarna', 'afterpay_clearpay', 'affirm'],
paymentMethodTypes: ['klarna']
};
const paymentMessageElement = elements.create('paymentMethodMessaging', options);
paymentMessageElement.mount(`#${paymentMethodMessageElement.id}`);
`
Okay and does this render the Messaging element?
Also, ca you you hard code the HTML element ID instead of using the template literal?
Okay and there's nothing visible showing up there?
And you are still not seeing the messaging element?
I am afraid not
I think it's an amount restriction. Try adding another 0, making int 550.00
I see Klarna disappearing when I change currency to GBP in my repro
let me flick to USD
weird!
also when you change the country in the docs -> https://docs.stripe.com/payments/payment-method-messaging?locale=en-GB
klarna does dissapear
and here we go:
Ah .... okay
sorry
International incident, at least it wasn't our code ๐
the whole point we are going it is to be compliant
and it did work last week
did throw me off!
thanks @knotty surge !
Happy to debug with you!
Happy to be a rubber ๐ฆ from time to tine ๐