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

Duplicate shippingOptions lead to inconsistent updateWith() - should throw! #594

Closed
marcoscaceres opened this issue Aug 25, 2017 · 1 comment · Fixed by #596
Closed

Duplicate shippingOptions lead to inconsistent updateWith() - should throw! #594

marcoscaceres opened this issue Aug 25, 2017 · 1 comment · Fixed by #596

Comments

@marcoscaceres
Copy link
Member

If given:

const methods = [{ supportedMethods: ["basic-card"] }];
const details = {
  total: {
    label: "Total due",
    amount: { currency: "USD", value: "1.0" },
  },
};
const options = {
  requestShipping: true,
};

const request = new PaymentRequest(methods, detailsNoShippingOptions, options);
// See below
const response = await request.show();

And we do:

response.onshippingaddresschange =  ev =>{
  const shippingOptions = [
    {
      id: "duplicate",
      label: "Option",
      amount: { currency: "USD", value: "5.00" },
      selected: true,
    },
    {
      id: "duplicate",
      label: "Option",
      amount: { currency: "USD", value: "5.00" },
    },
    {
      id: "not a duplicate",
      label: "Option",
      amount: { currency: "USD", value: "5.00" },
    },
 ];
 const newDetails = {...details, shippingOptions};
 ev.updateWith(newDetails);
}

The API says that because there are duplicates, all the shippingOptions become invalid and essentially this becomes an error in the payment sheet.

However, the above is developer error, not a user error! This leads to somewhat frustrating user experience where the user is told the merchant can't ship to that address (when in fact, the merchant can!):

screenshot 2017-08-25 15 18 56

I think we should throw on duplicate IDs instead, because the developer screwed up.

@marcoscaceres
Copy link
Member Author

marcoscaceres commented Aug 25, 2017

Note also in the above, that the use can keep trying/modifying/adding addresses but they will all continue to fail. But neither the user or the developer will know why!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants