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
=== modified file 'app/payui.qml'
--- app/payui.qml 2014-08-22 14:31:57 +0000
+++ app/payui.qml 2014-08-27 13:32:21 +0000
@@ -126,6 +126,12 @@
126126
127 onNoPreferredPaymentMethod: {127 onNoPreferredPaymentMethod: {
128 direct.hasPreferredPayment = false;128 direct.hasPreferredPayment = false;
129 var values = mainView.getLastPayment();
130 var backendid = values[0];
131 var paymentid = values[1];
132 if (backendid != "" && paymentid != "") {
133 direct.hasStoredPayment = true;
134 }
129 }135 }
130136
131 onPasswordValid: {137 onPasswordValid: {
@@ -201,6 +207,7 @@
201 function(tx) {207 function(tx) {
202 // Create the database if it doesn't already exist208 // Create the database if it doesn't already exist
203 tx.executeSql('CREATE TABLE IF NOT EXISTS PayUI(date TEXT)');209 tx.executeSql('CREATE TABLE IF NOT EXISTS PayUI(date TEXT)');
210 tx.executeSql('CREATE TABLE IF NOT EXISTS PayUIPayment(backendid TEXT, paymentid TEXT)');
204 var rs = tx.executeSql('SELECT * FROM PayUI');211 var rs = tx.executeSql('SELECT * FROM PayUI');
205 if (rs.rows.length == 0) {212 if (rs.rows.length == 0) {
206 // If it's empty, add initial date.213 // If it's empty, add initial date.
@@ -241,6 +248,36 @@
241 return valid;248 return valid;
242 }249 }
243250
251 function getLastPayment() {
252 var backendid = "";
253 var paymentid = "";
254 var db = LocalStorage.openDatabaseSync("PayUI", "1.0", "PayUI Credentials Date", 100);
255 db.transaction(
256 function(tx) {
257 var rs = tx.executeSql('SELECT * FROM PayUIPayment');
258 if (rs.rows.length > 0) {
259 backendid = rs.rows.item(0).backendid;
260 paymentid = rs.rows.item(0).paymentid;
261 }
262 }
263 )
264 return [backendid, paymentid];
265 }
266
267 function updatePayment(backendid, paymentid) {
268 var db = LocalStorage.openDatabaseSync("PayUI", "1.0", "PayUI Credentials Date", 100);
269 db.transaction(
270 function(tx) {
271 var rs = tx.executeSql('SELECT * FROM PayUIPayment');
272 if (rs.rows.length > 0) {
273 tx.executeSql('UPDATE PayUIPayment SET backendid = "' + backendid + '", paymentid = "' + paymentid + '"');
274 } else {
275 tx.executeSql('INSERT INTO PayUIPayment VALUES(?, ?)', [backendid, paymentid]);
276 }
277 }
278 )
279 }
280
244 ErrorDialog {281 ErrorDialog {
245 id: purchaseErrorDialog282 id: purchaseErrorDialog
246 title: i18n.tr("Purchase failed")283 title: i18n.tr("Purchase failed")
@@ -351,9 +388,14 @@
351 onBuy: {388 onBuy: {
352 if (direct.hasPayments && direct.hasPreferredPayment) {389 if (direct.hasPayments && direct.hasPreferredPayment) {
353 mainView.purchasing = true;390 mainView.purchasing = true;
354 purchase.buyItemWithPreferredPayment(email, password);391 purchase.buyItemWithPreferredPayment(email, password, mainView.recentLogin);
355 showLoading();392 showLoading();
356 } else {393 } else if (direct.hasStoredPayment) {
394 var values = mainView.getLastPayment();
395 var backendid = values[0];
396 var paymentid = values[1];
397 purchase.buyItem(email, password, paymentid, backendid, mainView.recentLogin);
398 }else {
357 mainView.state = "checkout";399 mainView.state = "checkout";
358 pageStack.push(checkout);400 pageStack.push(checkout);
359 }401 }
@@ -372,6 +414,10 @@
372 onBuy: {414 onBuy: {
373 mainView.purchasing = true;415 mainView.purchasing = true;
374 showLoading();416 showLoading();
417 if (!direct.hasPreferredPayment) {
418 mainView.updatePayment(backendId, paymentId);
419 }
420
375 var password = direct.password;421 var password = direct.password;
376 purchase.buyItem(email, password, paymentId, backendId, mainView.recentLogin);422 purchase.buyItem(email, password, paymentId, backendId, mainView.recentLogin);
377 }423 }
378424
=== modified file 'app/ui/DirectPurchase.qml'
--- app/ui/DirectPurchase.qml 2014-08-22 14:31:57 +0000
+++ app/ui/DirectPurchase.qml 2014-08-27 13:32:21 +0000
@@ -32,6 +32,7 @@
32 property alias price: priceItemLabel.text32 property alias price: priceItemLabel.text
33 property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 033 property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
34 property bool hasPreferredPayment: true34 property bool hasPreferredPayment: true
35 property bool hasStoredPayment: false
35 property bool beforeTimeout: false36 property bool beforeTimeout: false
3637
37 function launchPurchase() {38 function launchPurchase() {
@@ -245,7 +246,7 @@
245 Button {246 Button {
246 id: buyButton247 id: buyButton
247 objectName: "buyButtonDirect"248 objectName: "buyButtonDirect"
248 text: pageDirectPayment.hasPreferredPayment ? i18n.tr("Buy Now") : i18n.tr("Confirm")249 text: (pageDirectPayment.hasPreferredPayment || pageDirectPayment.hasStoredPayment) ? i18n.tr("Buy Now") : i18n.tr("Confirm")
249 color: UbuntuColors.orange250 color: UbuntuColors.orange
250 width: parent.buttonsWidth251 width: parent.buttonsWidth
251 enabled: (passwordField.text.length > 7 || pageDirectPayment.beforeTimeout) ? true : false252 enabled: (passwordField.text.length > 7 || pageDirectPayment.beforeTimeout) ? true : false
252253
=== modified file 'backend/modules/payui/network.cpp'
--- backend/modules/payui/network.cpp 2014-08-20 20:09:06 +0000
+++ backend/modules/payui/network.cpp 2014-08-27 13:32:21 +0000
@@ -249,13 +249,17 @@
249}249}
250250
251void Network::buyItemWithPreferredPaymentType(const QString& email, const QString& password,251void Network::buyItemWithPreferredPaymentType(const QString& email, const QString& password,
252 const QString& appid, const QString& itemid)252 const QString& appid, const QString& itemid, bool recentLogin)
253{253{
254 m_selectedPaymentId = m_preferred->paymentId();254 m_selectedPaymentId = m_preferred->paymentId();
255 m_selectedBackendId = m_preferred->backendId();255 m_selectedBackendId = m_preferred->backendId();
256 m_selectedAppId = appid;256 m_selectedAppId = appid;
257 m_selectedItemId = itemid;257 m_selectedItemId = itemid;
258 updateCredentials(email, password);258 if (recentLogin) {
259 purchaseProcess();
260 } else {
261 updateCredentials(email, password);
262 }
259}263}
260264
261void Network::buyItem(const QString& email, const QString& password,265void Network::buyItem(const QString& email, const QString& password,
262266
=== modified file 'backend/modules/payui/network.h'
--- backend/modules/payui/network.h 2014-08-20 20:09:06 +0000
+++ backend/modules/payui/network.h 2014-08-27 13:32:21 +0000
@@ -35,7 +35,7 @@
35namespace UbuntuPurchase {35namespace UbuntuPurchase {
3636
37constexpr static const char* PAY_BASE_URL_ENVVAR{"PAY_BASE_URL"};37constexpr static const char* PAY_BASE_URL_ENVVAR{"PAY_BASE_URL"};
38constexpr static const char* PAY_BASE_URL{"https://sc.ubuntu.com"};38constexpr static const char* PAY_BASE_URL{"https://software-center.ubuntu.com"};
39constexpr static const char* PAY_API_ROOT{"/api/2.0/click"};39constexpr static const char* PAY_API_ROOT{"/api/2.0/click"};
4040
41class RequestObject : public QObject41class RequestObject : public QObject
@@ -62,7 +62,8 @@
62 const QString& itemid, const QString& paymentId, const QString& backendId,62 const QString& itemid, const QString& paymentId, const QString& backendId,
63 bool recentLogin);63 bool recentLogin);
64 void buyItemWithPreferredPaymentType(const QString& email, const QString& password,64 void buyItemWithPreferredPaymentType(const QString& email, const QString& password,
65 const QString& appid, const QString& itemid);65 const QString& appid, const QString& itemid,
66 bool recentLogin);
66 void getItemInfo(const QString &packagename);67 void getItemInfo(const QString &packagename);
67 void checkPassword(const QString& email, const QString& password);68 void checkPassword(const QString& email, const QString& password);
68 void getCredentials();69 void getCredentials();
6970
=== modified file 'backend/modules/payui/purchase.cpp'
--- backend/modules/payui/purchase.cpp 2014-08-20 20:09:06 +0000
+++ backend/modules/payui/purchase.cpp 2014-08-27 13:32:21 +0000
@@ -101,9 +101,9 @@
101 m_network.checkPassword(email, password);101 m_network.checkPassword(email, password);
102}102}
103103
104void Purchase::buyItemWithPreferredPayment(QString email, QString password)104void Purchase::buyItemWithPreferredPayment(QString email, QString password, bool recentLogin)
105{105{
106 m_network.buyItemWithPreferredPaymentType(email, password, m_appid, m_itemid);106 m_network.buyItemWithPreferredPaymentType(email, password, m_appid, m_itemid, recentLogin);
107}107}
108108
109void Purchase::buyItem(QString email, QString password, QString paymentId, QString backendId, bool recentLogin)109void Purchase::buyItem(QString email, QString password, QString paymentId, QString backendId, bool recentLogin)
110110
=== modified file 'backend/modules/payui/purchase.h'
--- backend/modules/payui/purchase.h 2014-08-20 20:09:06 +0000
+++ backend/modules/payui/purchase.h 2014-08-27 13:32:21 +0000
@@ -16,7 +16,7 @@
1616
17 Q_INVOKABLE void getItemDetails(QString packagename, QString itemid);17 Q_INVOKABLE void getItemDetails(QString packagename, QString itemid);
18 Q_INVOKABLE void getPaymentTypes();18 Q_INVOKABLE void getPaymentTypes();
19 Q_INVOKABLE void buyItemWithPreferredPayment(QString email, QString password);19 Q_INVOKABLE void buyItemWithPreferredPayment(QString email, QString password, bool recentLogin);
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);
21 Q_INVOKABLE void checkCredentials();21 Q_INVOKABLE void checkCredentials();
22 Q_INVOKABLE QString getAddPaymentUrl();22 Q_INVOKABLE QString getAddPaymentUrl();
2323
=== modified file 'backend/tests/test_network.cpp'
--- backend/tests/test_network.cpp 2014-08-20 19:30:32 +0000
+++ backend/tests/test_network.cpp 2014-08-27 13:32:21 +0000
@@ -167,7 +167,7 @@
167 network.requestPaymentTypes();167 network.requestPaymentTypes();
168 QTRY_COMPARE(spy.count(), 1);168 QTRY_COMPARE(spy.count(), 1);
169 QSignalSpy spy2(&network, SIGNAL(buyItemSucceeded()));169 QSignalSpy spy2(&network, SIGNAL(buyItemSucceeded()));
170 network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid");170 network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid", false);
171 QTRY_COMPARE(spy2.count(), 1);171 QTRY_COMPARE(spy2.count(), 1);
172}172}
173173
@@ -180,7 +180,7 @@
180 QTRY_COMPARE(spy.count(), 1);180 QTRY_COMPARE(spy.count(), 1);
181 setenv(PAY_BASE_URL_ENVVAR, "http://localhost:8000/fail/", 1);181 setenv(PAY_BASE_URL_ENVVAR, "http://localhost:8000/fail/", 1);
182 QSignalSpy spy2(&network, SIGNAL(buyItemFailed()));182 QSignalSpy spy2(&network, SIGNAL(buyItemFailed()));
183 network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid");183 network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid", false);
184 QTRY_COMPARE(spy2.count(), 1);184 QTRY_COMPARE(spy2.count(), 1);
185}185}
186186
@@ -193,7 +193,7 @@
193 QTRY_COMPARE(spy.count(), 1);193 QTRY_COMPARE(spy.count(), 1);
194 setenv(PAY_BASE_URL_ENVVAR, "http://localhost:8000/interaction/", 1);194 setenv(PAY_BASE_URL_ENVVAR, "http://localhost:8000/interaction/", 1);
195 QSignalSpy spy2(&network, SIGNAL(buyInteractionRequired(QString)));195 QSignalSpy spy2(&network, SIGNAL(buyInteractionRequired(QString)));
196 network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid");196 network.buyItemWithPreferredPaymentType("email", "password", "appid", "itemid", false);
197 QTRY_COMPARE(spy2.count(), 1);197 QTRY_COMPARE(spy2.count(), 1);
198}198}
199199
200200
=== modified file 'manifest.json'
--- manifest.json 2014-08-22 14:31:57 +0000
+++ manifest.json 2014-08-27 13:32:21 +0000
@@ -11,6 +11,6 @@
11 "desktop": "payui_payui.desktop"11 "desktop": "payui_payui.desktop"
12 }12 }
13 },13 },
14 "version": "0.3.13",14 "version": "0.3.15",
15 "maintainer": "Diego Sarmentero <diego.sarmentero@canonical.com>"15 "maintainer": "Diego Sarmentero <diego.sarmentero@canonical.com>"
16}16}

Subscribers

People subscribed via source and target branches

to all changes: