| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java
|
| index 822172d9b88a648a251941db86c83f01c6dc43dc..aa705adb7d819b84f6e6053ba388ddfb3f41dd1c 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java
|
| @@ -28,8 +28,7 @@
|
| public class AutofillPaymentInstrument
|
| extends PaymentInstrument implements FullCardRequestDelegate {
|
| private final WebContents mWebContents;
|
| - private CreditCard mCard;
|
| - private boolean mIsComplete;
|
| + private final CreditCard mCard;
|
| @Nullable private AutofillProfile mBillingAddress;
|
| @Nullable private DetailsCallback mCallback;
|
|
|
| @@ -38,7 +37,7 @@
|
| *
|
| * @param webContents The web contents where PaymentRequest was invoked.
|
| * @param card The autofill card that can be used for payment.
|
| - * @param billingAddress The billing address for the card.
|
| + * @param billingAddress The optional billing address for the card.
|
| */
|
| public AutofillPaymentInstrument(
|
| WebContents webContents, CreditCard card, @Nullable AutofillProfile billingAddress) {
|
| @@ -46,7 +45,6 @@
|
| card.getIssuerIconDrawableId());
|
| mWebContents = webContents;
|
| mCard = card;
|
| - mIsComplete = false;
|
| mBillingAddress = billingAddress;
|
| }
|
|
|
| @@ -58,15 +56,9 @@
|
| @Override
|
| public void getDetails(String unusedMerchantName, String unusedOrigin, PaymentItem unusedTotal,
|
| List<PaymentItem> unusedCart, JSONObject unusedDetails, DetailsCallback callback) {
|
| - assert mIsComplete;
|
| assert mCallback == null;
|
| mCallback = callback;
|
| - if (mCard.getGUID().isEmpty()) {
|
| - PersonalDataManager.getInstance().getFullTemporaryCard(mWebContents, mCard.getNumber(),
|
| - mCard.getName(), mCard.getMonth(), mCard.getYear(), this);
|
| - } else {
|
| - PersonalDataManager.getInstance().getFullCard(mWebContents, mCard.getGUID(), this);
|
| - }
|
| + PersonalDataManager.getInstance().getFullCard(mWebContents, mCard.getGUID(), this);
|
| }
|
|
|
| @Override
|
| @@ -82,33 +74,35 @@
|
| json.name("expiryYear").value(card.getYear());
|
| json.name("cardSecurityCode").value(cvc);
|
|
|
| - json.name("billingAddress").beginObject();
|
| + if (mBillingAddress != null) {
|
| + json.name("billingAddress").beginObject();
|
|
|
| - json.name("country").value(ensureNotNull(mBillingAddress.getCountryCode()));
|
| - json.name("region").value(ensureNotNull(mBillingAddress.getRegion()));
|
| - json.name("city").value(ensureNotNull(mBillingAddress.getLocality()));
|
| - json.name("dependentLocality")
|
| - .value(ensureNotNull(mBillingAddress.getDependentLocality()));
|
| + json.name("country").value(ensureNotNull(mBillingAddress.getCountryCode()));
|
| + json.name("region").value(ensureNotNull(mBillingAddress.getRegion()));
|
| + json.name("city").value(ensureNotNull(mBillingAddress.getLocality()));
|
| + json.name("dependentLocality")
|
| + .value(ensureNotNull(mBillingAddress.getDependentLocality()));
|
|
|
| - json.name("addressLine").beginArray();
|
| - String multipleLines = ensureNotNull(mBillingAddress.getStreetAddress());
|
| - if (!TextUtils.isEmpty(multipleLines)) {
|
| - String[] lines = multipleLines.split("\n");
|
| - for (int i = 0; i < lines.length; i++) {
|
| - json.value(lines[i]);
|
| + json.name("addressLine").beginArray();
|
| + String multipleLines = ensureNotNull(mBillingAddress.getStreetAddress());
|
| + if (!TextUtils.isEmpty(multipleLines)) {
|
| + String[] lines = multipleLines.split("\n");
|
| + for (int i = 0; i < lines.length; i++) {
|
| + json.value(lines[i]);
|
| + }
|
| }
|
| + json.endArray();
|
| +
|
| + json.name("postalCode").value(ensureNotNull(mBillingAddress.getPostalCode()));
|
| + json.name("sortingCode").value(ensureNotNull(mBillingAddress.getSortingCode()));
|
| + json.name("languageCode").value(ensureNotNull(mBillingAddress.getLanguageCode()));
|
| + json.name("organization").value(ensureNotNull(mBillingAddress.getCompanyName()));
|
| + json.name("recipient").value(ensureNotNull(mBillingAddress.getFullName()));
|
| + json.name("careOf").value("");
|
| + json.name("phone").value(ensureNotNull(mBillingAddress.getPhoneNumber()));
|
| +
|
| + json.endObject();
|
| }
|
| - json.endArray();
|
| -
|
| - json.name("postalCode").value(ensureNotNull(mBillingAddress.getPostalCode()));
|
| - json.name("sortingCode").value(ensureNotNull(mBillingAddress.getSortingCode()));
|
| - json.name("languageCode").value(ensureNotNull(mBillingAddress.getLanguageCode()));
|
| - json.name("organization").value(ensureNotNull(mBillingAddress.getCompanyName()));
|
| - json.name("recipient").value(ensureNotNull(mBillingAddress.getFullName()));
|
| - json.name("careOf").value("");
|
| - json.name("phone").value(ensureNotNull(mBillingAddress.getPhoneNumber()));
|
| -
|
| - json.endObject();
|
|
|
| json.endObject();
|
| } catch (IOException e) {
|
| @@ -131,40 +125,4 @@
|
|
|
| @Override
|
| public void dismiss() {}
|
| -
|
| - /** @return Whether the card is complete and ready to be sent to the merchant as-is. */
|
| - public boolean isComplete() {
|
| - return mIsComplete;
|
| - }
|
| -
|
| - /** Marks this card complete and ready to be sent to the merchant without editing first. */
|
| - public void setIsComplete() {
|
| - mIsComplete = true;
|
| - }
|
| -
|
| - /**
|
| - * Updates the instrument and marks it "complete." Called after the user has edited this
|
| - * instrument.
|
| - *
|
| - * @param card The new credit card to use. The GUID should not change.
|
| - * @param billingAddress The billing address for the card. The GUID should match the billing
|
| - * address ID of the new card to use.
|
| - */
|
| - public void completeInstrument(CreditCard card, AutofillProfile billingAddress) {
|
| - assert card != null;
|
| - assert billingAddress != null;
|
| - assert card.getBillingAddressId() != null;
|
| - assert card.getBillingAddressId().equals(billingAddress.getGUID());
|
| -
|
| - mCard = card;
|
| - mBillingAddress = billingAddress;
|
| - mIsComplete = true;
|
| - updateIdentifierLabelsAndIcon(card.getGUID(), card.getObfuscatedNumber(), card.getName(),
|
| - card.getIssuerIconDrawableId());
|
| - }
|
| -
|
| - /** @return The credit card represented by this payment instrument. */
|
| - public CreditCard getCard() {
|
| - return mCard;
|
| - }
|
| }
|
|
|