Skip to content
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

A way to specify payment method when mounting Dropin #1510

Open
geext-dk opened this issue Feb 24, 2022 · 3 comments
Open

A way to specify payment method when mounting Dropin #1510

geext-dk opened this issue Feb 24, 2022 · 3 comments
Labels
Enhancement New feature or request Progress: on hold v6 Included in the next major release

Comments

@geext-dk
Copy link

Is your feature request related to a problem? Please describe.
We have a case when our payment amount may change after initializing the Dropin. The documentation advices to remount (unmount and mount) the widget in case it changes. But payment methods configuration (some of which also require amount) is specified in the global configuration only, so it also should be updated. That's why I use AdyenCheckout.update method to update the configuration and remount dropin automatically. Yet it introduces another problem - after remounting, the dropin doesn't open the payment method that was opened before unmounting.

Without updating the amount, Google Pay and Apple Pay show outdated amount in their widgets.

To workaround that, I get the current payment method type (this.dropin.activePaymentMethod?.type) and I find the needed payment method in the DOM via this selector .adyen-checkout__payment-method--${type} and call .click() to simulate choice. And all of that should be done in the onReady dropin hook, because when AdyenCheckout.update resolves dropin is not yet fully mounted. I think that's not how it should be done.

Of course it's possible I'm doing it the totally wrong way.

Describe the solution you'd like
Add a public method for selecting a payment method by its type

Describe alternatives you've considered

  • Preserve selected payment option when remounting Dropin
  • Add a public method or other way to update amount without remounting Dropin
  • A configuration value that specifies which payment method to open upon mounting the Dropin

Additional context
Our dropin is integrated the old way (before 5.0.0).
Package version we use (@adyen/adyen-web): 5.3.1.

@geext-dk geext-dk added the Enhancement New feature or request label Feb 24, 2022
@ribeiroguilherme
Copy link
Contributor

Hi @geext-dk ,

Thanks for reaching out and for sharing the alternatives as well. The good news is that this improvement is already on our backlog 😃 I will update this ticket as soon as this feature is released.

@ankarhem
Copy link

Hey,

I have a similar problem. I think the approach klarna has for solving this problem is quite good. They allow you to lock the UI with a suspend function when performing external actions that affect the session. And then a resume function that unlocks the UI, that also refetches the internal amount in klarnas' session.

You could provide a way to patch the session via api and then mimick this behaviour in the mount / remount function. That provides a good DX which abstracts much of the logic.

@camil-adyen
Copy link
Contributor

Hi all!

A BETA version of Web v6 is now available on Github. Feel free to take a look and give us feedback! We aim to release the official v6 in the coming weeks. More information can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Progress: on hold v6 Included in the next major release
Projects
None yet
Development

No branches or pull requests

4 participants