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

teach retry() about payerErrors #721

Merged
merged 2 commits into from
Jun 25, 2018
Merged

Conversation

marcoscaceres
Copy link
Member

@marcoscaceres marcoscaceres commented Jun 7, 2018

BUILDS ON #720 - This is part 2 of 5. It adds:

  • retry() argument for validation errors: retry(PaymentValidationErrors errorFields)
  • PaymentValidationErrors dictionary
  • PayerErrorFields dictionary
  • Adds shippingAddressErrors to PaymentValidationErrors

The following tasks have been completed:

Implementation commitment:

  • Safari (link to issue)
  • Chrome (link to issue)
  • Firefox (link to issue)
  • Edge (public signal)

Impact on Payment Handler spec?
Unknown.

Example

Via payerErrors, the user now knows what's actually wrong with the payment.

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 payerErrors = await validatePayerInput(response);
  if (!payerErrors) {
    return;
  }
  await response.retry({ payerErrors });
  return recursiveValidate(request, response);
}

doPaymentRequest();

Preview | Diff

@marcoscaceres
Copy link
Member Author

Blocked on #720 landing.

@marcoscaceres
Copy link
Member Author

For anyone watching at home, this currently lacks (coming soon as new PRs/parts):

  • interfacing with updateWith() - in particular, errors need to reject the retryPromise.
  • "payerdetailschange" event, onpayerdetailschange on PaymentResponse, and associated task to fire the event.

@marcoscaceres marcoscaceres force-pushed the retry_request_payerError branch 3 times, most recently from b788b46 to 75a617c Compare June 21, 2018 17:01
@marcoscaceres
Copy link
Member Author

Friendly ping, @domenic.

Copy link
Collaborator

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM editorially, but I'm increasingly unhappy with the excessive prefixing and suffixing.

Step away from your particular coding style, which uses lots of redundant variables and object literal shorthand. Consider what more conventional code using this API would have to look like:

await response.retry({
  shippingAddressErrors: {
    addressLineError: "Bad address line"
  },
  payerErrors: {
    payerEmailError: "Bad email"
  }
});

This is fairly ridiculous. The field names here are something like errors.payerErrors.payerEmailError, instead of the simpler errors.payer.email or even errors.payerEmail. (Similarly, errors.shippingAddressErrors.addressLineError instead of errors.shippingAddress.addressLine---the latter is long enough already.)

I'd really suggest getting rid of all the redundant prefixes and suffixes, and allowing people to write clean, straightforward code of the sort

await response.retry({
  shippingAddress: {
    addressLine: "Bad address line"
  },
  payer: {
    email: "Bad email"
  }
});

If we're not in agreement on this, maybe it's something to bring up with a larger audience to get more perspectives?

index.html Outdated
wrong with the user-provided data of the payment response.
<li>By matching the members of <var>errorFields</var> to input fields
in the user agent's UI, indicate to the end-user that something is
wrong with the data of the payment response.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe discuss how the UA should use the developer-supplied strings?

@marcoscaceres
Copy link
Member Author

marcoscaceres commented Jun 25, 2018 via email

@marcoscaceres
Copy link
Member Author

marcoscaceres commented Jun 25, 2018

Filed #736 to drop *Error.

@marcoscaceres marcoscaceres merged commit 634a8a8 into gh-pages Jun 25, 2018
@marcoscaceres marcoscaceres deleted the retry_request_payerError branch June 27, 2018 19:00
@marcoscaceres
Copy link
Member Author

Tests web-platform-tests/wpt#12395

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 17, 2018
Related spec change:
  w3c/payment-request#721

Tests:
  components/payments/content/payment_request_spec_unittest.cc
  components/payments/content/payment_request_state_unittest.cc

Manual tests:
  wpt/payment-request/payment-response/retry-method-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html

Demo:
  https://youtu.be/_mbcGkbwfw8

Bug: 861704
Change-Id: I12c2d74f7b170626d2c9a41ecfc9116bfe75c2b7
marcoscaceres pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 21, 2018
)

Related spec change:
  w3c/payment-request#721

Tests:
  components/payments/content/payment_request_spec_unittest.cc
  components/payments/content/payment_request_state_unittest.cc

Manual tests:
  wpt/payment-request/payment-response/retry-method-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html

Demo:
  https://youtu.be/_mbcGkbwfw8

Bug: 861704
Change-Id: I12c2d74f7b170626d2c9a41ecfc9116bfe75c2b7
aarongable pushed a commit to chromium/chromium that referenced this pull request Aug 23, 2018
Related spec change:
  w3c/payment-request#721

Tests:
  chrome/browser/ui/views/payments/contact_info_editor_view_controller_browsertest.cc
  chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc
  components/payments/content/payment_request_spec_unittest.cc
  components/payments/content/payment_request_state_unittest.cc

Manual tests:
  wpt/payment-request/payment-response/retry-method-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html

Demo:
  https://youtu.be/_mbcGkbwfw8

Bug: 861704
Change-Id: I12c2d74f7b170626d2c9a41ecfc9116bfe75c2b7
Reviewed-on: https://chromium-review.googlesource.com/1144587
Commit-Queue: Jinho Bang <[email protected]>
Reviewed-by: Rouslan Solomakhin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#585581}
zcorpan pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 27, 2018
)

