Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2394)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java

Issue 2530793002: PaymentApp: Allow multiple payment method names for one instrument. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
index 97a39cd707fbb42c314d10026490e71acfc4c444..61cc252ee3575f8df9be001254d2196cd212dbc5 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
@@ -55,6 +55,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@@ -907,7 +908,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
}
@Override
- public void loadingInstrumentDetails() {
+ public void onInstrumentDetailsLoading() {
if (mClient == null || mUI == null || mPaymentResponseHelper == null) return;
mUI.showProcessingMessage();
@@ -926,8 +927,19 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
mPaymentResponseHelper = new PaymentResponseHelper(
selectedShippingAddress, selectedShippingOption, selectedContact, this);
- instrument.getInstrumentDetails(mMerchantName, mOrigin, mRawTotal, mRawLineItems,
- mMethodData.get(instrument.getInstrumentMethodName()), this);
+ // Create a map that is the subset of mMethodData that contains the
+ // payment methods supported by the selected payment instrument. If this
+ // intersection contains more than one payment method, the payment app is
+ // at liberty to choose (or have the user choose) one of the methods.
+ Map<String, PaymentMethodData> methodData = new HashMap<>();
+ for (String instrumentMethodName : instrument.getInstrumentMethodNames()) {
+ if (mMethodData.containsKey(instrumentMethodName)) {
+ methodData.put(instrumentMethodName, mMethodData.get(instrumentMethodName));
+ }
+ }
+
+ instrument.invokePayment(mMerchantName, mOrigin, mRawTotal, mRawLineItems,
+ methodData, this);
please use gerrit instead 2016/11/29 14:17:18 Wrap methodData in Collections.unmodifiableMap().
tommyt 2016/11/30 10:15:50 Done.
recordSuccessFunnelHistograms("PayClicked");
return !(instrument instanceof AutofillPaymentInstrument);
}
@@ -1058,10 +1070,19 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
// all apps have responded.
if (instruments != null) {
for (int i = 0; i < instruments.size(); i++) {
+ boolean added = false;
PaymentInstrument instrument = instruments.get(i);
- if (mMethodData.containsKey(instrument.getInstrumentMethodName())) {
- addPendingInstrument(instrument);
- } else {
+ // If at least one of the payment method names supported by the
+ // instrument is in mMethodData, add this instrument.
please use gerrit instead 2016/11/29 14:17:18 Your approach is 9 lines long. Here's a shorter wa
tommyt 2016/11/30 10:15:50 Done.
+ for (String instrumentMethodName : instrument.getInstrumentMethodNames()) {
+ if (mMethodData.containsKey(instrumentMethodName)) {
+ addPendingInstrument(instrument);
+ added = true;
+ break;
+ }
+ }
+ // ... otherwise get rid of it.
+ if (!added) {
instrument.dismissInstrument();
}
}

Powered by Google App Engine
This is Rietveld 408576698