| 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 #ifndef COMPONENTS_PAYMENTS_CORE_PAYMENT_INSTRUMENT_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CORE_PAYMENT_INSTRUMENT_H_ |
| 6 #define COMPONENTS_PAYMENTS_CORE_PAYMENT_INSTRUMENT_H_ | 6 #define COMPONENTS_PAYMENTS_CORE_PAYMENT_INSTRUMENT_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 | 13 |
| 14 namespace payments { | 14 namespace payments { |
| 15 | 15 |
| 16 // Base class which represents a form of payment in Payment Request. | 16 // Base class which represents a form of payment in Payment Request. |
| 17 class PaymentInstrument { | 17 class PaymentInstrument { |
| 18 public: | 18 public: |
| 19 // The type of this instrument instance. |
| 20 enum class Type { AUTOFILL }; |
| 21 |
| 19 class Delegate { | 22 class Delegate { |
| 20 public: | 23 public: |
| 21 virtual ~Delegate() {} | 24 virtual ~Delegate() {} |
| 22 | 25 |
| 23 // Should be called with method name (e.g., "visa") and json-serialized | 26 // Should be called with method name (e.g., "visa") and json-serialized |
| 24 // stringified details. | 27 // stringified details. |
| 25 virtual void OnInstrumentDetailsReady( | 28 virtual void OnInstrumentDetailsReady( |
| 26 const std::string& method_name, | 29 const std::string& method_name, |
| 27 const std::string& stringified_details) = 0; | 30 const std::string& stringified_details) = 0; |
| 28 | 31 |
| 29 virtual void OnInstrumentDetailsError() = 0; | 32 virtual void OnInstrumentDetailsError() = 0; |
| 30 }; | 33 }; |
| 31 | 34 |
| 32 virtual ~PaymentInstrument(); | 35 virtual ~PaymentInstrument(); |
| 33 | 36 |
| 34 // Will call into the |delegate| (can't be null) on success or error. | 37 // Will call into the |delegate| (can't be null) on success or error. |
| 35 virtual void InvokePaymentApp(Delegate* delegate) = 0; | 38 virtual void InvokePaymentApp(Delegate* delegate) = 0; |
| 36 // Returns true if the card is valid to be used as a payment method. | 39 // Returns whether the instrument is complete to be used as a payment method |
| 37 virtual bool IsValid() = 0; | 40 // without further editing. |
| 41 virtual bool IsCompleteForPayment() = 0; |
| 42 // Returns whether the instrument is valid for the purposes of responding to |
| 43 // canMakePayment. |
| 44 virtual bool IsValidForCanMakePayment() = 0; |
| 38 | 45 |
| 39 const std::string& method_name() const { return method_name_; } | 46 const std::string& method_name() const { return method_name_; } |
| 40 const base::string16& label() const { return label_; } | 47 const base::string16& label() const { return label_; } |
| 41 const base::string16& sublabel() const { return sublabel_; } | 48 const base::string16& sublabel() const { return sublabel_; } |
| 42 int icon_resource_id() const { return icon_resource_id_; } | 49 int icon_resource_id() const { return icon_resource_id_; } |
| 50 Type type() { return type_; } |
| 43 | 51 |
| 44 protected: | 52 protected: |
| 45 PaymentInstrument(const std::string& method_name, | 53 PaymentInstrument(const std::string& method_name, |
| 46 const base::string16& label, | 54 const base::string16& label, |
| 47 const base::string16& sublabel, | 55 const base::string16& sublabel, |
| 48 int icon_resource_id); | 56 int icon_resource_id, |
| 57 Type type); |
| 49 | 58 |
| 50 private: | 59 private: |
| 51 const std::string method_name_; | 60 const std::string method_name_; |
| 52 const base::string16 label_; | 61 const base::string16 label_; |
| 53 const base::string16 sublabel_; | 62 const base::string16 sublabel_; |
| 54 int icon_resource_id_; | 63 int icon_resource_id_; |
| 64 Type type_; |
| 55 | 65 |
| 56 DISALLOW_COPY_AND_ASSIGN(PaymentInstrument); | 66 DISALLOW_COPY_AND_ASSIGN(PaymentInstrument); |
| 57 }; | 67 }; |
| 58 | 68 |
| 59 } // namespace payments | 69 } // namespace payments |
| 60 | 70 |
| 61 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENT_INSTRUMENT_H_ | 71 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENT_INSTRUMENT_H_ |
| OLD | NEW |