Related spec change:
  w3c/payment-request#721

Tests:
  components/payments/content/payment_request_spec_unittest.cc
  components/payments/content/payment_request_state_unittest.cc

Manual tests:
  wpt/payment-request/payment-response/retry-method-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html

Demo:
  https://youtu.be/_mbcGkbwfw8

Bug: 861704
Change-Id: I12c2d74f7b170626d2c9a41ecfc9116bfe75c2b7
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Aug 29, 2018
… PaymentResponse.retry(), a=testonly

Automatic update from web-platform-testsPaymentRequest: Implement desktop UI for PaymentResponse.retry() (#12550)

Related spec change:
  w3c/payment-request#721

Tests:
  components/payments/content/payment_request_spec_unittest.cc
  components/payments/content/payment_request_state_unittest.cc

Manual tests:
  wpt/payment-request/payment-response/retry-method-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html

Demo:
  https://youtu.be/_mbcGkbwfw8

Bug: 861704
Change-Id: I12c2d74f7b170626d2c9a41ecfc9116bfe75c2b7
--

wpt-commits: 4797b9cde63931bf7c49a74e2589a12dd619bec1
wpt-pr: 12550
jankeromnes pushed a commit to jankeromnes/gecko that referenced this pull request Aug 29, 2018
… PaymentResponse.retry(), a=testonly

Automatic update from web-platform-testsPaymentRequest: Implement desktop UI for PaymentResponse.retry() (#12550)

Related spec change:
  w3c/payment-request#721

Tests:
  components/payments/content/payment_request_spec_unittest.cc
  components/payments/content/payment_request_state_unittest.cc

Manual tests:
  wpt/payment-request/payment-response/retry-method-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html

Demo:
  https://youtu.be/_mbcGkbwfw8

Bug: 861704
Change-Id: I12c2d74f7b170626d2c9a41ecfc9116bfe75c2b7
--

wpt-commits: 4797b9cde63931bf7c49a74e2589a12dd619bec1
wpt-pr: 12550
aarongable pushed a commit to chromium/chromium that referenced this pull request Jan 27, 2019
Related spec change:
  w3c/payment-request#721

Tests:
  chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestRetryTest.java

Manual tests:
  wpt/payment-request/payment-response/retry-method-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html

Bug: 861704
Change-Id: Ibeae527b950c32e31ca19a631da3a88dc9e33429
Reviewed-on: https://chromium-review.googlesource.com/c/1415050
Commit-Queue: Jinho Bang <[email protected]>
Reviewed-by: Rouslan Solomakhin <[email protected]>
Reviewed-by: Theresa <[email protected]>
Cr-Commit-Position: refs/heads/master@{#626397}
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
… PaymentResponse.retry(), a=testonly

Automatic update from web-platform-testsPaymentRequest: Implement desktop UI for PaymentResponse.retry() (#12550)

Related spec change:
  w3c/payment-request#721

Tests:
  components/payments/content/payment_request_spec_unittest.cc
  components/payments/content/payment_request_state_unittest.cc

Manual tests:
  wpt/payment-request/payment-response/retry-method-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html

Demo:
  https://youtu.be/_mbcGkbwfw8

Bug: 861704
Change-Id: I12c2d74f7b170626d2c9a41ecfc9116bfe75c2b7
--

wpt-commits: 4797b9cde63931bf7c49a74e2589a12dd619bec1
wpt-pr: 12550

UltraBlame original commit: a066a82e40b8fdc71502a1bb33c2242c019263f1
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
… PaymentResponse.retry(), a=testonly

Automatic update from web-platform-testsPaymentRequest: Implement desktop UI for PaymentResponse.retry() (#12550)

Related spec change:
  w3c/payment-request#721

Tests:
  components/payments/content/payment_request_spec_unittest.cc
  components/payments/content/payment_request_state_unittest.cc

Manual tests:
  wpt/payment-request/payment-response/retry-method-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html

Demo:
  https://youtu.be/_mbcGkbwfw8

Bug: 861704
Change-Id: I12c2d74f7b170626d2c9a41ecfc9116bfe75c2b7
--

wpt-commits: 4797b9cde63931bf7c49a74e2589a12dd619bec1
wpt-pr: 12550

UltraBlame original commit: a066a82e40b8fdc71502a1bb33c2242c019263f1
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
… PaymentResponse.retry(), a=testonly

Automatic update from web-platform-testsPaymentRequest: Implement desktop UI for PaymentResponse.retry() (#12550)

Related spec change:
  w3c/payment-request#721

Tests:
  components/payments/content/payment_request_spec_unittest.cc
  components/payments/content/payment_request_state_unittest.cc

Manual tests:
  wpt/payment-request/payment-response/retry-method-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
  wpt/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html

Demo:
  https://youtu.be/_mbcGkbwfw8

Bug: 861704
Change-Id: I12c2d74f7b170626d2c9a41ecfc9116bfe75c2b7
--

wpt-commits: 4797b9cde63931bf7c49a74e2589a12dd619bec1
wpt-pr: 12550

UltraBlame original commit: a066a82e40b8fdc71502a1bb33c2242c019263f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants