Merge lp:~diegosarmentero/pay-ui/update-production-url into lp:pay-ui
- update-production-url
- Merge into first-branch
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 | ||||
Related bugs: |
|
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
Description of the change
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 | 126 | 126 | ||
6 | 127 | onNoPreferredPaymentMethod: { | 127 | onNoPreferredPaymentMethod: { |
7 | 128 | direct.hasPreferredPayment = false; | 128 | direct.hasPreferredPayment = false; |
8 | 129 | var values = mainView.getLastPayment(); | ||
9 | 130 | var backendid = values[0]; | ||
10 | 131 | var paymentid = values[1]; | ||
11 | 132 | if (backendid != "" && paymentid != "") { | ||
12 | 133 | direct.hasStoredPayment = true; | ||
13 | 134 | } | ||
14 | 129 | } | 135 | } |
15 | 130 | 136 | ||
16 | 131 | onPasswordValid: { | 137 | onPasswordValid: { |
17 | @@ -201,6 +207,7 @@ | |||
18 | 201 | function(tx) { | 207 | function(tx) { |
19 | 202 | // Create the database if it doesn't already exist | 208 | // Create the database if it doesn't already exist |
20 | 203 | tx.executeSql('CREATE TABLE IF NOT EXISTS PayUI(date TEXT)'); | 209 | tx.executeSql('CREATE TABLE IF NOT EXISTS PayUI(date TEXT)'); |
21 | 210 | tx.executeSql('CREATE TABLE IF NOT EXISTS PayUIPayment(backendid TEXT, paymentid TEXT)'); | ||
22 | 204 | var rs = tx.executeSql('SELECT * FROM PayUI'); | 211 | var rs = tx.executeSql('SELECT * FROM PayUI'); |
23 | 205 | if (rs.rows.length == 0) { | 212 | if (rs.rows.length == 0) { |
24 | 206 | // If it's empty, add initial date. | 213 | // If it's empty, add initial date. |
25 | @@ -241,6 +248,36 @@ | |||
26 | 241 | return valid; | 248 | return valid; |
27 | 242 | } | 249 | } |
28 | 243 | 250 | ||
29 | 251 | function getLastPayment() { | ||
30 | 252 | var backendid = ""; | ||
31 | 253 | var paymentid = ""; | ||
32 | 254 | var db = LocalStorage.openDatabaseSync("PayUI", "1.0", "PayUI Credentials Date", 100); | ||
33 | 255 | db.transaction( | ||
34 | 256 | function(tx) { | ||
35 | 257 | var rs = tx.executeSql('SELECT * FROM PayUIPayment'); | ||
36 | 258 | if (rs.rows.length > 0) { | ||
37 | 259 | backendid = rs.rows.item(0).backendid; | ||
38 | 260 | paymentid = rs.rows.item(0).paymentid; | ||
39 | 261 | } | ||
40 | 262 | } | ||
41 | 263 | ) | ||
42 | 264 | return [backendid, paymentid]; | ||
43 | 265 | } | ||
44 | 266 | |||
45 | 267 | function updatePayment(backendid, paymentid) { | ||
46 | 268 | var db = LocalStorage.openDatabaseSync("PayUI", "1.0", "PayUI Credentials Date", 100); | ||
47 | 269 | db.transaction( | ||
48 | 270 | function(tx) { | ||
49 | 271 | var rs = tx.executeSql('SELECT * FROM PayUIPayment'); | ||
50 | 272 | if (rs.rows.length > 0) { | ||
51 | 273 | tx.executeSql('UPDATE PayUIPayment SET backendid = "' + backendid + '", paymentid = "' + paymentid + '"'); | ||
52 | 274 | } else { | ||
53 | 275 | tx.executeSql('INSERT INTO PayUIPayment VALUES(?, ?)', [backendid, paymentid]); | ||
54 | 276 | } | ||
55 | 277 | } | ||
56 | 278 | ) | ||
57 | 279 | } | ||
58 | 280 | |||
59 | 244 | ErrorDialog { | 281 | ErrorDialog { |
60 | 245 | id: purchaseErrorDialog | 282 | id: purchaseErrorDialog |
61 | 246 | title: i18n.tr("Purchase failed") | 283 | title: i18n.tr("Purchase failed") |
62 | @@ -351,9 +388,14 @@ | |||
63 | 351 | onBuy: { | 388 | onBuy: { |
64 | 352 | if (direct.hasPayments && direct.hasPreferredPayment) { | 389 | if (direct.hasPayments && direct.hasPreferredPayment) { |
65 | 353 | mainView.purchasing = true; | 390 | mainView.purchasing = true; |
67 | 354 | purchase.buyItemWithPreferredPayment(email, password); | 391 | purchase.buyItemWithPreferredPayment(email, password, mainView.recentLogin); |
68 | 355 | showLoading(); | 392 | showLoading(); |
70 | 356 | } else { | 393 | } else if (direct.hasStoredPayment) { |
71 | 394 | var values = mainView.getLastPayment(); | ||
72 | 395 | var backendid = values[0]; | ||
73 | 396 | var paymentid = values[1]; | ||
74 | 397 | purchase.buyItem(email, password, paymentid, backendid, mainView.recentLogin); | ||
75 | 398 | }else { | ||
76 | 357 | mainView.state = "checkout"; | 399 | mainView.state = "checkout"; |
77 | 358 | pageStack.push(checkout); | 400 | pageStack.push(checkout); |
78 | 359 | } | 401 | } |
79 | @@ -372,6 +414,10 @@ | |||
80 | 372 | onBuy: { | 414 | onBuy: { |
81 | 373 | mainView.purchasing = true; | 415 | mainView.purchasing = true; |
82 | 374 | showLoading(); | 416 | showLoading(); |
83 | 417 | if (!direct.hasPreferredPayment) { | ||
84 | 418 | mainView.updatePayment(backendId, paymentId); | ||
85 | 419 | } | ||
86 | 420 | |||
87 | 375 | var password = direct.password; | 421 | var password = direct.password; |
88 | 376 | purchase.buyItem(email, password, paymentId, backendId, mainView.recentLogin); | 422 | purchase.buyItem(email, password, paymentId, backendId, mainView.recentLogin); |
89 | 377 | } | 423 | } |
90 | 378 | 424 | ||
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 | 32 | property alias price: priceItemLabel.text | 32 | property alias price: priceItemLabel.text |
96 | 33 | property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0 | 33 | property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0 |
97 | 34 | property bool hasPreferredPayment: true | 34 | property bool hasPreferredPayment: true |
98 | 35 | property bool hasStoredPayment: false | ||
99 | 35 | property bool beforeTimeout: false | 36 | property bool beforeTimeout: false |
100 | 36 | 37 | ||
101 | 37 | function launchPurchase() { | 38 | function launchPurchase() { |
102 | @@ -245,7 +246,7 @@ | |||
103 | 245 | Button { | 246 | Button { |
104 | 246 | id: buyButton | 247 | id: buyButton |
105 | 247 | objectName: "buyButtonDirect" | 248 | objectName: "buyButtonDirect" |
107 | 248 | text: pageDirectPayment.hasPreferredPayment ? i18n.tr("Buy Now") : i18n.tr("Confirm") | 249 | text: (pageDirectPayment.hasPreferredPayment || pageDirectPayment.hasStoredPayment) ? i18n.tr("Buy Now") : i18n.tr("Confirm") |
108 | 249 | color: UbuntuColors.orange | 250 | color: UbuntuColors.orange |
109 | 250 | width: parent.buttonsWidth | 251 | width: parent.buttonsWidth |
110 | 251 | enabled: (passwordField.text.length > 7 || pageDirectPayment.beforeTimeout) ? true : false | 252 | enabled: (passwordField.text.length > 7 || pageDirectPayment.beforeTimeout) ? true : false |
111 | 252 | 253 | ||
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 | 249 | } | 249 | } |
117 | 250 | 250 | ||
118 | 251 | void Network::buyItemWithPreferredPaymentType(const QString& email, const QString& password, | 251 | void Network::buyItemWithPreferredPaymentType(const QString& email, const QString& password, |
120 | 252 | const QString& appid, const QString& itemid) | 252 | const QString& appid, const QString& itemid, bool recentLogin) |
121 | 253 | { | 253 | { |
122 | 254 | m_selectedPaymentId = m_preferred->paymentId(); | 254 | m_selectedPaymentId = m_preferred->paymentId(); |
123 | 255 | m_selectedBackendId = m_preferred->backendId(); | 255 | m_selectedBackendId = m_preferred->backendId(); |
124 | 256 | m_selectedAppId = appid; | 256 | m_selectedAppId = appid; |
125 | 257 | m_selectedItemId = itemid; | 257 | m_selectedItemId = itemid; |
127 | 258 | updateCredentials(email, password); | 258 | if (recentLogin) { |
128 | 259 | purchaseProcess(); | ||
129 | 260 | } else { | ||
130 | 261 | updateCredentials(email, password); | ||
131 | 262 | } | ||
132 | 259 | } | 263 | } |
133 | 260 | 264 | ||
134 | 261 | void Network::buyItem(const QString& email, const QString& password, | 265 | void Network::buyItem(const QString& email, const QString& password, |
135 | 262 | 266 | ||
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 | 35 | namespace UbuntuPurchase { | 35 | namespace UbuntuPurchase { |
141 | 36 | 36 | ||
142 | 37 | constexpr static const char* PAY_BASE_URL_ENVVAR{"PAY_BASE_URL"}; | 37 | constexpr static const char* PAY_BASE_URL_ENVVAR{"PAY_BASE_URL"}; |
144 | 38 | constexpr static const char* PAY_BASE_URL{"https://sc.ubuntu.com"}; | 38 | constexpr static const char* PAY_BASE_URL{"https://software-center.ubuntu.com"}; |
145 | 39 | constexpr static const char* PAY_API_ROOT{"/api/2.0/click"}; | 39 | constexpr static const char* PAY_API_ROOT{"/api/2.0/click"}; |
146 | 40 | 40 | ||
147 | 41 | class RequestObject : public QObject | 41 | class RequestObject : public QObject |
148 | @@ -62,7 +62,8 @@ | |||
149 | 62 | const QString& itemid, const QString& paymentId, const QString& backendId, | 62 | const QString& itemid, const QString& paymentId, const QString& backendId, |
150 | 63 | bool recentLogin); | 63 | bool recentLogin); |
151 | 64 | void buyItemWithPreferredPaymentType(const QString& email, const QString& password, | 64 | void buyItemWithPreferredPaymentType(const QString& email, const QString& password, |
153 | 65 | const QString& appid, const QString& itemid); | 65 | const QString& appid, const QString& itemid, |
154 | 66 | bool recentLogin); | ||
155 | 66 | void getItemInfo(const QString &packagename); | 67 | void getItemInfo(const QString &packagename); |
156 | 67 | void checkPassword(const QString& email, const QString& password); | 68 | void checkPassword(const QString& email, const QString& password); |
157 | 68 | void getCredentials(); | 69 | void getCredentials(); |
158 | 69 | 70 | ||
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 | 101 | m_network.checkPassword(email, password); | 101 | m_network.checkPassword(email, password); |
164 | 102 | } | 102 | } |
165 | 103 | 103 | ||
167 | 104 | void Purchase::buyItemWithPreferredPayment(QString email, QString password) | 104 | void Purchase::buyItemWithPreferredPayment(QString email, QString password, bool recentLogin) |
168 | 105 | { | 105 | { |
170 | 106 | m_network.buyItemWithPreferredPaymentType(email, password, m_appid, m_itemid); | 106 | m_network.buyItemWithPreferredPaymentType(email, password, m_appid, m_itemid, recentLogin); |
171 | 107 | } | 107 | } |
172 | 108 | 108 | ||
173 | 109 | void Purchase::buyItem(QString email, QString password, QString paymentId, QString backendId, bool recentLogin) | 109 | void Purchase::buyItem(QString email, QString password, QString paymentId, QString backendId, bool recentLogin) |
174 | 110 | 110 | ||
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 | 16 | 16 | ||
180 | 17 | Q_INVOKABLE void getItemDetails(QString packagename, QString itemid); | 17 | Q_INVOKABLE void getItemDetails(QString packagename, QString itemid); |
181 | 18 | Q_INVOKABLE void getPaymentTypes(); | 18 | Q_INVOKABLE void getPaymentTypes(); |
183 | 19 | Q_INVOKABLE void buyItemWithPreferredPayment(QString email, QString password); | 19 | Q_INVOKABLE void buyItemWithPreferredPayment(QString email, QString password, bool recentLogin); |
184 | 20 | Q_INVOKABLE void buyItem(QString email, QString password, QString paymentId, QString backendId, bool recentLogin); | 20 | Q_INVOKABLE void buyItem(QString email, QString password, QString paymentId, QString backendId, bool recentLogin); |
185 | 21 | Q_INVOKABLE void checkCredentials(); | 21 | Q_INVOKABLE void checkCredentials(); |
186 | 22 | Q_INVOKABLE QString getAddPaymentUrl(); | 22 | Q_INVOKABLE QString getAddPaymentUrl(); |
187 | 23 | 23 | ||
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 | 167 | network.requestPaymentTypes(); | 167 | network.requestPaymentTypes(); |
193 | 168 | QTRY_COMPARE(spy.count(), 1); | 168 | QTRY_COMPARE(spy.count(), 1); |
194 | 169 | QSignalSpy spy2(&network, SIGNAL(buyItemSucceeded())); | 169 | QSignalSpy spy2(&network, SIGNAL(buyItemSucceeded())); |
196 | 170 | network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid"); | 170 | network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid", false); |
197 | 171 | QTRY_COMPARE(spy2.count(), 1); | 171 | QTRY_COMPARE(spy2.count(), 1); |
198 | 172 | } | 172 | } |
199 | 173 | 173 | ||
200 | @@ -180,7 +180,7 @@ | |||
201 | 180 | QTRY_COMPARE(spy.count(), 1); | 180 | QTRY_COMPARE(spy.count(), 1); |
202 | 181 | setenv(PAY_BASE_URL_ENVVAR, "http://localhost:8000/fail/", 1); | 181 | setenv(PAY_BASE_URL_ENVVAR, "http://localhost:8000/fail/", 1); |
203 | 182 | QSignalSpy spy2(&network, SIGNAL(buyItemFailed())); | 182 | QSignalSpy spy2(&network, SIGNAL(buyItemFailed())); |
205 | 183 | network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid"); | 183 | network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid", false); |
206 | 184 | QTRY_COMPARE(spy2.count(), 1); | 184 | QTRY_COMPARE(spy2.count(), 1); |
207 | 185 | } | 185 | } |
208 | 186 | 186 | ||
209 | @@ -193,7 +193,7 @@ | |||
210 | 193 | QTRY_COMPARE(spy.count(), 1); | 193 | QTRY_COMPARE(spy.count(), 1); |
211 | 194 | setenv(PAY_BASE_URL_ENVVAR, "http://localhost:8000/interaction/", 1); | 194 | setenv(PAY_BASE_URL_ENVVAR, "http://localhost:8000/interaction/", 1); |
212 | 195 | QSignalSpy spy2(&network, SIGNAL(buyInteractionRequired(QString))); | 195 | QSignalSpy spy2(&network, SIGNAL(buyInteractionRequired(QString))); |
214 | 196 | network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid"); | 196 | network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid", false); |
215 | 197 | QTRY_COMPARE(spy2.count(), 1); | 197 | QTRY_COMPARE(spy2.count(), 1); |
216 | 198 | } | 198 | } |
217 | 199 | 199 | ||
218 | 200 | 200 | ||
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 | 11 | "desktop": "payui_payui.desktop" | 11 | "desktop": "payui_payui.desktop" |
224 | 12 | } | 12 | } |
225 | 13 | }, | 13 | }, |
227 | 14 | "version": "0.3.13", | 14 | "version": "0.3.15", |
228 | 15 | "maintainer": "Diego Sarmentero <diego.sarmentero@canonical.com>" | 15 | "maintainer": "Diego Sarmentero <diego.sarmentero@canonical.com>" |
229 | 16 | } | 16 | } |