You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some payment actions that lead to a call to onAdditionalDetails, when initiated via checkout.createFromAction, were seeing onAdditionalDetails being called without the actions argument containing the resolve & reject functions. These are needed to complete the flow, as detailed in our documentation.
This applies to threeDS, await & qrCode actions.
Calling checkout.createFromAction means the component that is instantiated just receives the raw, merchant defined, onAdditionalDetails callback, and not the "wrapped" version of this callback that is generated by UIElement.handleAction.
It is this latter, wrapped, version, called within UIElement.handleAdditionalDetails, that creates a Promise that can then be finalised with the resolve & reject functions that are passed, as the third argument, to the merchant's own onAdditionalDetails callback.
Our documentation states that the merchant callback should expect to receive these 2 functions and that they should be called to properly finalise the flow & lead to onPaymentCompleted or onPaymentFailed being called.
Fix:
This PR fixes this problem, within core.ts > createFromAction, by ensuring that the call to onAdditionalDetails (referenced internally as the "onComplete" fn) is always pushed towards the Component (UIElement) handleAdditionalDetails function
Tested scenarios
Manually tested threeDS, await (via MBWay) & qrCode (via PromptPay) actions, both with handleAction & createFromAction, to see them complete correctly in both scenarios.
Also tested threeDS in the "MDFlow", to see that the onComplete function passed by this flow is called instead of any others.
Tested the redirect action to see that this situation didn't arise (checkout.submitDetails, which is called after a redirect, creates its own Promise, with its own resolve & reject functions that can then be use to finalise the payment)
Tested the sdk action with the Klarna widget to see that the onComplete for the KlarnaPayments component directly calls it's super.handleAdditionalDetails function. So this issue doesn't arise.
Tested that this doesn't apply to bankTransfer actions. (They are concluded in a 3rd party app and not via onAdditionalDetails)
Tested that this doesn't apply to voucher actions, since they don't conclude in a call to onAdditionalDetails
Also tested how a card and storedCard within the Dropin performed, to ensure the elementRef (which points to the DropinElement) is persisted through the 3DS2 flow and reaches the ThreeDS2Challenge component.
Tested that both await & qrCode components also performed correctly within the Dropin
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Description:
Some payment actions that lead to a call to
onAdditionalDetails
, when initiated viacheckout.createFromAction
, were seeingonAdditionalDetails
being called without theactions
argument containing theresolve
&reject
functions. These are needed to complete the flow, as detailed in our documentation.This applies to
threeDS
,await
&qrCode
actions.Calling
checkout.createFromAction
means the component that is instantiated just receives the raw, merchant defined,onAdditionalDetails
callback, and not the "wrapped" version of this callback that is generated byUIElement.handleAction
.It is this latter, wrapped, version, called within
UIElement.handleAdditionalDetails
, that creates aPromise
that can then be finalised with theresolve
&reject
functions that are passed, as the third argument, to the merchant's ownonAdditionalDetails
callback.Our documentation states that the merchant callback should expect to receive these 2 functions and that they should be called to properly finalise the flow & lead to
onPaymentCompleted
oronPaymentFailed
being called.Fix:
This PR fixes this problem, within
core.ts > createFromAction
, by ensuring that the call toonAdditionalDetails
(referenced internally as the "onComplete" fn) is always pushed towards the Component (UIElement)handleAdditionalDetails
functionTested scenarios
Manually tested
threeDS
,await
(viaMBWay
) &qrCode
(viaPromptPay
) actions, both withhandleAction
&createFromAction
, to see them complete correctly in both scenarios.Also tested
threeDS
in the "MDFlow", to see that theonComplete
function passed by this flow is called instead of any others.Tested the
redirect
action to see that this situation didn't arise (checkout.submitDetails
, which is called after a redirect, creates its ownPromise
, with its ownresolve
&reject
functions that can then be use to finalise the payment)Tested the
sdk
action with the Klarna widget to see that theonComplete
for theKlarnaPayments
component directly calls it'ssuper.handleAdditionalDetails
function. So this issue doesn't arise.Tested that this doesn't apply to
bankTransfer
actions. (They are concluded in a 3rd party app and not viaonAdditionalDetails
)Tested that this doesn't apply to
voucher
actions, since they don't conclude in a call toonAdditionalDetails
Also tested how a card and storedCard within the Dropin performed, to ensure the
elementRef
(which points to theDropinElement
) is persisted through the 3DS2 flow and reaches theThreeDS2Challenge
component.Tested that both
await
&qrCode
components also performed correctly within the DropinAll e2e tests pass
Additional unit tests added