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

Unified Diff: components/payments/core/autofill_payment_instrument.cc

Issue 2779283002: [Web Payments] Implement the CVC Unmask dialog. (Closed)
Patch Set: Created 3 years, 9 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
Index: components/payments/core/autofill_payment_instrument.cc
diff --git a/components/payments/core/autofill_payment_instrument.cc b/components/payments/core/autofill_payment_instrument.cc
index 00c59b6a925aba1bbd78977b27abd9f7be1cf508..946b56c998e4de52733c6d6d313452684f223705 100644
--- a/components/payments/core/autofill_payment_instrument.cc
+++ b/components/payments/core/autofill_payment_instrument.cc
@@ -17,7 +17,8 @@ AutofillPaymentInstrument::AutofillPaymentInstrument(
const std::string& method_name,
const autofill::CreditCard& card,
const std::vector<autofill::AutofillProfile*>& billing_profiles,
- const std::string& app_locale)
+ const std::string& app_locale,
+ FullCardRequestDelegate* full_card_request_delegate)
: PaymentInstrument(
method_name,
/* label= */ card.TypeAndLastFourDigits(),
@@ -28,26 +29,38 @@ AutofillPaymentInstrument::AutofillPaymentInstrument(
.icon_resource_id),
credit_card_(card),
billing_profiles_(billing_profiles),
- app_locale_(app_locale) {}
+ app_locale_(app_locale),
+ delegate_(nullptr),
+ full_card_request_delegate_(full_card_request_delegate),
+ weak_ptr_factory_(this) {}
AutofillPaymentInstrument::~AutofillPaymentInstrument() {}
void AutofillPaymentInstrument::InvokePaymentApp(
PaymentInstrument::Delegate* delegate) {
DCHECK(delegate);
+ delegate_ = delegate;
+
+ full_card_request_delegate_->DoFullCardRequest(
+ credit_card_, weak_ptr_factory_.GetWeakPtr());
+}
+
+bool AutofillPaymentInstrument::IsValid() {
+ return credit_card_.IsValid();
+}
+
+void AutofillPaymentInstrument::OnFullCardRequestSucceeded(
+ const autofill::CreditCard& card,
+ const base::string16& cvc) {
+ DCHECK(delegate_);
std::string stringified_details;
- // TODO(mathp): Show the CVC dialog and use the data instead of the
- // placeholder string.
std::unique_ptr<base::DictionaryValue> response_value =
payments::data_util::GetBasicCardResponseFromAutofillCreditCard(
- credit_card_, base::ASCIIToUTF16("123"), billing_profiles_,
- app_locale_)
+ credit_card_, cvc, billing_profiles_, app_locale_)
sebsg 2017/03/29 20:53:31 You should use the data from card that you got as
anthonyvd 2017/03/29 20:59:37 Ah great insight, thanks! Done.
sebsg 2017/03/29 21:12:01 It think it would be better to replace your credit
.ToDictionaryValue();
base::JSONWriter::Write(*response_value, &stringified_details);
- delegate->OnInstrumentDetailsReady(method_name(), stringified_details);
+ delegate_->OnInstrumentDetailsReady(method_name(), stringified_details);
}
-bool AutofillPaymentInstrument::IsValid() {
- return credit_card_.IsValid();
-}
+void AutofillPaymentInstrument::OnFullCardRequestFailed() {}
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698