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

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

Issue 2640743005: PaymentApp: Implement invokePaymentApp for Android (Closed)
Patch Set: Fix a compile error Created 3 years, 11 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.payments; 5 package org.chromium.chrome.browser.payments;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.graphics.Bitmap; 9 import android.graphics.Bitmap;
10 import android.os.Handler; 10 import android.os.Handler;
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 new LineItem(total.label, mCurrencyFormatter.getFormattedCurrenc yCode(), 664 new LineItem(total.label, mCurrencyFormatter.getFormattedCurrenc yCode(),
665 mCurrencyFormatter.format(total.amount.value), false /* isPending */)); 665 mCurrencyFormatter.format(total.amount.value), false /* isPending */));
666 mUiShoppingCart.setAdditionalContents(modifier == null 666 mUiShoppingCart.setAdditionalContents(modifier == null
667 ? null 667 ? null
668 : getLineItems(modifier.additionalDisplayItems, mCurrenc yFormatter)); 668 : getLineItems(modifier.additionalDisplayItems, mCurrenc yFormatter));
669 mUI.updateOrderSummarySection(mUiShoppingCart); 669 mUI.updateOrderSummarySection(mUiShoppingCart);
670 } 670 }
671 671
672 /** @return The first modifier that matches the given instrument, or null. * / 672 /** @return The first modifier that matches the given instrument, or null. * /
673 @Nullable private PaymentDetailsModifier getModifier(@Nullable PaymentInstru ment instrument) { 673 @Nullable private PaymentDetailsModifier getModifier(@Nullable PaymentInstru ment instrument) {
674 if (instrument == null) return null; 674 if (mModifiers == null || instrument == null) return null;
675 Set<String> methodNames = instrument.getInstrumentMethodNames(); 675 Set<String> methodNames = instrument.getInstrumentMethodNames();
676 methodNames.retainAll(mModifiers.keySet()); 676 methodNames.retainAll(mModifiers.keySet());
677 return methodNames.isEmpty() ? null : mModifiers.get(methodNames.iterato r().next()); 677 return methodNames.isEmpty() ? null : mModifiers.get(methodNames.iterato r().next());
678 } 678 }
679 679
680 /** 680 /**
681 * Converts a list of payment items and returns their parsed representation. 681 * Converts a list of payment items and returns their parsed representation.
682 * 682 *
683 * @param items The payment items to parse. Can be null. 683 * @param items The payment items to parse. Can be null.
684 * @param formatter A formatter for the currency amount value. 684 * @param formatter A formatter for the currency amount value.
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 PaymentOption selectedShippingOption, PaymentOption selectedPaymentM ethod) { 1027 PaymentOption selectedShippingOption, PaymentOption selectedPaymentM ethod) {
1028 assert selectedPaymentMethod instanceof PaymentInstrument; 1028 assert selectedPaymentMethod instanceof PaymentInstrument;
1029 PaymentInstrument instrument = (PaymentInstrument) selectedPaymentMethod ; 1029 PaymentInstrument instrument = (PaymentInstrument) selectedPaymentMethod ;
1030 mPaymentAppRunning = true; 1030 mPaymentAppRunning = true;
1031 1031
1032 PaymentOption selectedContact = mContactSection != null ? mContactSectio n.getSelectedItem() 1032 PaymentOption selectedContact = mContactSection != null ? mContactSectio n.getSelectedItem()
1033 : null; 1033 : null;
1034 mPaymentResponseHelper = new PaymentResponseHelper( 1034 mPaymentResponseHelper = new PaymentResponseHelper(
1035 selectedShippingAddress, selectedShippingOption, selectedContact , this); 1035 selectedShippingAddress, selectedShippingOption, selectedContact , this);
1036 1036
1037 // Create a map that is the subset of mMethodData that contains the 1037 // Create maps that are subsets of mMethodData and mModifiers, that cont ain
1038 // payment methods supported by the selected payment instrument. If this 1038 // the payment methods supported by the selected payment instrument. If the
1039 // intersection contains more than one payment method, the payment app i s 1039 // intersection of method data contains more than one payment method, th e
1040 // at liberty to choose (or have the user choose) one of the methods. 1040 // payment app is at liberty to choose (or have the user choose) one of the
1041 // methods.
1041 Map<String, PaymentMethodData> methodData = new HashMap<>(); 1042 Map<String, PaymentMethodData> methodData = new HashMap<>();
1043 Map<String, PaymentDetailsModifier> modifiers = new HashMap<>();
1042 for (String instrumentMethodName : instrument.getInstrumentMethodNames() ) { 1044 for (String instrumentMethodName : instrument.getInstrumentMethodNames() ) {
1043 if (mMethodData.containsKey(instrumentMethodName)) { 1045 if (mMethodData.containsKey(instrumentMethodName)) {
1044 methodData.put(instrumentMethodName, mMethodData.get(instrumentM ethodName)); 1046 methodData.put(instrumentMethodName, mMethodData.get(instrumentM ethodName));
1045 } 1047 }
1048 if (mModifiers != null && mModifiers.containsKey(instrumentMethodNam e)) {
1049 modifiers.put(instrumentMethodName, mModifiers.get(instrumentMet hodName));
1050 }
1046 } 1051 }
1047 1052
1048 instrument.invokePaymentApp(mMerchantName, mOrigin, mRawTotal, mRawLineI tems, 1053 instrument.invokePaymentApp(mMerchantName, mOrigin, Collections.unmodifi ableMap(methodData),
1049 Collections.unmodifiableMap(methodData), this); 1054 mRawTotal, mRawLineItems, Collections.unmodifiableMap(modifiers) , this);
1055
1050 recordSuccessFunnelHistograms("PayClicked"); 1056 recordSuccessFunnelHistograms("PayClicked");
1051 return !(instrument instanceof AutofillPaymentInstrument); 1057 return !(instrument instanceof AutofillPaymentInstrument);
1052 } 1058 }
1053 1059
1054 @Override 1060 @Override
1055 public void onDismiss() { 1061 public void onDismiss() {
1056 disconnectFromClientWithDebugMessage("Dialog dismissed"); 1062 disconnectFromClientWithDebugMessage("Dialog dismissed");
1057 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY _USER); 1063 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY _USER);
1058 } 1064 }
1059 1065
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 "PaymentRequest.CheckoutFunnel.Aborted", abortReason, 1473 "PaymentRequest.CheckoutFunnel.Aborted", abortReason,
1468 PaymentRequestMetrics.ABORT_REASON_MAX); 1474 PaymentRequestMetrics.ABORT_REASON_MAX);
1469 1475
1470 if (abortReason == PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER) { 1476 if (abortReason == PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER) {
1471 mJourneyLogger.recordJourneyStatsHistograms("UserAborted"); 1477 mJourneyLogger.recordJourneyStatsHistograms("UserAborted");
1472 } else { 1478 } else {
1473 mJourneyLogger.recordJourneyStatsHistograms("OtherAborted"); 1479 mJourneyLogger.recordJourneyStatsHistograms("OtherAborted");
1474 } 1480 }
1475 } 1481 }
1476 } 1482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698