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

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

Issue 1931233002: Implement PaymentRequestUpdateEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@explicit-shipping
Patch Set: Rebase Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5dcbd8c9267a44f5fee78ef60394f04f10629985..e076df91fa795604ff8c6a655d3c889b22f54889 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
@@ -154,19 +154,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
return;
}
- mLineItems = getValidatedLineItems(details);
- if (mLineItems == null) {
- disconnectFromClientWithDebugMessage("Invalid line items");
- return;
- }
- mPaymentItems = Arrays.asList(details.items);
-
- mShippingOptions =
- getValidatedShippingOptions(details.items[0].amount.currencyCode, details);
- if (mShippingOptions == null) {
- disconnectFromClientWithDebugMessage("Invalid shipping options");
- return;
- }
+ if (!setLineItemsAndShippingOptionsOrDisconnectFromClient(details)) return;
// If the merchant requests shipping and does not provide shipping options here, then the
// merchant needs the shipping address to calculate shipping price and availability.
@@ -224,6 +212,51 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
mFavicon = null;
}
+ /**
+ * Called by merchant to update the shipping options and line items after the user has selected
+ * their shipping address or shipping option.
+ */
+ @Override
+ public void updateWith(PaymentDetails details) {
+ if (mClient == null) return;
+
+ if (mUI == null) {
+ disconnectFromClientWithDebugMessage(
+ "PaymentRequestUpdateEvent.updateWith() called without PaymentRequest.show()");
+ return;
+ }
+
+ if (!setLineItemsAndShippingOptionsOrDisconnectFromClient(details)) return;
+
+ // Empty shipping options means the merchant cannot ship to the user's selected shipping
+ // address.
+ if (mShippingOptions.isEmpty() && !mMerchantNeedsShippingAddress) {
+ disconnectFromClientWithDebugMessage("Merchant indicates inablity to ship although "
+ + "originally indicated that can ship anywhere");
+ }
+
+ mUI.updateOrderSummarySection(mLineItems);
+ mUI.updateShippingOptionsSection(mShippingOptions);
+ }
+
+ private boolean setLineItemsAndShippingOptionsOrDisconnectFromClient(PaymentDetails details) {
+ mLineItems = getValidatedLineItems(details);
+ if (mLineItems == null) {
+ disconnectFromClientWithDebugMessage("Invalid line items");
+ return false;
+ }
+ mPaymentItems = Arrays.asList(details.items);
+
+ mShippingOptions =
+ getValidatedShippingOptions(details.items[0].amount.currencyCode, details);
+ if (mShippingOptions == null) {
+ disconnectFromClientWithDebugMessage("Invalid shipping options");
+ return false;
+ }
+
+ return true;
+ }
+
private HashSet<String> getValidatedSupportedMethods(String[] methods) {
// Payment methods are required.
if (methods == null || methods.length == 0) return null;
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698