| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "components/payments/core/autofill_payment_instrument.h" | 5 #include "components/payments/core/autofill_payment_instrument.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 country_code = autofill::AutofillCountry::CountryCodeForLocale(app_locale_); | 71 country_code = autofill::AutofillCountry::CountryCodeForLocale(app_locale_); |
| 72 } | 72 } |
| 73 payment_request_delegate_->GetAddressNormalizer()->StartAddressNormalization( | 73 payment_request_delegate_->GetAddressNormalizer()->StartAddressNormalization( |
| 74 billing_address_, country_code, /*timeout_seconds=*/5, this); | 74 billing_address_, country_code, /*timeout_seconds=*/5, this); |
| 75 | 75 |
| 76 payment_request_delegate_->DoFullCardRequest(credit_card_, | 76 payment_request_delegate_->DoFullCardRequest(credit_card_, |
| 77 weak_ptr_factory_.GetWeakPtr()); | 77 weak_ptr_factory_.GetWeakPtr()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool AutofillPaymentInstrument::IsCompleteForPayment() { | 80 bool AutofillPaymentInstrument::IsCompleteForPayment() { |
| 81 // COMPLETE or EXPIRED cards are considered valid for payment. The user will |
| 82 // be prompted to enter the new expiration at the CVC step. |
| 81 return autofill::GetCompletionStatusForCard(credit_card_, app_locale_, | 83 return autofill::GetCompletionStatusForCard(credit_card_, app_locale_, |
| 82 billing_profiles_) == | 84 billing_profiles_) <= |
| 83 autofill::CREDIT_CARD_COMPLETE; | 85 autofill::CREDIT_CARD_EXPIRED; |
| 84 } | 86 } |
| 85 | 87 |
| 86 base::string16 AutofillPaymentInstrument::GetMissingInfoLabel() { | 88 base::string16 AutofillPaymentInstrument::GetMissingInfoLabel() { |
| 87 return autofill::GetCompletionMessageForCard( | 89 return autofill::GetCompletionMessageForCard( |
| 88 autofill::GetCompletionStatusForCard(credit_card_, app_locale_, | 90 autofill::GetCompletionStatusForCard(credit_card_, app_locale_, |
| 89 billing_profiles_)); | 91 billing_profiles_)); |
| 90 } | 92 } |
| 91 | 93 |
| 92 bool AutofillPaymentInstrument::IsValidForCanMakePayment() { | 94 bool AutofillPaymentInstrument::IsValidForCanMakePayment() { |
| 93 autofill::CreditCardCompletionStatus status = | 95 autofill::CreditCardCompletionStatus status = |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 .ToDictionaryValue(); | 164 .ToDictionaryValue(); |
| 163 std::string stringified_details; | 165 std::string stringified_details; |
| 164 base::JSONWriter::Write(*response_value, &stringified_details); | 166 base::JSONWriter::Write(*response_value, &stringified_details); |
| 165 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); | 167 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); |
| 166 | 168 |
| 167 delegate_ = nullptr; | 169 delegate_ = nullptr; |
| 168 cvc_ = base::UTF8ToUTF16(""); | 170 cvc_ = base::UTF8ToUTF16(""); |
| 169 } | 171 } |
| 170 | 172 |
| 171 } // namespace payments | 173 } // namespace payments |
| OLD | NEW |