Merge lp:~diegosarmentero/pay-ui/handle-payment-issues into lp:pay-ui

Proposed by Diego Sarmentero
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 24
Merged at revision: 23
Proposed branch: lp:~diegosarmentero/pay-ui/handle-payment-issues
Merge into: lp:pay-ui
Diff against target: 216 lines (+33/-15)
10 files modified
app/payui.qml (+8/-4)
app/ui/DirectPurchase.qml (+2/-1)
backend/modules/payui/network.cpp (+12/-5)
backend/modules/payui/network.h (+1/-0)
backend/modules/payui/purchase.cpp (+2/-0)
backend/modules/payui/purchase.h (+1/-0)
backend/tests/mock_click_server.py (+2/-2)
backend/tests/test_network.cpp (+3/-1)
manifest.json (+1/-1)
payui_payui.desktop.in.in (+1/-1)
To merge this branch: bzr merge lp:~diegosarmentero/pay-ui/handle-payment-issues
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alejandro J. Cura (community) Approve
Review via email: mp+231619@code.launchpad.net

Commit message

- Build properly redirect to url.
- Handle no preferred payment method situations.

To post a comment you must log in.
24. By Diego Sarmentero

change signal name for no preferred payment methods

Revision history for this message
Alejandro J. Cura (alecu) wrote :

