-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Klarna - Fix for handling multiple instances of the widget #3007
Conversation
🦋 Changeset detectedLatest commit: 4198784 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
Size Change: +836 B (+0.11%) Total Size: 769 kB
ℹ️ View Unchanged
|
The approach is great, but, as it stands, without the changes to (I realise the change to the |
packages/lib/src/components/Klarna/components/KlarnaContainer/KlarnaContainer.tsx
Show resolved
Hide resolved
|
Summary
PR to handle the issue with multiple instances of the Klarna widget being present in the PM list
There are 2 issues:
KlarnaWidget
it loads the KlarnaSDK, which in turn calls the callback we create (window.klarnaAsyncCallback
), which initialises the KlarnaSDK.KlarnaWidget
in the PM list, initialising that will not see the KlarnaSDK calling our callback for a second time, and so the KlarnaSDK is not re-initialised with the rightsdkData.client_token
to make the correct payment.sdkData.client_token
So..
KlarnaWidget
component it checks if it "manually" needs to initialise the KlarnaSDK widget (fixes issue 1)UIElement
to allow it to run some custom logic (onPaymentMethodActive
).This allows the
KlarnaWidget
to "manually" re-initialise the KlarnaSDK. (fixes issue 2)Proposed changes:
component.activate()
which can be used when the Component is active.submit()
, .mount()
, etc)component.activate()
is called in case the Component was previously createdKlarnaConfiguration
Fixes issue: COWEB-1468