@capawesome/capacitor-square-mobile-payments 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapawesomeCapacitorSquareMobilePayments.podspec +17 -0
- package/Package.swift +30 -0
- package/README.md +1183 -0
- package/android/build.gradle +63 -0
- package/android/src/main/AndroidManifest.xml +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/SquareMobilePayments.java +774 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/SquareMobilePaymentsPlugin.java +460 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/CustomExceptions.java +41 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/AvailableCardInputMethodsDidChangeEvent.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/PaymentDidCancelEvent.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/PaymentDidFailEvent.java +34 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/PaymentDidFinishEvent.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/ReaderDidChangeEvent.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/ReaderPairingDidFailEvent.java +28 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/ReaderWasAddedEvent.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/ReaderWasRemovedEvent.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/AuthorizeOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/ForgetReaderOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/InitializeOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/Money.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/PaymentParameters.java +126 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/PromptParameters.java +47 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/RetryConnectionOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/StartPaymentOptions.java +39 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/Card.java +51 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/CardPaymentDetails.java +30 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/GetAvailableCardInputMethodsResult.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/GetReadersResult.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/GetSettingsResult.java +28 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/IsAuthorizedResult.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/IsPairingInProgressResult.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/MoneyResult.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/Payment.java +87 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/ReaderInfo.java +82 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/UnavailableReasonInfo.java +30 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/interfaces/EmptyCallback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/interfaces/NonEmptyCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +2999 -0
- package/dist/esm/definitions.d.ts +1468 -0
- package/dist/esm/definitions.js +519 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +21 -0
- package/dist/esm/web.js +55 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +588 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +591 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Classes/Options/AuthorizeOptions.swift +17 -0
- package/ios/Plugin/Classes/Options/ForgetReaderOptions.swift +17 -0
- package/ios/Plugin/Classes/Options/InitializeOptions.swift +17 -0
- package/ios/Plugin/Classes/Options/Money.swift +12 -0
- package/ios/Plugin/Classes/Options/PaymentParameters.swift +49 -0
- package/ios/Plugin/Classes/Options/PromptParameters.swift +17 -0
- package/ios/Plugin/Classes/Options/RetryConnectionOptions.swift +17 -0
- package/ios/Plugin/Classes/Options/StartPaymentOptions.swift +19 -0
- package/ios/Plugin/Classes/Results/Card.swift +34 -0
- package/ios/Plugin/Classes/Results/CardPaymentDetails.swift +34 -0
- package/ios/Plugin/Classes/Results/GetAvailableCardInputMethodsResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetReadersResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetSettingsResult.swift +19 -0
- package/ios/Plugin/Classes/Results/IsAuthorizedResult.swift +16 -0
- package/ios/Plugin/Classes/Results/IsPairingInProgressResult.swift +16 -0
- package/ios/Plugin/Classes/Results/MoneyResult.swift +19 -0
- package/ios/Plugin/Classes/Results/Payment.swift +58 -0
- package/ios/Plugin/Classes/Results/ReaderInfo.swift +46 -0
- package/ios/Plugin/Classes/Results/UnavailableReasonInfo.swift +19 -0
- package/ios/Plugin/Enums/CustomError.swift +81 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +6 -0
- package/ios/Plugin/SquareMobilePayments.swift +632 -0
- package/ios/Plugin/SquareMobilePaymentsHelper.swift +212 -0
- package/ios/Plugin/SquareMobilePaymentsPlugin.swift +347 -0
- package/package.json +93 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.events;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results.ReaderInfo;
|
|
6
|
+
|
|
7
|
+
public class ReaderWasAddedEvent {
|
|
8
|
+
|
|
9
|
+
@NonNull
|
|
10
|
+
private final ReaderInfo reader;
|
|
11
|
+
|
|
12
|
+
public ReaderWasAddedEvent(@NonNull ReaderInfo reader) {
|
|
13
|
+
this.reader = reader;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@NonNull
|
|
17
|
+
public JSObject toJSObject() {
|
|
18
|
+
JSObject result = new JSObject();
|
|
19
|
+
result.put("reader", reader.toJSObject());
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.events;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results.ReaderInfo;
|
|
6
|
+
|
|
7
|
+
public class ReaderWasRemovedEvent {
|
|
8
|
+
|
|
9
|
+
@NonNull
|
|
10
|
+
private final ReaderInfo reader;
|
|
11
|
+
|
|
12
|
+
public ReaderWasRemovedEvent(@NonNull ReaderInfo reader) {
|
|
13
|
+
this.reader = reader;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@NonNull
|
|
17
|
+
public JSObject toJSObject() {
|
|
18
|
+
JSObject result = new JSObject();
|
|
19
|
+
result.put("reader", reader.toJSObject());
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.PluginCall;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.CustomExceptions;
|
|
6
|
+
|
|
7
|
+
public class AuthorizeOptions {
|
|
8
|
+
|
|
9
|
+
@NonNull
|
|
10
|
+
private final String accessToken;
|
|
11
|
+
|
|
12
|
+
public AuthorizeOptions(@NonNull PluginCall call) throws Exception {
|
|
13
|
+
this.accessToken = AuthorizeOptions.getAccessTokenFromCall(call);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@NonNull
|
|
17
|
+
public String getAccessToken() {
|
|
18
|
+
return accessToken;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@NonNull
|
|
22
|
+
private static String getAccessTokenFromCall(@NonNull PluginCall call) throws Exception {
|
|
23
|
+
String accessToken = call.getString("accessToken");
|
|
24
|
+
if (accessToken == null) {
|
|
25
|
+
throw CustomExceptions.ACCESS_TOKEN_MISSING;
|
|
26
|
+
}
|
|
27
|
+
return accessToken;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.PluginCall;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.CustomExceptions;
|
|
6
|
+
|
|
7
|
+
public class ForgetReaderOptions {
|
|
8
|
+
|
|
9
|
+
@NonNull
|
|
10
|
+
private final String serialNumber;
|
|
11
|
+
|
|
12
|
+
public ForgetReaderOptions(@NonNull PluginCall call) throws Exception {
|
|
13
|
+
this.serialNumber = ForgetReaderOptions.getSerialNumberFromCall(call);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@NonNull
|
|
17
|
+
public String getSerialNumber() {
|
|
18
|
+
return serialNumber;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@NonNull
|
|
22
|
+
private static String getSerialNumberFromCall(@NonNull PluginCall call) throws Exception {
|
|
23
|
+
String serialNumber = call.getString("serialNumber");
|
|
24
|
+
if (serialNumber == null) {
|
|
25
|
+
throw CustomExceptions.SERIAL_NUMBER_MISSING;
|
|
26
|
+
}
|
|
27
|
+
return serialNumber;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.PluginCall;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.CustomExceptions;
|
|
6
|
+
|
|
7
|
+
public class InitializeOptions {
|
|
8
|
+
|
|
9
|
+
@NonNull
|
|
10
|
+
private final String locationId;
|
|
11
|
+
|
|
12
|
+
public InitializeOptions(@NonNull PluginCall call) throws Exception {
|
|
13
|
+
this.locationId = InitializeOptions.getLocationIdFromCall(call);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@NonNull
|
|
17
|
+
public String getLocationId() {
|
|
18
|
+
return locationId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@NonNull
|
|
22
|
+
private static String getLocationIdFromCall(@NonNull PluginCall call) throws Exception {
|
|
23
|
+
String locationId = call.getString("locationId");
|
|
24
|
+
if (locationId == null) {
|
|
25
|
+
throw CustomExceptions.LOCATION_ID_MISSING;
|
|
26
|
+
}
|
|
27
|
+
return locationId;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
|
|
6
|
+
public class Money {
|
|
7
|
+
|
|
8
|
+
private final int amount;
|
|
9
|
+
|
|
10
|
+
@NonNull
|
|
11
|
+
private final String currency;
|
|
12
|
+
|
|
13
|
+
public Money(@NonNull JSObject obj) {
|
|
14
|
+
Integer amountValue = obj.getInteger("amount");
|
|
15
|
+
this.amount = amountValue != null ? amountValue : 0;
|
|
16
|
+
|
|
17
|
+
String currencyValue = obj.getString("currency");
|
|
18
|
+
this.currency = currencyValue != null ? currencyValue : "USD";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public int getAmount() {
|
|
22
|
+
return amount;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@NonNull
|
|
26
|
+
public String getCurrency() {
|
|
27
|
+
return currency;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.CustomExceptions;
|
|
7
|
+
|
|
8
|
+
public class PaymentParameters {
|
|
9
|
+
|
|
10
|
+
@NonNull
|
|
11
|
+
private final Money amountMoney;
|
|
12
|
+
|
|
13
|
+
@NonNull
|
|
14
|
+
private final String paymentAttemptId;
|
|
15
|
+
|
|
16
|
+
@Nullable
|
|
17
|
+
private final String processingMode;
|
|
18
|
+
|
|
19
|
+
@Nullable
|
|
20
|
+
private final String referenceId;
|
|
21
|
+
|
|
22
|
+
@Nullable
|
|
23
|
+
private final String note;
|
|
24
|
+
|
|
25
|
+
@Nullable
|
|
26
|
+
private final String orderId;
|
|
27
|
+
|
|
28
|
+
@Nullable
|
|
29
|
+
private final Money tipMoney;
|
|
30
|
+
|
|
31
|
+
@Nullable
|
|
32
|
+
private final Money applicationFee;
|
|
33
|
+
|
|
34
|
+
@Nullable
|
|
35
|
+
private final Boolean autocomplete;
|
|
36
|
+
|
|
37
|
+
@Nullable
|
|
38
|
+
private final String delayDuration;
|
|
39
|
+
|
|
40
|
+
@Nullable
|
|
41
|
+
private final String delayAction;
|
|
42
|
+
|
|
43
|
+
public PaymentParameters(@NonNull JSObject obj) throws Exception {
|
|
44
|
+
JSObject amountMoneyObj = obj.getJSObject("amountMoney");
|
|
45
|
+
if (amountMoneyObj == null) {
|
|
46
|
+
throw CustomExceptions.AMOUNT_MONEY_MISSING;
|
|
47
|
+
}
|
|
48
|
+
this.amountMoney = new Money(amountMoneyObj);
|
|
49
|
+
|
|
50
|
+
String paymentAttemptId = obj.getString("paymentAttemptId");
|
|
51
|
+
if (paymentAttemptId == null) {
|
|
52
|
+
throw CustomExceptions.PAYMENT_ATTEMPT_ID_MISSING;
|
|
53
|
+
}
|
|
54
|
+
this.paymentAttemptId = paymentAttemptId;
|
|
55
|
+
|
|
56
|
+
this.processingMode = obj.getString("processingMode");
|
|
57
|
+
this.referenceId = obj.getString("referenceId");
|
|
58
|
+
this.note = obj.getString("note");
|
|
59
|
+
this.orderId = obj.getString("orderId");
|
|
60
|
+
|
|
61
|
+
JSObject tipMoneyObj = obj.getJSObject("tipMoney");
|
|
62
|
+
this.tipMoney = tipMoneyObj != null ? new Money(tipMoneyObj) : null;
|
|
63
|
+
|
|
64
|
+
JSObject applicationFeeObj = obj.getJSObject("applicationFee");
|
|
65
|
+
this.applicationFee = applicationFeeObj != null ? new Money(applicationFeeObj) : null;
|
|
66
|
+
|
|
67
|
+
this.autocomplete = obj.getBool("autocomplete");
|
|
68
|
+
this.delayDuration = obj.getString("delayDuration");
|
|
69
|
+
this.delayAction = obj.getString("delayAction");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@NonNull
|
|
73
|
+
public Money getAmountMoney() {
|
|
74
|
+
return amountMoney;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@NonNull
|
|
78
|
+
public String getPaymentAttemptId() {
|
|
79
|
+
return paymentAttemptId;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Nullable
|
|
83
|
+
public String getProcessingMode() {
|
|
84
|
+
return processingMode;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@Nullable
|
|
88
|
+
public String getReferenceId() {
|
|
89
|
+
return referenceId;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@Nullable
|
|
93
|
+
public String getNote() {
|
|
94
|
+
return note;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@Nullable
|
|
98
|
+
public String getOrderId() {
|
|
99
|
+
return orderId;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@Nullable
|
|
103
|
+
public Money getTipMoney() {
|
|
104
|
+
return tipMoney;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@Nullable
|
|
108
|
+
public Money getApplicationFee() {
|
|
109
|
+
return applicationFee;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@Nullable
|
|
113
|
+
public Boolean getAutocomplete() {
|
|
114
|
+
return autocomplete;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Nullable
|
|
118
|
+
public String getDelayDuration() {
|
|
119
|
+
return delayDuration;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@Nullable
|
|
123
|
+
public String getDelayAction() {
|
|
124
|
+
return delayAction;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
import java.util.ArrayList;
|
|
7
|
+
import java.util.List;
|
|
8
|
+
import org.json.JSONArray;
|
|
9
|
+
import org.json.JSONException;
|
|
10
|
+
|
|
11
|
+
public class PromptParameters {
|
|
12
|
+
|
|
13
|
+
@Nullable
|
|
14
|
+
private final String mode;
|
|
15
|
+
|
|
16
|
+
@NonNull
|
|
17
|
+
private final List<String> additionalMethods;
|
|
18
|
+
|
|
19
|
+
public PromptParameters(@NonNull JSObject obj) throws JSONException {
|
|
20
|
+
this.mode = obj.getString("mode");
|
|
21
|
+
|
|
22
|
+
this.additionalMethods = new ArrayList<>();
|
|
23
|
+
try {
|
|
24
|
+
JSONArray additionalMethodsArray = obj.getJSONArray("additionalMethods");
|
|
25
|
+
if (additionalMethodsArray != null) {
|
|
26
|
+
for (int i = 0; i < additionalMethodsArray.length(); i++) {
|
|
27
|
+
String method = additionalMethodsArray.getString(i);
|
|
28
|
+
if (method != null) {
|
|
29
|
+
this.additionalMethods.add(method);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} catch (JSONException e) {
|
|
34
|
+
// Array not provided, use empty list
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Nullable
|
|
39
|
+
public String getMode() {
|
|
40
|
+
return mode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@NonNull
|
|
44
|
+
public List<String> getAdditionalMethods() {
|
|
45
|
+
return additionalMethods;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.PluginCall;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.CustomExceptions;
|
|
6
|
+
|
|
7
|
+
public class RetryConnectionOptions {
|
|
8
|
+
|
|
9
|
+
@NonNull
|
|
10
|
+
private final String serialNumber;
|
|
11
|
+
|
|
12
|
+
public RetryConnectionOptions(@NonNull PluginCall call) throws Exception {
|
|
13
|
+
this.serialNumber = RetryConnectionOptions.getSerialNumberFromCall(call);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@NonNull
|
|
17
|
+
public String getSerialNumber() {
|
|
18
|
+
return serialNumber;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@NonNull
|
|
22
|
+
private static String getSerialNumberFromCall(@NonNull PluginCall call) throws Exception {
|
|
23
|
+
String serialNumber = call.getString("serialNumber");
|
|
24
|
+
if (serialNumber == null) {
|
|
25
|
+
throw CustomExceptions.SERIAL_NUMBER_MISSING;
|
|
26
|
+
}
|
|
27
|
+
return serialNumber;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.CustomExceptions;
|
|
7
|
+
|
|
8
|
+
public class StartPaymentOptions {
|
|
9
|
+
|
|
10
|
+
@NonNull
|
|
11
|
+
private final PaymentParameters paymentParameters;
|
|
12
|
+
|
|
13
|
+
@NonNull
|
|
14
|
+
private final PromptParameters promptParameters;
|
|
15
|
+
|
|
16
|
+
public StartPaymentOptions(@NonNull PluginCall call) throws Exception {
|
|
17
|
+
JSObject paymentParametersObj = call.getObject("paymentParameters");
|
|
18
|
+
if (paymentParametersObj == null) {
|
|
19
|
+
throw CustomExceptions.PAYMENT_PARAMETERS_MISSING;
|
|
20
|
+
}
|
|
21
|
+
this.paymentParameters = new PaymentParameters(paymentParametersObj);
|
|
22
|
+
|
|
23
|
+
JSObject promptParametersObj = call.getObject("promptParameters");
|
|
24
|
+
if (promptParametersObj == null) {
|
|
25
|
+
throw CustomExceptions.PROMPT_PARAMETERS_MISSING;
|
|
26
|
+
}
|
|
27
|
+
this.promptParameters = new PromptParameters(promptParametersObj);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@NonNull
|
|
31
|
+
public PaymentParameters getPaymentParameters() {
|
|
32
|
+
return paymentParameters;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@NonNull
|
|
36
|
+
public PromptParameters getPromptParameters() {
|
|
37
|
+
return promptParameters;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.interfaces.Result;
|
|
7
|
+
import org.json.JSONObject;
|
|
8
|
+
|
|
9
|
+
public class Card implements Result {
|
|
10
|
+
|
|
11
|
+
@NonNull
|
|
12
|
+
private final String brand;
|
|
13
|
+
|
|
14
|
+
@NonNull
|
|
15
|
+
private final String lastFourDigits;
|
|
16
|
+
|
|
17
|
+
@Nullable
|
|
18
|
+
private final String cardholderName;
|
|
19
|
+
|
|
20
|
+
@Nullable
|
|
21
|
+
private final Integer expirationMonth;
|
|
22
|
+
|
|
23
|
+
@Nullable
|
|
24
|
+
private final Integer expirationYear;
|
|
25
|
+
|
|
26
|
+
public Card(
|
|
27
|
+
@NonNull String brand,
|
|
28
|
+
@NonNull String lastFourDigits,
|
|
29
|
+
@Nullable String cardholderName,
|
|
30
|
+
@Nullable Integer expirationMonth,
|
|
31
|
+
@Nullable Integer expirationYear
|
|
32
|
+
) {
|
|
33
|
+
this.brand = brand;
|
|
34
|
+
this.lastFourDigits = lastFourDigits;
|
|
35
|
+
this.cardholderName = cardholderName;
|
|
36
|
+
this.expirationMonth = expirationMonth;
|
|
37
|
+
this.expirationYear = expirationYear;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Override
|
|
41
|
+
@NonNull
|
|
42
|
+
public JSObject toJSObject() {
|
|
43
|
+
JSObject result = new JSObject();
|
|
44
|
+
result.put("brand", brand);
|
|
45
|
+
result.put("lastFourDigits", lastFourDigits);
|
|
46
|
+
result.put("cardholderName", cardholderName == null ? JSONObject.NULL : cardholderName);
|
|
47
|
+
result.put("expirationMonth", expirationMonth == null ? JSONObject.NULL : expirationMonth);
|
|
48
|
+
result.put("expirationYear", expirationYear == null ? JSONObject.NULL : expirationYear);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.interfaces.Result;
|
|
7
|
+
import org.json.JSONObject;
|
|
8
|
+
|
|
9
|
+
public class CardPaymentDetails implements Result {
|
|
10
|
+
|
|
11
|
+
@NonNull
|
|
12
|
+
private final Card card;
|
|
13
|
+
|
|
14
|
+
@NonNull
|
|
15
|
+
private final String entryMethod;
|
|
16
|
+
|
|
17
|
+
public CardPaymentDetails(@NonNull Card card, @NonNull String entryMethod) {
|
|
18
|
+
this.card = card;
|
|
19
|
+
this.entryMethod = entryMethod;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Override
|
|
23
|
+
@NonNull
|
|
24
|
+
public JSObject toJSObject() {
|
|
25
|
+
JSObject result = new JSObject();
|
|
26
|
+
result.put("card", card.toJSObject());
|
|
27
|
+
result.put("entryMethod", entryMethod);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSArray;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.interfaces.Result;
|
|
7
|
+
import java.util.List;
|
|
8
|
+
|
|
9
|
+
public class GetAvailableCardInputMethodsResult implements Result {
|
|
10
|
+
|
|
11
|
+
@NonNull
|
|
12
|
+
private final List<String> cardInputMethods;
|
|
13
|
+
|
|
14
|
+
public GetAvailableCardInputMethodsResult(@NonNull List<String> cardInputMethods) {
|
|
15
|
+
this.cardInputMethods = cardInputMethods;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
@NonNull
|
|
20
|
+
public JSObject toJSObject() {
|
|
21
|
+
JSObject result = new JSObject();
|
|
22
|
+
JSArray array = new JSArray();
|
|
23
|
+
for (String method : cardInputMethods) {
|
|
24
|
+
array.put(method);
|
|
25
|
+
}
|
|
26
|
+
result.put("cardInputMethods", array);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSArray;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.interfaces.Result;
|
|
7
|
+
import java.util.List;
|
|
8
|
+
|
|
9
|
+
public class GetReadersResult implements Result {
|
|
10
|
+
|
|
11
|
+
@NonNull
|
|
12
|
+
private final List<ReaderInfo> readers;
|
|
13
|
+
|
|
14
|
+
public GetReadersResult(@NonNull List<ReaderInfo> readers) {
|
|
15
|
+
this.readers = readers;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
@NonNull
|
|
20
|
+
public JSObject toJSObject() {
|
|
21
|
+
JSObject result = new JSObject();
|
|
22
|
+
JSArray array = new JSArray();
|
|
23
|
+
for (ReaderInfo reader : readers) {
|
|
24
|
+
array.put(reader.toJSObject());
|
|
25
|
+
}
|
|
26
|
+
result.put("readers", array);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.interfaces.Result;
|
|
6
|
+
|
|
7
|
+
public class GetSettingsResult implements Result {
|
|
8
|
+
|
|
9
|
+
@NonNull
|
|
10
|
+
private final String version;
|
|
11
|
+
|
|
12
|
+
@NonNull
|
|
13
|
+
private final String environment;
|
|
14
|
+
|
|
15
|
+
public GetSettingsResult(@NonNull String version, @NonNull String environment) {
|
|
16
|
+
this.version = version;
|
|
17
|
+
this.environment = environment;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Override
|
|
21
|
+
@NonNull
|
|
22
|
+
public JSObject toJSObject() {
|
|
23
|
+
JSObject result = new JSObject();
|
|
24
|
+
result.put("version", version);
|
|
25
|
+
result.put("environment", environment);
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.interfaces.Result;
|
|
6
|
+
|
|
7
|
+
public class IsAuthorizedResult implements Result {
|
|
8
|
+
|
|
9
|
+
private final boolean authorized;
|
|
10
|
+
|
|
11
|
+
public IsAuthorizedResult(boolean authorized) {
|
|
12
|
+
this.authorized = authorized;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Override
|
|
16
|
+
@NonNull
|
|
17
|
+
public JSObject toJSObject() {
|
|
18
|
+
JSObject result = new JSObject();
|
|
19
|
+
result.put("authorized", authorized);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.interfaces.Result;
|
|
6
|
+
|
|
7
|
+
public class IsPairingInProgressResult implements Result {
|
|
8
|
+
|
|
9
|
+
private final boolean inProgress;
|
|
10
|
+
|
|
11
|
+
public IsPairingInProgressResult(boolean inProgress) {
|
|
12
|
+
this.inProgress = inProgress;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Override
|
|
16
|
+
@NonNull
|
|
17
|
+
public JSObject toJSObject() {
|
|
18
|
+
JSObject result = new JSObject();
|
|
19
|
+
result.put("inProgress", inProgress);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.squaremobilepayments.interfaces.Result;
|
|
6
|
+
|
|
7
|
+
public class MoneyResult implements Result {
|
|
8
|
+
|
|
9
|
+
private final int amount;
|
|
10
|
+
|
|
11
|
+
@NonNull
|
|
12
|
+
private final String currency;
|
|
13
|
+
|
|
14
|
+
public MoneyResult(int amount, @NonNull String currency) {
|
|
15
|
+
this.amount = amount;
|
|
16
|
+
this.currency = currency;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
@NonNull
|
|
21
|
+
public JSObject toJSObject() {
|
|
22
|
+
JSObject result = new JSObject();
|
|
23
|
+
result.put("amount", amount);
|
|
24
|
+
result.put("currency", currency);
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
}
|