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

Side by Side Diff: components/payments/core/basic_card_response.cc

Issue 2733953003: [Payments] Return a basic card response (Closed)
Patch Set: ios and android build fix 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/payments/core/basic_card_response.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "base/values.h"
9
10 namespace web {
11
12 namespace {
13
14 // These are defined as part of the spec at:
15 // https://w3c.github.io/browser-payment-api/.
16 static const char kCardBillingAddress[] = "billingAddress";
17 static const char kCardCardholderName[] = "cardholderName";
18 static const char kCardCardNumber[] = "cardNumber";
19 static const char kCardCardSecurityCode[] = "cardSecurityCode";
20 static const char kCardExpiryMonth[] = "expiryMonth";
21 static const char kCardExpiryYear[] = "expiryYear";
22
23 } // namespace
24
25 BasicCardResponse::BasicCardResponse() {}
26 BasicCardResponse::BasicCardResponse(const BasicCardResponse& other) = default;
27 BasicCardResponse::~BasicCardResponse() = default;
28
29 bool BasicCardResponse::operator==(const BasicCardResponse& other) const {
30 return this->cardholder_name == other.cardholder_name &&
31 this->card_number == other.card_number &&
32 this->expiry_month == other.expiry_month &&
33 this->expiry_year == other.expiry_year &&
34 this->card_security_code == other.card_security_code &&
35 this->billing_address == other.billing_address;
36 }
37
38 bool BasicCardResponse::operator!=(const BasicCardResponse& other) const {
39 return !(*this == other);
40 }
41
42 std::unique_ptr<base::DictionaryValue> BasicCardResponse::ToDictionaryValue()
43 const {
44 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
anthonyvd 2017/03/08 16:41:48 nit: base::MakeUnique
Mathieu 2017/03/08 18:04:26 Done.
45
46 if (!this->cardholder_name.empty())
47 result->SetString(kCardCardholderName, this->cardholder_name);
48 result->SetString(kCardCardNumber, this->card_number);
49 if (!this->expiry_month.empty())
50 result->SetString(kCardExpiryMonth, this->expiry_month);
51 if (!this->expiry_year.empty())
52 result->SetString(kCardExpiryYear, this->expiry_year);
53 if (!this->card_security_code.empty())
54 result->SetString(kCardCardSecurityCode, this->card_security_code);
55 if (!this->billing_address.ToDictionaryValue()->empty())
56 result->Set(kCardBillingAddress, this->billing_address.ToDictionaryValue());
57
58 return result;
59 }
60
61 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698