Commit a849d4c7 authored by gogerald's avatar gogerald Committed by Commit Bot

[Payments] Do not match capabilities again.

Do not match capabilities again since it
has been done in ServiceWorkerPaymentAppFactory.

Note that, the capability related matching tests
for getInstruments is not applicable anymore, so
they have been modified to test matching modifiers
which use the same matching rules.

Bug: 777470
Change-Id: Ib01ad930b48b2ab5e78b13aa5b73c1e1fa4cf645
Reviewed-on: https://chromium-review.googlesource.com/788452Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519729}
parent 0bd5352f
...@@ -137,22 +137,9 @@ public class ServiceWorkerPaymentApp extends PaymentInstrument implements Paymen ...@@ -137,22 +137,9 @@ public class ServiceWorkerPaymentApp extends PaymentInstrument implements Paymen
public void getInstruments(Map<String, PaymentMethodData> methodDataMap, String origin, public void getInstruments(Map<String, PaymentMethodData> methodDataMap, String origin,
String iframeOrigin, byte[][] unusedCertificateChain, String iframeOrigin, byte[][] unusedCertificateChain,
Map<String, PaymentDetailsModifier> modifiers, final InstrumentsCallback callback) { Map<String, PaymentDetailsModifier> modifiers, final InstrumentsCallback callback) {
boolean isOnlySupportBasiccard = isOnlySupportBasiccard(methodDataMap);
if (isOnlySupportBasiccard
&& !matchBasiccardCapabilities(
methodDataMap.get(BasicCardUtils.BASIC_CARD_METHOD_NAME))) {
// Do not list this app if 'basic-card' is the only supported payment method with
// unmatched capabilities.
new Handler().post(() -> {
List<PaymentInstrument> instruments = new ArrayList();
callback.onInstrumentsReady(ServiceWorkerPaymentApp.this, instruments);
});
return;
}
// Do not send canMakePayment event when in incognito mode or basic-card is the only // Do not send canMakePayment event when in incognito mode or basic-card is the only
// supported payment method for the payment request. // supported payment method for the payment request.
if (mIsIncognito || isOnlySupportBasiccard) { if (mIsIncognito || isOnlySupportBasiccard(methodDataMap)) {
new Handler().post(() -> { new Handler().post(() -> {
List<PaymentInstrument> instruments = new ArrayList(); List<PaymentInstrument> instruments = new ArrayList();
instruments.add(ServiceWorkerPaymentApp.this); instruments.add(ServiceWorkerPaymentApp.this);
......
...@@ -155,8 +155,8 @@ if (is_ios) { ...@@ -155,8 +155,8 @@ if (is_ios) {
"//components/test/data/payments/alicepay_bobpay_charliepay_and_cards.js", "//components/test/data/payments/alicepay_bobpay_charliepay_and_cards.js",
"//components/test/data/payments/blob_url.js", "//components/test/data/payments/blob_url.js",
"//components/test/data/payments/bobpay.js", "//components/test/data/payments/bobpay.js",
"//components/test/data/payments/bobpay_and_basic_card_with_modifier_optional_data.js",
"//components/test/data/payments/bobpay_and_basic_card_with_modifiers.js", "//components/test/data/payments/bobpay_and_basic_card_with_modifiers.js",
"//components/test/data/payments/bobpay_and_basic_card_with_optional_data.js",
"//components/test/data/payments/bobpay_and_cards.js", "//components/test/data/payments/bobpay_and_cards.js",
"//components/test/data/payments/bobpay_ui_skip.js", "//components/test/data/payments/bobpay_ui_skip.js",
"//components/test/data/payments/bobpay_ui_skip_preload.js", "//components/test/data/payments/bobpay_ui_skip_preload.js",
...@@ -189,8 +189,8 @@ if (is_ios) { ...@@ -189,8 +189,8 @@ if (is_ios) {
"//components/test/data/payments/payment_request_abort_test.html", "//components/test/data/payments/payment_request_abort_test.html",
"//components/test/data/payments/payment_request_alicepay_bobpay_charliepay_and_cards_test.html", "//components/test/data/payments/payment_request_alicepay_bobpay_charliepay_and_cards_test.html",
"//components/test/data/payments/payment_request_blob_url_test.html", "//components/test/data/payments/payment_request_blob_url_test.html",
"//components/test/data/payments/payment_request_bobpay_and_basic_card_with_modifier_optional_data_test.html",
"//components/test/data/payments/payment_request_bobpay_and_basic_card_with_modifiers_test.html", "//components/test/data/payments/payment_request_bobpay_and_basic_card_with_modifiers_test.html",
"//components/test/data/payments/payment_request_bobpay_and_basic_card_with_optional_data_test.html",
"//components/test/data/payments/payment_request_bobpay_and_cards_test.html", "//components/test/data/payments/payment_request_bobpay_and_cards_test.html",
"//components/test/data/payments/payment_request_bobpay_test.html", "//components/test/data/payments/payment_request_bobpay_test.html",
"//components/test/data/payments/payment_request_bobpay_ui_skip_preload_test.html", "//components/test/data/payments/payment_request_bobpay_ui_skip_preload_test.html",
......
...@@ -5,14 +5,29 @@ ...@@ -5,14 +5,29 @@
*/ */
/** /**
* Launches the PaymentRequest UI with Bob Pay as payment method. * Launches the PaymentRequest UI with Bob Pay and 'basic-card' as
* payment methods, and Bob Pay modifier.
*/ */
function buy() { // eslint-disable-line no-unused-vars function buy() { // eslint-disable-line no-unused-vars
try { try {
new PaymentRequest( new PaymentRequest(
[{supportedMethods: ['https://bobpay.com']}], [{supportedMethods: ['https://bobpay.com', 'basic-card']}],
{ {
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
modifiers: [{
supportedMethods: ['https://bobpay.com'],
total: {
label: 'Total',
amount: {currency: 'USD', value: '4.00'},
},
additionalDisplayItems: [{
label: 'BobPay discount',
amount: {currency: 'USD', value: '-1.00'},
}],
data: {
discountProgramParticipantId: '86328764873265',
},
}],
}) })
.show() .show()
.then(function(resp) { .then(function(resp) {
...@@ -33,14 +48,27 @@ ...@@ -33,14 +48,27 @@
} }
/** /**
* Launches the PaymentRequest UI with all cards as payment methods. * Launches the PaymentRequest UI with 'basic-card' payment method and
* all cards modifier.
*/ */
function buyWithAllCards() { // eslint-disable-line no-unused-vars function buyWithAllCardsModifier() { // eslint-disable-line no-unused-vars
try { try {
new PaymentRequest( new PaymentRequest(
[{supportedMethods: ['basic-card']}], [{supportedMethods: ['basic-card']}],
{ {
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
modifiers: [{
supportedMethods: ['basic-card'],
total: {
label: 'Total',
amount: {currency: 'USD', value: '4.00'},
},
additionalDisplayItems: [{
label: 'basic-card discount',
amount: {currency: 'USD', value: '-1.00'},
}],
data: {discountProgramParticipantId: '86328764873265'},
}],
}) })
.show() .show()
.then(function(resp) { .then(function(resp) {
...@@ -61,20 +89,33 @@ ...@@ -61,20 +89,33 @@
} }
/** /**
* Launches the PaymentRequest UI with visa credit card as payment method. * Launches the PaymentRequest UI with 'basic-card' as payment method and
* visa credit card modifier.
*/ */
function buyWithVisaCredit() { // eslint-disable-line no-unused-vars function buyWithVisaCreditModifier() { // eslint-disable-line no-unused-vars
try { try {
new PaymentRequest( new PaymentRequest(
[{ [{
supportedMethods: ['basic-card'], supportedMethods: ['basic-card'],
data: {
supportedTypes: ['credit'],
supportedNetworks: ['visa'],
},
}], }],
{ {
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
modifiers: [{
supportedMethods: ['basic-card'],
total: {
label: 'Total',
amount: {currency: 'USD', value: '4.00'},
},
additionalDisplayItems: [{
label: 'Visa credit discount',
amount: {currency: 'USD', value: '-1.00'},
}],
data: {
discountProgramParticipantId: '86328764873265',
supportedTypes: ['credit'],
supportedNetworks: ['visa'],
},
}],
}) })
.show() .show()
.then(function(resp) { .then(function(resp) {
...@@ -95,20 +136,33 @@ ...@@ -95,20 +136,33 @@
} }
/** /**
* Launches the PaymentRequest UI with visa debit card as payment method. * Launches the PaymentRequest UI with 'basic-card' as payment method and
* visa debit card modifier.
*/ */
function buyWithVisaDebit() { // eslint-disable-line no-unused-vars function buyWithVisaDebitModifier() { // eslint-disable-line no-unused-vars
try { try {
new PaymentRequest( new PaymentRequest(
[{ [{
supportedMethods: ['basic-card'], supportedMethods: ['basic-card'],
data: {
supportedTypes: ['debit'],
supportedNetworks: ['visa'],
},
}], }],
{ {
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
modifiers: [{
supportedMethods: ['basic-card'],
total: {
label: 'Total',
amount: {currency: 'USD', value: '4.00'},
},
additionalDisplayItems: [{
label: 'Visa debit discount',
amount: {currency: 'USD', value: '-1.00'},
}],
data: {
discountProgramParticipantId: '86328764873265',
supportedTypes: ['debit'],
supportedNetworks: ['visa'],
},
}],
}) })
.show() .show()
.then(function(resp) { .then(function(resp) {
...@@ -129,53 +183,33 @@ ...@@ -129,53 +183,33 @@
} }
/** /**
* Launches the PaymentRequest UI with credit card as payment method. * Launches the PaymentRequest UI with 'basic-card' as payment method and
* credit card modifier.
*/ */
function buyWithCredit() { // eslint-disable-line no-unused-vars function buyWithCreditModifier() { // eslint-disable-line no-unused-vars
try { try {
new PaymentRequest( new PaymentRequest(
[{ [{
supportedMethods: ['basic-card'], supportedMethods: ['basic-card'],
data: {
supportedTypes: ['credit'],
},
}], }],
{ {
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
}) modifiers: [{
.show()
.then(function(resp) {
resp.complete('success')
.then(function() {
print(JSON.stringify(resp, undefined, 2));
})
.catch(function(error) {
print('complete() rejected<br>' + error.message);
});
})
.catch(function(error) {
print('show() rejected<br>' + error.message);
});
} catch (error) {
print('exception thrown<br>' + error.message);
}
}
/**
* Launches the PaymentRequest UI with visa card as payment method.
*/
function buyWithVisa() { // eslint-disable-line no-unused-vars
try {
new PaymentRequest(
[{
supportedMethods: ['basic-card'], supportedMethods: ['basic-card'],
total: {
label: 'Total',
amount: {currency: 'USD', value: '4.00'},
},
additionalDisplayItems: [{
label: 'Credit card discount',
amount: {currency: 'USD', value: '-1.00'},
}],
data: { data: {
supportedNetworks: ['visa'], discountProgramParticipantId: '86328764873265',
supportedTypes: ['credit'],
}, },
}], }],
{ })
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
})
.show() .show()
.then(function(resp) { .then(function(resp) {
resp.complete('success') resp.complete('success')
...@@ -194,20 +228,33 @@ ...@@ -194,20 +228,33 @@
} }
} }
/** /**
* Launches the PaymentRequest UI with Bob Pay and visa card as payment methods. * Launches the PaymentRequest UI with 'basic-card' as payment method and
* visa card modifier.
*/ */
function buyWithBobPayAndVisa() { // eslint-disable-line no-unused-vars function buyWithVisaModifier() { // eslint-disable-line no-unused-vars
try { try {
new PaymentRequest( new PaymentRequest(
[{ [{
supportedMethods: ['https://bobpay.com', 'basic-card'], supportedMethods: ['basic-card'],
data: {
supportedNetworks: ['visa'],
},
}], }],
{ {
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
modifiers: [{
supportedMethods: ['basic-card'],
total: {
label: 'Total',
amount: {currency: 'USD', value: '4.00'},
},
additionalDisplayItems: [{
label: 'Visa discount',
amount: {currency: 'USD', value: '-1.00'},
}],
data: {
discountProgramParticipantId: '86328764873265',
supportedNetworks: ['visa'],
},
}],
}) })
.show() .show()
.then(function(resp) { .then(function(resp) {
......
...@@ -6,21 +6,20 @@ found in the LICENSE file. ...@@ -6,21 +6,20 @@ found in the LICENSE file.
--> -->
<html> <html>
<head> <head>
<title>Bob Pay and basic-card with optional data test</title> <title>Bob Pay and basic-card with modifier optional data test</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
</head> </head>
<body> <body>
<button onclick="buy()" id="buy">Bob Pay Test</button> <button onclick="buy()" id="buy">Bob Pay modifier Test</button>
<button onclick="buyWithAllCards()" id="buy_with_all_cards">All cards test</button> <button onclick="buyWithAllCardsModifier()" id="buy_with_all_cards_modifier">All cards modifier test</button>
<button onclick="buyWithVisaCredit()" id="buy_with_visa_credit">Visa credit card test</button> <button onclick="buyWithVisaCreditModifier()" id="buy_with_visa_credit_modifier">Visa credit card modifier test</button>
<button onclick="buyWithVisaDebit()" id="buy_with_visa_debit">Visa debit card test</button> <button onclick="buyWithVisaDebitModifier()" id="buy_with_visa_debit_modifier">Visa debit card modifier test</button>
<button onclick="buyWithCredit()" id="buy_with_credit">Credit card test</button> <button onclick="buyWithCreditModifier()" id="buy_with_credit_modifier">Credit card modifier test</button>
<button onclick="buyWithVisa()" id="buy_with_visa">Visa card test</button> <button onclick="buyWithVisaModifier()" id="buy_with_visa_modifier">Visa card modifier test</button>
<button onclick="buyWithBobPayAndVisa()" id="buy_with_bobpay_and_visa">Bob Pay And Visa card test</button>
<pre id="result"></pre> <pre id="result"></pre>
<script src="util.js"></script> <script src="util.js"></script>
<script src="bobpay_and_basic_card_with_optional_data.js"></script> <script src="bobpay_and_basic_card_with_modifier_optional_data.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment