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

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

Issue 2733953003: [Payments] Return a basic card response (Closed)
Patch Set: addressed comments from anthony 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
new file mode 100644
index 0000000000000000000000000000000000000000..3f55efdde6d3333de27487f7af29a185e400d102
--- /dev/null
+++ b/components/payments/core/autofill_payment_instrument.cc
@@ -0,0 +1,42 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/payments/core/autofill_payment_instrument.h"
+
+#include "base/json/json_writer.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/values.h"
+#include "components/autofill/core/browser/autofill_data_util.h"
+#include "components/payments/core/basic_card_response.h"
+#include "components/payments/core/payment_request_data_util.h"
+
+namespace payments {
+
+AutofillPaymentInstrument::AutofillPaymentInstrument(
+ const std::string& method_name,
+ const autofill::CreditCard& credit_card,
+ const std::vector<autofill::AutofillProfile*>& billing_profiles,
+ const std::string& app_locale)
+ : PaymentInstrument(method_name),
+ credit_card_(credit_card),
+ billing_profiles_(billing_profiles),
+ app_locale_(app_locale) {}
+AutofillPaymentInstrument::~AutofillPaymentInstrument() {}
+
+void AutofillPaymentInstrument::InvokePaymentApp(
+ PaymentInstrument::Delegate* delegate) {
+ 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_)
+ .ToDictionaryValue();
+ base::JSONWriter::Write(*response_value, &stringified_details);
+ delegate->OnInstrumentDetailsReady(method_name(), stringified_details);
+}
+
+} // namespace payments
« no previous file with comments | « components/payments/core/autofill_payment_instrument.h ('k') | components/payments/core/basic_card_response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698