Unity 8
Payments.h
1 /*
2  * Copyright (C) 2014 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef PAYMENTS_H
18 #define PAYMENTS_H
19 
20 #include <QObject>
21 
22 #include <libpay/pay-package.h>
23 
24 
25 class Payments : public QObject
26 {
27  Q_OBJECT
28  Q_DISABLE_COPY(Payments)
29  Q_PROPERTY(QString currency READ currency WRITE setCurrency NOTIFY currencyChanged)
30  Q_PROPERTY(double price READ price WRITE setPrice NOTIFY priceChanged)
31  Q_PROPERTY(QString storeItemId READ storeItemId WRITE setStoreItemId NOTIFY storeItemIdChanged)
32  Q_PROPERTY(QString formattedPrice READ formattedPrice NOTIFY formattedPriceChanged)
33 
34 public:
35  explicit Payments(QObject *parent = 0);
36  virtual ~Payments();
37 
38  QString currency() const;
39  double price() const;
40  QString storeItemId() const;
41  QString formattedPrice() const;
42  bool purchasing() const;
43 
44  void setCurrency(const QString& currency);
45  void setPrice(const double price);
46  void setStoreItemId(const QString& store_item_id);
47  void setPurchasing(bool is_purchasing);
48  Q_INVOKABLE void start();
49 
50 Q_SIGNALS:
51  void currencyChanged(const QString& currency);
52  void priceChanged(const double price);
53  void storeItemIdChanged(const QString &store_item_id);
54  void formattedPriceChanged(const QString &formatted_price);
55 
56  void purchaseError(const QString &error);
57  void purchaseCompleted();
58  void purchaseCancelled();
59 
60 private:
61  QString m_currency;
62  double m_price;
63  QString m_store_item_id;
64  bool m_purchasing;
65 
66  PayPackage *m_package;
67 };
68 
69 #endif // PAYMENTS_H