Skip to content

Commit 944b55d

Browse files
authored
Bind Giropay to its project (#172)
1 parent b80a83e commit 944b55d

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ All notable changes to this project will be documented in this file.
77
### Removed
88
### Fixed
99

10+
## [0.72.3]
11+
### Fixed
12+
* core, ui: Bind Giropay to its project (#172)
13+
1014
## [0.72.2]
1115
### Changed
1216
* core: Explicitly enable buildConfig (#171)

core/src/main/java/io/snabble/sdk/payment/PaymentCredentials.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,22 @@ private static long parseValidTo(String format, String expirationDate) {
362362
}
363363

364364
/**
365-
* Encrypts and stores a paydirekt authorization token.
365+
* Encrypts and stores a Giropay authorization token.
366366
*/
367-
public static PaymentCredentials fromGiropay(GiropayAuthorizationData authorizationData, String customerAuthorizationURI) {
368-
if (customerAuthorizationURI == null) {
367+
@Nullable
368+
public static PaymentCredentials fromGiropay(
369+
GiropayAuthorizationData authorizationData,
370+
String customerAuthorizationURI,
371+
String projectId) {
372+
373+
if (customerAuthorizationURI == null || projectId == null) {
369374
return null;
370375
}
371376

372377
PaymentCredentials pc = new PaymentCredentials();
373378
pc.generateId();
374379
pc.type = Type.GIROPAY;
380+
pc.projectId = projectId;
375381

376382
List<X509Certificate> certificates = Snabble.getInstance().getPaymentCertificates();
377383
if (certificates.size() == 0) {

ui/src/main/java/io/snabble/sdk/ui/payment/GiropayInputView.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.UUID;
3030

3131
import io.snabble.sdk.Environment;
32+
import io.snabble.sdk.Project;
3233
import io.snabble.sdk.Snabble;
3334
import io.snabble.sdk.payment.PaymentCredentials;
3435
import io.snabble.sdk.payment.data.GiropayAuthorizationData;
@@ -77,6 +78,7 @@ public String getWebLink() {
7778
private static final String CANCELLED_URL = "snabble-paydirekt://cancelled";
7879
private static final String FAILURE_URL = "snabble-paydirekt://failure";
7980

81+
private String projectId;
8082
private boolean acceptedKeyguard;
8183
private WebView webView;
8284
private OkHttpClient okHttpClient;
@@ -183,6 +185,9 @@ public void onProgressChanged(WebView view, final int newProgress) {
183185
}
184186

185187
private void load() {
188+
@Nullable final Project project = Snabble.getInstance().getCheckedInProject().getValue();
189+
if (project != null) projectId = project.getId();
190+
186191
String url = Snabble.getInstance().getGiropayAuthUrl();
187192
if (url == null) {
188193
finishWithError();
@@ -289,7 +294,11 @@ public void error() {
289294
}
290295

291296
private void save() {
292-
final PaymentCredentials pc = PaymentCredentials.fromGiropay(authorizationData, authorizationResult.getAuthorizationLink());
297+
final PaymentCredentials pc = PaymentCredentials.fromGiropay(
298+
authorizationData,
299+
authorizationResult.getAuthorizationLink(),
300+
projectId
301+
);
293302

294303
if (pc == null) {
295304
Toast.makeText(getContext(), "Could not verify payment credentials", Toast.LENGTH_LONG)

0 commit comments

Comments
 (0)