Skip to content

Commit f546d82

Browse files
committed
removed receipt_available checkout state, removed receipt ui components, changed ReceiptInfo.getProject to getProjectId
1 parent a31bbdc commit f546d82

File tree

14 files changed

+33
-423
lines changed

14 files changed

+33
-423
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.15.0]
5+
6+
### Breaking Changes
7+
- Removed RECEIPT_AVAILABLE checkout state
8+
- Changed ReceiptInfo.getProject to return a string instead of the resolved project
9+
- Removed receipt ui components
10+
411
## [0.14.18]
512

613
### Fixed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ allprojects {
2323
}
2424

2525
project.ext {
26-
sdkVersion='0.14.18'
26+
sdkVersion='0.15.0'
2727
versionCode=1
2828

2929
compileSdkVersion=28

core/src/main/java/io/snabble/sdk/Checkout.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ public enum State {
4343
* The payment was approved. We are done.
4444
*/
4545
PAYMENT_APPROVED,
46-
/**
47-
* After payment approval, when the receipt is available.
48-
*/
49-
RECEIPT_AVAILABLE,
5046
/**
5147
* The payment was denied by the payment provider.
5248
*/
@@ -125,7 +121,6 @@ public void cancel() {
125121
cancelOutstandingCalls();
126122

127123
if (state != State.PAYMENT_APPROVED
128-
&& state != State.RECEIPT_AVAILABLE
129124
&& state != State.DENIED_BY_PAYMENT_PROVIDER
130125
&& state != State.DENIED_BY_SUPERVISOR
131126
&& checkoutProcess != null) {
@@ -147,7 +142,6 @@ public void cancel() {
147142
*/
148143
public void cancelSilently() {
149144
if (state != State.PAYMENT_APPROVED
150-
&& state != State.RECEIPT_AVAILABLE
151145
&& state != State.DENIED_BY_PAYMENT_PROVIDER
152146
&& state != State.DENIED_BY_SUPERVISOR
153147
&& checkoutProcess != null) {
@@ -377,13 +371,7 @@ private boolean handleProcessResponse() {
377371

378372
if (checkoutProcess.paymentState == CheckoutApi.PaymentState.SUCCESSFUL) {
379373
approve();
380-
381-
if (checkoutProcess.getReceiptLink() != null) {
382-
notifyStateChanged(State.RECEIPT_AVAILABLE);
383-
return true;
384-
} else {
385-
return false;
386-
}
374+
return true;
387375
} else if (checkoutProcess.paymentState == CheckoutApi.PaymentState.PENDING) {
388376
if (checkoutProcess.supervisorApproval != null && !checkoutProcess.supervisorApproval) {
389377
Logger.d("Payment denied by supervisor");

core/src/main/java/io/snabble/sdk/ReceiptInfo.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
public class ReceiptInfo {
66
private String id;
7-
private Project project;
7+
private String projectId;
88
private Date date;
99
private String pdfUrl;
1010
private String shopName;
1111
private String price;
1212

13-
public ReceiptInfo(String id, Project project, Date date, String pdfUrl, String shopName, String price) {
13+
public ReceiptInfo(String id, String projectId, Date date, String pdfUrl, String shopName, String price) {
1414
this.id = id;
15-
this.project = project;
15+
this.projectId = projectId;
1616
this.date = date;
1717
this.pdfUrl = pdfUrl;
1818
this.shopName = shopName;
@@ -23,8 +23,8 @@ public String getId() {
2323
return id;
2424
}
2525

26-
public Project getProject() {
27-
return project;
26+
public String getProjectId() {
27+
return projectId;
2828
}
2929

3030
public Date getDate() {

core/src/main/java/io/snabble/sdk/Receipts.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void cancelDownload() {
7070
*/
7171
public void download(final ReceiptInfo receiptInfo,
7272
final ReceiptDownloadCallback callback) {
73-
if (receiptInfo.getPdfUrl() == null || receiptInfo.getProject() == null) {
73+
if (receiptInfo.getPdfUrl() == null) {
7474
callback.failure();
7575
return;
7676
}
@@ -94,7 +94,22 @@ public void download(final ReceiptInfo receiptInfo,
9494
return;
9595
}
9696

97-
call = receiptInfo.getProject().getOkHttpClient().newCall(request);
97+
Project project = null;
98+
99+
Snabble snabble = Snabble.getInstance();
100+
for (Project p : snabble.getProjects()) {
101+
if (p.getId().equals(receiptInfo.getProjectId())) {
102+
project = p;
103+
}
104+
break;
105+
}
106+
107+
if (project == null) {
108+
callback.failure();
109+
return;
110+
}
111+
112+
call = project.getOkHttpClient().newCall(request);
98113
call.enqueue(new Callback() {
99114
@Override
100115
public void onResponse(Call call, Response response) throws IOException {

core/src/main/java/io/snabble/sdk/ReceiptsApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void success(ApiReceipt apiReceipt) {
8686
try {
8787
ReceiptInfo receiptInfo = new ReceiptInfo(
8888
apiOrder.id,
89-
project,
89+
apiOrder.project,
9090
simpleDateFormat.parse(apiOrder.date),
9191
snabble.absoluteUrl(apiLink.href),
9292
apiOrder.shopName,

sample/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<activity android:name=".ProductSearchActivity" />
2727
<activity android:name=".CheckoutActivity" />
2828
<activity android:name=".ShoppingCartActivity" />
29-
<activity android:name=".ReceiptListActivity" />
3029
<activity android:name=".SEPACardInputActivity" />
3130
<activity android:name=".PaymentCredentialsListActivity" />
3231
<activity android:name=".PaymentCredentialsSelectActivity" />

sample/src/main/java/io/snabble/testapp/HomeFragment.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package io.snabble.testapp;
22

3-
import android.content.Intent;
43
import android.os.Bundle;
54
import androidx.annotation.NonNull;
65
import androidx.annotation.Nullable;
76
import androidx.fragment.app.Fragment;
87
import io.snabble.sdk.Project;
98
import io.snabble.sdk.Snabble;
109
import io.snabble.sdk.ui.SnabbleUI;
11-
import io.snabble.sdk.ui.receipts.ReceiptListView;
1210

1311
import android.view.LayoutInflater;
1412
import android.view.View;
@@ -45,14 +43,6 @@ public void onClick(View v) {
4543
}
4644
});
4745

48-
v.findViewById(R.id.receipt_list).setOnClickListener(new View.OnClickListener() {
49-
@Override
50-
public void onClick(View v) {
51-
Intent intent = new Intent(requireActivity(), ReceiptListActivity.class);
52-
startActivity(intent);
53-
}
54-
});
55-
5646
v.findViewById(R.id.update_db).setOnClickListener(new View.OnClickListener() {
5747
@Override
5848
public void onClick(View v) {

sample/src/main/java/io/snabble/testapp/ReceiptListActivity.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

sample/src/main/res/layout/fragment_home.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@
2525
android:padding="8dp"
2626
android:id="@+id/scanner"
2727
android:text="Scanner" />
28-
<Button
29-
android:layout_width="wrap_content"
30-
android:layout_height="wrap_content"
31-
android:padding="8dp"
32-
android:id="@+id/receipt_list"
33-
android:text="Receipts" />
3428
<Button
3529
android:layout_width="wrap_content"
3630
android:layout_height="wrap_content"

0 commit comments

Comments
 (0)