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 ca53cbcf63dd9f831990019556b106b7a20b6b33..81a1029dfa3fb0b2ab5545448c9778f12236fc92 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 |
@@ -420,6 +420,13 @@ public class PaymentRequestImpl |
if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return; |
+ if (mRawTotal == null) { |
+ disconnectFromClientWithDebugMessage("Missing total"); |
+ recordAbortReasonHistogram( |
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER); |
+ return; |
+ } |
+ |
PaymentAppFactory.getInstance().create(mWebContents, |
Collections.unmodifiableSet(mMethodData.keySet()), this /* callback */); |
@@ -735,15 +742,20 @@ public class PaymentRequestImpl |
details.total.amount.currencySystem, Locale.getDefault()); |
} |
- // Total is never pending. |
- LineItem uiTotal = new LineItem(details.total.label, |
- mCurrencyFormatter.getFormattedCurrencyCode(), |
- mCurrencyFormatter.format(details.total.amount.value), /* isPending */ false); |
+ if (details.total != null) { |
+ mRawTotal = details.total; |
+ } |
+ |
+ if (mRawTotal != null) { |
+ // Total is never pending. |
+ LineItem uiTotal = new LineItem(mRawTotal.label, |
+ mCurrencyFormatter.getFormattedCurrencyCode(), |
+ mCurrencyFormatter.format(mRawTotal.amount.value), /* isPending */ false); |
- List<LineItem> uiLineItems = getLineItems(details.displayItems, mCurrencyFormatter); |
+ List<LineItem> uiLineItems = getLineItems(details.displayItems, mCurrencyFormatter); |
- mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems); |
- mRawTotal = details.total; |
+ mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems); |
+ } |
mRawLineItems = Collections.unmodifiableList(Arrays.asList(details.displayItems)); |
mUiShippingOptions = getShippingOptions(details.shippingOptions, mCurrencyFormatter); |