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

Paypal component not refreshing changed currency and fails on submit #210

Closed
almirakrdzic1991 opened this issue Aug 24, 2020 · 2 comments
Closed
Assignees

Comments

@almirakrdzic1991
Copy link

almirakrdzic1991 commented Aug 24, 2020

I have form with country selector and paypal smart button.
Change of the country will cause change of the currency and price.

I have written to the support and they said to umount and mount the component again to refresh the currency, so I did that.
Here is my code for it:

    onPlanChanged() {
      this.mountedPaypal.unmount();
      this.$nextTick(() => {
        this.mountPaypal();
      });
    },
    mountPaypal() {
      this.mountedPaypal = this.checkout
        .create("paypal", {
          environment: "test",
          countryCode: this.plan.country,
          amount: {
            currency: this.plan.currency,
            value: this.plan.price,
          },
          merchantId: "***",
          onSubmit: (data, component) => {
            data.handleAction = (action) => {
              component.handleAction(action);
            };
            this.$emit("submit", data);
          },
        })
        .mount(".pm-paypal-action");
    },

If currency is changed and button clicked, UI tries to open the paypal secure browser and then fails with error:
Expected currency from order api call to be EUR, got USD. Please ensure you are passing currency=USD to the sdk url.

Do I maybe need to wait for some amount of time between unmount and remount of the component or it is some other issue.

Note: when button is submitted we are sending the data to our api where latest plan with latest currency is used and they return us the action needed.

To Reproduce
Steps to reproduce the behavior:

  1. Mount paypal component with some currency variable have "EUR" value
  2. Change currency variable from "EUR" to "USD"
  3. Unmount existing paypal component
  4. Create and mount new paypal component with "USD" currency
  5. Submit button and do api call to get the action
  6. Provide action to mounted paypal component
  7. You will get error Expected currency from order api call to be EUR, got USD. Please ensure you are passing currency=USD to the sdk url.

Expected behavior
Paypal component should open the secure browser with the USD currency plan

Screenshots

  • OS: MacOS (Catalina)
  • Browser: Chrome 83

Screenshot 2020-08-24 at 11 06 08

Additional context
Version: checkoutshopper/sdk/3.11.0

@almirakrdzic1991 almirakrdzic1991 changed the title Paypal component not refreshing changed currency Paypal component not refreshing changed currency and fails on submit Aug 24, 2020
@pabloai
Copy link
Contributor

pabloai commented Aug 27, 2020

Hi @almirakrdzic1991,

Thanks for such a complete report.
We were able to fix the issue and it will be included in our next release.

Cheers.

@pabloai
Copy link
Contributor

pabloai commented Aug 28, 2020

Closing issue, let us know if we can help with anything else. Cheers!

@pabloai pabloai closed this as completed Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants