Merge lp:~diegosarmentero/pay-ui/update-production-url into lp:pay-ui

Proposed by Diego Sarmentero
Status: Superseded
Proposed branch: lp:~diegosarmentero/pay-ui/update-production-url
Merge into: lp:pay-ui
Diff against target: 229 lines (+66/-14)
8 files modified
app/payui.qml (+48/-2)
app/ui/DirectPurchase.qml (+2/-1)
backend/modules/payui/network.cpp (+6/-2)
backend/modules/payui/network.h (+3/-2)
backend/modules/payui/purchase.cpp (+2/-2)
backend/modules/payui/purchase.h (+1/-1)
backend/tests/test_network.cpp (+3/-3)
manifest.json (+1/-1)
To merge this branch: bzr merge lp:~diegosarmentero/pay-ui/update-production-url
Reviewer Review Type Date Requested Status
Unity API Team Pending
Review via email: mp+232407@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-27.

Commit message

- Update production url

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/payui.qml'
2--- app/payui.qml 2014-08-22 14:31:57 +0000
3+++ app/payui.qml 2014-08-27 13:32:21 +0000
4@@ -126,6 +126,12 @@
5
6 onNoPreferredPaymentMethod: {
7 direct.hasPreferredPayment = false;
8+ var values = mainView.getLastPayment();
9+ var backendid = values[0];
10+ var paymentid = values[1];
11+ if (backendid != "" && paymentid != "") {
12+ direct.hasStoredPayment = true;
13+ }
14 }
15
16 onPasswordValid: {
17@@ -201,6 +207,7 @@
18 function(tx) {
19 // Create the database if it doesn't already exist
20 tx.executeSql('CREATE TABLE IF NOT EXISTS PayUI(date TEXT)');
21+ tx.executeSql('CREATE TABLE IF NOT EXISTS PayUIPayment(backendid TEXT, paymentid TEXT)');
22 var rs = tx.executeSql('SELECT * FROM PayUI');
23 if (rs.rows.length == 0) {
24 // If it's empty, add initial date.
25@@ -241,6 +248,36 @@
26 return valid;
27 }
28
29+ function getLastPayment() {
30+ var backendid = "";
31+ var paymentid = "";
32+ var db = LocalStorage.openDatabaseSync("PayUI", "1.0", "PayUI Credentials Date", 100);
33+ db.transaction(
34+ function(tx) {
35+ var rs = tx.executeSql('SELECT * FROM PayUIPayment');
36+ if (rs.rows.length > 0) {
37+ backendid = rs.rows.item(0).backendid;
38+ paymentid = rs.rows.item(0).paymentid;
39+ }
40+ }
41+ )
42+ return [backendid, paymentid];
43+ }
44+
45+ function updatePayment(backendid, paymentid) {
46+ var db = LocalStorage.openDatabaseSync("PayUI", "1.0", "PayUI Credentials Date", 100);
47+ db.transaction(
48+ function(tx) {
49+ var rs = tx.executeSql('SELECT * FROM PayUIPayment');
50+ if (rs.rows.length > 0) {
51+ tx.executeSql('UPDATE PayUIPayment SET backendid = "' + backendid + '", paymentid = "' + paymentid + '"');
52+ } else {
53+ tx.executeSql('INSERT INTO PayUIPayment VALUES(?, ?)', [backendid, paymentid]);
54+ }
55+ }
56+ )
57+ }
58+
59 ErrorDialog {
60 id: purchaseErrorDialog
61 title: i18n.tr("Purchase failed")
62@@ -351,9 +388,14 @@
63 onBuy: {
64 if (direct.hasPayments && direct.hasPreferredPayment) {
65 mainView.purchasing = true;
66- purchase.buyItemWithPreferredPayment(email, password);
67+ purchase.buyItemWithPreferredPayment(email, password, mainView.recentLogin);
68 showLoading();
69- } else {
70+ } else if (direct.hasStoredPayment) {
71+ var values = mainView.getLastPayment();
72+ var backendid = values[0];
73+ var paymentid = values[1];
74+ purchase.buyItem(email, password, paymentid, backendid, mainView.recentLogin);
75+ }else {
76 mainView.state = "checkout";
77 pageStack.push(checkout);
78 }
79@@ -372,6 +414,10 @@
80 onBuy: {
81 mainView.purchasing = true;
82 showLoading();
83+ if (!direct.hasPreferredPayment) {
84+ mainView.updatePayment(backendId, paymentId);
85+ }
86+
87 var password = direct.password;
88 purchase.buyItem(email, password, paymentId, backendId, mainView.recentLogin);
89 }
90
91=== modified file 'app/ui/DirectPurchase.qml'
92--- app/ui/DirectPurchase.qml 2014-08-22 14:31:57 +0000
93+++ app/ui/DirectPurchase.qml 2014-08-27 13:32:21 +0000
94@@ -32,6 +32,7 @@
95 property alias price: priceItemLabel.text
96 property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
97 property bool hasPreferredPayment: true
98+ property bool hasStoredPayment: false
99 property bool beforeTimeout: false
100
101 function launchPurchase() {
102@@ -245,7 +246,7 @@
103 Button {
104 id: buyButton
105 objectName: "buyButtonDirect"
106- text: pageDirectPayment.hasPreferredPayment ? i18n.tr("Buy Now") : i18n.tr("Confirm")
107+ text: (pageDirectPayment.hasPreferredPayment || pageDirectPayment.hasStoredPayment) ? i18n.tr("Buy Now") : i18n.tr("Confirm")
108 color: UbuntuColors.orange
109 width: parent.buttonsWidth
110 enabled: (passwordField.text.length > 7 || pageDirectPayment.beforeTimeout) ? true : false
111
112=== modified file 'backend/modules/payui/network.cpp'
113--- backend/modules/payui/network.cpp 2014-08-20 20:09:06 +0000
114+++ backend/modules/payui/network.cpp 2014-08-27 13:32:21 +0000
115@@ -249,13 +249,17 @@
116 }
117
118 void Network::buyItemWithPreferredPaymentType(const QString& email, const QString& password,
119- const QString& appid, const QString& itemid)
120+ const QString& appid, const QString& itemid, bool recentLogin)
121 {
122 m_selectedPaymentId = m_preferred->paymentId();
123 m_selectedBackendId = m_preferred->backendId();
124 m_selectedAppId = appid;
125 m_selectedItemId = itemid;
126- updateCredentials(email, password);
127+ if (recentLogin) {
128+ purchaseProcess();
129+ } else {
130+ updateCredentials(email, password);
131+ }
132 }
133
134 void Network::buyItem(const QString& email, const QString& password,
135
136=== modified file 'backend/modules/payui/network.h'
137--- backend/modules/payui/network.h 2014-08-20 20:09:06 +0000
138+++ backend/modules/payui/network.h 2014-08-27 13:32:21 +0000
139@@ -35,7 +35,7 @@
140 namespace UbuntuPurchase {
141
142 constexpr static const char* PAY_BASE_URL_ENVVAR{"PAY_BASE_URL"};
143-constexpr static const char* PAY_BASE_URL{"https://sc.ubuntu.com"};
144+constexpr static const char* PAY_BASE_URL{"https://software-center.ubuntu.com"};
145 constexpr static const char* PAY_API_ROOT{"/api/2.0/click"};
146
147 class RequestObject : public QObject
148@@ -62,7 +62,8 @@
149 const QString& itemid, const QString& paymentId, const QString& backendId,
150 bool recentLogin);
151 void buyItemWithPreferredPaymentType(const QString& email, const QString& password,
152- const QString& appid, const QString& itemid);
153+ const QString& appid, const QString& itemid,
154+ bool recentLogin);
155 void getItemInfo(const QString &packagename);
156 void checkPassword(const QString& email, const QString& password);
157 void getCredentials();
158
159=== modified file 'backend/modules/payui/purchase.cpp'
160--- backend/modules/payui/purchase.cpp 2014-08-20 20:09:06 +0000
161+++ backend/modules/payui/purchase.cpp 2014-08-27 13:32:21 +0000
162@@ -101,9 +101,9 @@
163 m_network.checkPassword(email, password);
164 }
165
166-void Purchase::buyItemWithPreferredPayment(QString email, QString password)
167+void Purchase::buyItemWithPreferredPayment(QString email, QString password, bool recentLogin)
168 {
169- m_network.buyItemWithPreferredPaymentType(email, password, m_appid, m_itemid);
170+ m_network.buyItemWithPreferredPaymentType(email, password, m_appid, m_itemid, recentLogin);
171 }
172
173 void Purchase::buyItem(QString email, QString password, QString paymentId, QString backendId, bool recentLogin)
174
175=== modified file 'backend/modules/payui/purchase.h'
176--- backend/modules/payui/purchase.h 2014-08-20 20:09:06 +0000
177+++ backend/modules/payui/purchase.h 2014-08-27 13:32:21 +0000
178@@ -16,7 +16,7 @@
179
180 Q_INVOKABLE void getItemDetails(QString packagename, QString itemid);
181 Q_INVOKABLE void getPaymentTypes();
182- Q_INVOKABLE void buyItemWithPreferredPayment(QString email, QString password);
183+ Q_INVOKABLE void buyItemWithPreferredPayment(QString email, QString password, bool recentLogin);
184 Q_INVOKABLE void buyItem(QString email, QString password, QString paymentId, QString backendId, bool recentLogin);
185 Q_INVOKABLE void checkCredentials();
186 Q_INVOKABLE QString getAddPaymentUrl();
187
188=== modified file 'backend/tests/test_network.cpp'
189--- backend/tests/test_network.cpp 2014-08-20 19:30:32 +0000
190+++ backend/tests/test_network.cpp 2014-08-27 13:32:21 +0000
191@@ -167,7 +167,7 @@
192 network.requestPaymentTypes();
193 QTRY_COMPARE(spy.count(), 1);
194 QSignalSpy spy2(&network, SIGNAL(buyItemSucceeded()));
195- network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid");
196+ network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid", false);
197 QTRY_COMPARE(spy2.count(), 1);
198 }
199
200@@ -180,7 +180,7 @@
201 QTRY_COMPARE(spy.count(), 1);
202 setenv(PAY_BASE_URL_ENVVAR, "http://localhost:8000/fail/", 1);
203 QSignalSpy spy2(&network, SIGNAL(buyItemFailed()));
204- network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid");
205+ network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid", false);
206 QTRY_COMPARE(spy2.count(), 1);
207 }
208
209@@ -193,7 +193,7 @@
210 QTRY_COMPARE(spy.count(), 1);
211 setenv(PAY_BASE_URL_ENVVAR, "http://localhost:8000/interaction/", 1);
212 QSignalSpy spy2(&network, SIGNAL(buyInteractionRequired(QString)));
213- network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid");
214+ network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid", false);
215 QTRY_COMPARE(spy2.count(), 1);
216 }
217
218
219=== modified file 'manifest.json'
220--- manifest.json 2014-08-22 14:31:57 +0000
221+++ manifest.json 2014-08-27 13:32:21 +0000
222@@ -11,6 +11,6 @@
223 "desktop": "payui_payui.desktop"
224 }
225 },
226- "version": "0.3.13",
227+ "version": "0.3.15",
228 "maintainer": "Diego Sarmentero <diego.sarmentero@canonical.com>"
229 }

Subscribers

People subscribed via source and target branches

to all changes: