Skip to content

Commit

Permalink
[Web Payment] No shipping with secure payment confirmation.
Browse files Browse the repository at this point in the history
Before this patch, invoking PaymentRequest API with secure payment
confirmation method identifier and options to request shipping or
contact information was considered valid.

This patch throws RangeError in PaymentRequest constructor if secure
payment confirmation method identifier is requested together with
shipping or contact information.

After this patch, it's not possible to request secure payment
confirmation method together with shipping or contact information.

Bug: 2348410
Change-Id: I3e01f9b758645a1653533f41da9688c453199b03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359554
Reviewed-by: Liquan (Max) Gu <maxlg@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798755}
  • Loading branch information
rsolomakhin authored and chromium-wpt-export-bot committed Aug 17, 2020
1 parent 4b36a44 commit 2f79fdd
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions payment-request/secure-payment-confirmation.https.html
Expand Up @@ -50,6 +50,96 @@
}], details);
}, 'The timeout field is optional.');

test(() => {
assert_throws_js(RangeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}, {supportedMethods: 'basic-card'}], details);
});
}, 'Extra payment method not allowed afterward.');

test(() => {
assert_throws_js(RangeError, () => {
new PaymentRequest([{supportedMethods: 'basic-card'}, {
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details);
});
}, 'Extra payment method not allowed beforehand.');

test(() => {
assert_throws_js(RangeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details, {requestShipping: true});
});
}, 'Cannot request shipping information.');

test(() => {
assert_throws_js(RangeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details, {requestPayerName: true});
});
}, 'Cannot request payer name.');

test(() => {
assert_throws_js(RangeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details, {requestPayerEmail: true});
});
}, 'Cannot request payer email.');

test(() => {
assert_throws_js(RangeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details, {requestPayerPhone: true});
});
}, 'Cannot request payer phone.');

test(() => {
assert_throws_js(TypeError, () => {
new PaymentRequest([{
Expand Down

0 comments on commit 2f79fdd

Please sign in to comment.