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

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

Issue 2733953003: [Payments] Return a basic card response (Closed)
Patch Set: tests 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/basic_card_response.cc
diff --git a/components/payments/core/basic_card_response.cc b/components/payments/core/basic_card_response.cc
new file mode 100644
index 0000000000000000000000000000000000000000..215e202e706321e38fb7b7f1323bab90594bbe7d
--- /dev/null
+++ b/components/payments/core/basic_card_response.cc
@@ -0,0 +1,61 @@
+// 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/basic_card_response.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "base/values.h"
+
+namespace web {
+
+namespace {
+
+// These are defined as part of the spec at:
+// https://w3c.github.io/browser-payment-api/.
please use gerrit instead 2017/03/08 14:46:09 https://w3c.github.io/webpayments-methods-card/#ba
Mathieu 2017/03/08 18:04:25 Done.
+static const char kCardBillingAddress[] = "billingAddress";
+static const char kCardCardholderName[] = "cardholderName";
+static const char kCardCardNumber[] = "cardNumber";
+static const char kCardCardSecurityCode[] = "cardSecurityCode";
+static const char kCardExpiryMonth[] = "expiryMonth";
+static const char kCardExpiryYear[] = "expiryYear";
+
+} // namespace
+
+BasicCardResponse::BasicCardResponse() {}
+BasicCardResponse::BasicCardResponse(const BasicCardResponse& other) = default;
+BasicCardResponse::~BasicCardResponse() = default;
+
+bool BasicCardResponse::operator==(const BasicCardResponse& other) const {
+ return this->cardholder_name == other.cardholder_name &&
+ this->card_number == other.card_number &&
+ this->expiry_month == other.expiry_month &&
+ this->expiry_year == other.expiry_year &&
+ this->card_security_code == other.card_security_code &&
+ this->billing_address == other.billing_address;
+}
+
+bool BasicCardResponse::operator!=(const BasicCardResponse& other) const {
+ return !(*this == other);
+}
+
+std::unique_ptr<base::DictionaryValue> BasicCardResponse::ToDictionaryValue()
+ const {
+ std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
please use gerrit instead 2017/03/08 14:46:09 base::MakeUnique<base::DitionaryValue>();
Mathieu 2017/03/08 18:04:25 Done.
+
+ if (!this->cardholder_name.empty())
+ result->SetString(kCardCardholderName, this->cardholder_name);
+ result->SetString(kCardCardNumber, this->card_number);
+ if (!this->expiry_month.empty())
+ result->SetString(kCardExpiryMonth, this->expiry_month);
+ if (!this->expiry_year.empty())
+ result->SetString(kCardExpiryYear, this->expiry_year);
+ if (!this->card_security_code.empty())
+ result->SetString(kCardCardSecurityCode, this->card_security_code);
+ if (!this->billing_address.ToDictionaryValue()->empty())
+ result->Set(kCardBillingAddress, this->billing_address.ToDictionaryValue());
+
+ return result;
+}
+
+} // namespace web

Powered by Google App Engine
This is Rietveld 408576698