w3c / payment-request

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

Define PaymentResponse.retry() method #715

Closed marcoscaceres closed 6 years ago

marcoscaceres commented 6 years ago

part 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

stpeter commented 6 years ago

@marcoscaceres Thanks for sketching this out - I like where it's going.

marcoscaceres commented 6 years ago

@domenic, this puts in place the .retry() model, but without the validation errors (#712), or all the eventing infrastructure that is needed.

To keep the pull requests reasonable in size, I'm sending these parts incrementally.

marcoscaceres commented 6 years ago

Blocked on #712.

marcoscaceres commented 6 years ago

Started writing tests so found some bugs (yay! "the system works").

marcoscaceres commented 6 years ago

Tests: https://github.com/w3c/web-platform-tests/pull/11101

marcoscaceres commented 6 years ago

Added link to related Gecko bug.

marcoscaceres commented 6 years ago

Trying a different way... will send again.

marcoscaceres commented 6 years ago

.retry() API support landed in Firefox Nightly 🎉 (though the payments UI doesn't yet support it... but still 🎊 )