Seems to work now.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

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-20 13:24:39 +0000
3+++ app/payui.qml 2014-08-20 20:09:34 +0000
4@@ -57,7 +57,7 @@
5 property bool purchasing: false
6 property bool recentLogin: false
7
8- backgroundColor: "white"
9+ backgroundColor: "transparent"
10
11 onStateChanged: {
12 if (mainView.state == "direct") {
13@@ -127,6 +127,10 @@
14 hideLoading();
15 }
16
17+ onNoPreferredPaymentMethod: {
18+ direct.hasPreferredPayment = false;
19+ }
20+
21 onPasswordValid: {
22 hideLoading();
23 mainView.state = "checkout";
24@@ -343,13 +347,13 @@
25 }
26
27 onBuy: {
28- if (direct.hasPayments) {
29+ if (direct.hasPayments && direct.hasPreferredPayment) {
30 mainView.purchasing = true;
31 purchase.buyItemWithPreferredPayment(email, password);
32 showLoading();
33 } else {
34- mainView.state = "payment";
35- pageStack.push(payment);
36+ mainView.state = "checkout";
37+ pageStack.push(checkout);
38 }
39 }
40 }
41
42=== modified file 'app/ui/DirectPurchase.qml'
43--- app/ui/DirectPurchase.qml 2014-08-13 19:54:12 +0000
44+++ app/ui/DirectPurchase.qml 2014-08-20 20:09:34 +0000
45@@ -28,6 +28,7 @@
46 property bool hasPayments: false
47 property alias password: passwordField.text
48 property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
49+ property bool hasPreferredPayment: true
50
51 function launchPurchase() {
52 errorPasswordLabel.visible = false;
53@@ -174,7 +175,7 @@
54 Button {
55 id: buyButton
56 objectName: "buyButtonDirect"
57- text: i18n.tr("Buy Now")
58+ text: pageDirectPayment.hasPreferredPayment ? i18n.tr("Buy Now") : i18n.tr("Confirm")
59 color: UbuntuColors.orange
60 width: parent.buttonsWidth
61 enabled: passwordField.text.length > 7 ? true : false
62
63=== modified file 'backend/modules/payui/network.cpp'
64--- backend/modules/payui/network.cpp 2014-08-05 14:55:51 +0000
65+++ backend/modules/payui/network.cpp 2014-08-20 20:09:34 +0000
66@@ -52,7 +52,8 @@
67 Network::Network(QObject *parent) :
68 QObject(parent),
69 m_nam(this),
70- m_service(this)
71+ m_service(this),
72+ m_preferred(nullptr)
73 {
74 connect(&m_nam, SIGNAL(finished(QNetworkReply*)),
75 this, SLOT(onReply(QNetworkReply*)));
76@@ -146,7 +147,7 @@
77 for (int j = 0; j < choices.size(); j++) {
78 QJsonObject choice = choices.at(j).toObject();
79 QString name = choice.value("description").toString();
80- QString paymentId = choice.value("id").toString();
81+ QString paymentId = QString::number(choice.value("id").toInt());
82 bool requiresInteracion = choice.value("requires_interaction").toBool();
83 bool preferred = choice.value("preferred").toBool() && preferredBackend;
84 PayInfo* pay = new PayInfo();
85@@ -158,6 +159,9 @@
86 }
87 }
88 Q_EMIT paymentTypesObtained(listPays);
89+ if (m_preferred == nullptr) {
90+ Q_EMIT noPreferredPaymentMethod();
91+ }
92 } else if (state->operation.contains(BUY_ITEM) && document.isObject()) {
93 qDebug() << "Reply state:" << BUY_ITEM;
94 QJsonObject object = document.object();
95@@ -167,9 +171,12 @@
96 qDebug() << "BUY STATE: complete";
97 Q_EMIT buyItemSucceeded();
98 } else if (state == BUY_IN_PROGRESS) {
99+ QString baseUrl = getAPIUrl(PAY_BASE_URL_ENVVAR, QString(PAY_BASE_URL)) + object.value("redirect_to").toString();
100 qDebug() << "BUY STATE: in progress";
101- QString redirect_to = object.value("redirect_to").toString();
102- Q_EMIT buyInteractionRequired(redirect_to);
103+ QString sign = m_token.signUrl(baseUrl, "GET", true);
104+ QUrl redirectTo(baseUrl);
105+ redirectTo.setQuery(sign);
106+ Q_EMIT buyInteractionRequired(redirectTo.toString());
107 } else {
108 qDebug() << "BUY STATE: failed";
109 Q_EMIT buyItemFailed();
110@@ -275,7 +282,7 @@
111 serializer.insert("device_id", getDeviceId());
112 serializer.insert("name", m_selectedAppId);
113 serializer.insert("backend_id", m_selectedBackendId);
114- serializer.insert("method", m_selectedPaymentId);
115+ serializer.insert("method_id", m_selectedPaymentId);
116 QJsonDocument doc(serializer);
117
118 QByteArray content = doc.toJson();
119
120=== modified file 'backend/modules/payui/network.h'
121--- backend/modules/payui/network.h 2014-07-29 17:32:50 +0000
122+++ backend/modules/payui/network.h 2014-08-20 20:09:34 +0000
123@@ -82,6 +82,7 @@
124 void credentialsFound();
125 void credentialsUpdated();
126 void passwordValid();
127+ void noPreferredPaymentMethod();
128
129 private Q_SLOTS:
130 void onReply(QNetworkReply*);
131
132=== modified file 'backend/modules/payui/purchase.cpp'
133--- backend/modules/payui/purchase.cpp 2014-07-29 17:32:50 +0000
134+++ backend/modules/payui/purchase.cpp 2014-08-20 20:09:34 +0000
135@@ -32,6 +32,8 @@
136 this, &Purchase::credentialsFound);
137 connect(&m_network, &Network::passwordValid,
138 this, &Purchase::passwordValid);
139+ connect(&m_network, &Network::noPreferredPaymentMethod,
140+ this, &Purchase::noPreferredPaymentMethod);
141
142 QCoreApplication* instance = QCoreApplication::instance();
143 Logger::setupLogging();
144
145=== modified file 'backend/modules/payui/purchase.h'
146--- backend/modules/payui/purchase.h 2014-07-29 17:32:50 +0000
147+++ backend/modules/payui/purchase.h 2014-08-20 20:09:34 +0000
148@@ -36,6 +36,7 @@
149 void credentialsNotFound();
150 void credentialsFound();
151 void passwordValid();
152+ void noPreferredPaymentMethod();
153
154 private:
155 Network m_network;
156
157=== modified file 'backend/tests/mock_click_server.py'
158--- backend/tests/mock_click_server.py 2014-08-01 14:21:55 +0000
159+++ backend/tests/mock_click_server.py 2014-08-20 20:09:34 +0000
160@@ -76,7 +76,7 @@
161 "state": state,
162 }
163 if interaction:
164- response["redirect_to"] = "http://redirect.url"
165+ response["redirect_to"] = "redirect.url"
166 if fail:
167 response = {}
168 self.send_response(200)
169@@ -162,4 +162,4 @@
170 t.start()
171
172
173-run_mocked_settings()
174\ No newline at end of file
175+run_mocked_settings()
176
177=== modified file 'backend/tests/test_network.cpp'
178--- backend/tests/test_network.cpp 2014-08-01 14:21:55 +0000
179+++ backend/tests/test_network.cpp 2014-08-20 20:09:34 +0000
180@@ -145,7 +145,9 @@
181 network.buyItem("email", "password", "appid", "itemid", "paymentid", "backendid", false);
182 QTRY_COMPARE(spy.count(), 1);
183 QList<QVariant> arguments = spy.takeFirst();
184- QVERIFY(arguments.at(0).toString() == "http://redirect.url");
185+ QString url(arguments.at(0).toString());
186+ QString expected("http://localhost:8000/interaction/redirect.url");
187+ QVERIFY(url.startsWith(expected));
188 }
189
190 void TestNetwork::testNetworkBuyItemFail()
191
192=== modified file 'manifest.json'
193--- manifest.json 2014-08-20 13:24:05 +0000
194+++ manifest.json 2014-08-20 20:09:34 +0000
195@@ -11,6 +11,6 @@
196 "desktop": "payui_payui.desktop"
197 }
198 },
199- "version": "0.3.11",
200+ "version": "0.3.12",
201 "maintainer": "Diego Sarmentero <diego.sarmentero@canonical.com>"
202 }
203\ No newline at end of file
204
205=== modified file 'payui_payui.desktop.in.in'
206--- payui_payui.desktop.in.in 2014-08-13 12:59:48 +0000
207+++ payui_payui.desktop.in.in 2014-08-20 20:09:34 +0000
208@@ -1,7 +1,7 @@
209 [Desktop Entry]
210 _Name=Pay UI
211 _Comment=The application for completing a purchase.
212-Exec=@EXEC@ %u
213+Exec=@EXEC@ --transparent %u
214 Icon=graphics/credit_card@8.png
215 Terminal=false
216 Type=Application

Subscribers

People subscribed via source and target branches

to all changes: