w3c / payment-request

Payment Request API
https://www.w3.org/TR/payment-request/
Other
488 stars 135 forks source link

Define PaymentResponse.prototype.retry() method #720

Closed marcoscaceres closed 6 years ago

marcoscaceres commented 6 years ago

part 1 of #705

The following tasks have been completed:

Implementation commitment:

Impact on Payment Handler spec?

Unknown.

Example

This pull request gets us here... the user doesn't yet know what's actually wrong with the payment, but at least they know something is wrong.

async function doPaymentRequest() {
  const request = new PaymentRequest(methodData, details, options);
  const response = await request.show();
  try {
    await recursiveValidate(request, response);
  } catch (err) { // retry aborted.
    console.error(err);
    return;
  }
  await response.complete("success");
}

async function recursiveValidate(request, response) {
  const promisesToFixThings = [];
  const errors = await validate(request, response);
  if (!errors) {
    return;
  }
  await response.retry();
  return recursiveValidate(request, response);
}

doPaymentRequest();

Preview | Diff

marcoscaceres commented 6 years ago

Ok, implemented this and it seems to work for me locally.

marcoscaceres commented 6 years ago

(again noting, this doesn't include passing the actual errors yet - that's part 2.)

marcoscaceres commented 6 years ago

@domenic, this is ready for review when you have time. Let me know how you want to handler all the parts. I tried to limit the changes to make is easier to review.

marcoscaceres commented 6 years ago

Seeking additional implementation commitment for .retry() also. Currently, only have commitment from Mozilla.

marcoscaceres commented 6 years ago

@ianbjacobs, @adrianhopebailie, could you evaluate if there is any impact on payment handler? I've not given it any thought. If there is, could you add details to the "Impact on Payment Handler spec?" Same applies for the other pull requests relating to retry().

marcoscaceres commented 6 years ago

Added some developer docs: https://developer.mozilla.org/en-US/docs/Web/API/PaymentResponse/retry

marcoscaceres commented 6 years ago

Blink intent to implement https://groups.google.com/a/chromium.org/d/msg/blink-dev/wayZGnuBkrI/SCLOTxCACwAJ

aestes commented 5 years ago

WebKit tracking bug: https://bugs.webkit.org/show_bug.cgi?id=190985