@school24/paymentjs-rn 1.4.8 → 1.5.0
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/dist/PaymentJS.js +9 -5
- package/dist/types.d.ts +5 -3
- package/package.json +1 -1
package/dist/PaymentJS.js
CHANGED
|
@@ -41,10 +41,10 @@ function safeBoolString(v) {
|
|
|
41
41
|
return (v ? "true" : "false");
|
|
42
42
|
}
|
|
43
43
|
function normalizeBase(url) {
|
|
44
|
-
return url.replace(/\/+$/, "");
|
|
44
|
+
return url ? url.replace(/\/+$/, "") : "";
|
|
45
45
|
}
|
|
46
46
|
function PaymentJS(props) {
|
|
47
|
-
const { uri, pageUrl = "https://client.brandsyncstudio.com/paymentjs/payment-rn.html", lambdaUrl = "https://qb3epa62mry53z3woeiecuhpve0scpjb.lambda-url.ap-southeast-2.on.aws", mode = "pay", environment = "test", shopperReference = "", amount = 0, currency = "AUD", storePaymentMethod = false, ts, style, debug = false, onPaymentSuccess, onPaymentFailure, onEncryptSuccess, onEncryptFailure, onDebug, } = props;
|
|
47
|
+
const { uri, pageUrl = "https://client.brandsyncstudio.com/paymentjs/payment-rn.html", lambdaUrl = "https://qb3epa62mry53z3woeiecuhpve0scpjb.lambda-url.ap-southeast-2.on.aws", store = "", mode = "pay", environment = "test", shopperReference = "", amount = 0, currency = "AUD", storePaymentMethod = false, ts, style, debug = false, onPaymentSuccess, onPaymentFailure, onEncryptSuccess, onEncryptFailure, onDebug, } = props;
|
|
48
48
|
// Build final URL if uri isn't provided
|
|
49
49
|
const finalUri = (0, react_1.useMemo)(() => {
|
|
50
50
|
if (uri)
|
|
@@ -55,7 +55,9 @@ function PaymentJS(props) {
|
|
|
55
55
|
params.set("env", environment);
|
|
56
56
|
params.set("baseUrl", normalizeBase(lambdaUrl));
|
|
57
57
|
params.set("currency", currency);
|
|
58
|
-
// Optional but
|
|
58
|
+
// Optional but required for MIT/Saved Card compliance:
|
|
59
|
+
if (store)
|
|
60
|
+
params.set("store", store);
|
|
59
61
|
if (shopperReference)
|
|
60
62
|
params.set("shopperReference", shopperReference);
|
|
61
63
|
params.set("storePaymentMethod", safeBoolString(storePaymentMethod));
|
|
@@ -63,13 +65,14 @@ function PaymentJS(props) {
|
|
|
63
65
|
if (mode === "pay") {
|
|
64
66
|
params.set("amount", String(amount !== null && amount !== void 0 ? amount : 0));
|
|
65
67
|
}
|
|
66
|
-
// cache buster
|
|
68
|
+
// cache buster for Expo/WebView refresh
|
|
67
69
|
params.set("ts", String(ts !== null && ts !== void 0 ? ts : Date.now()));
|
|
68
70
|
return `${pageUrl}?${params.toString()}`;
|
|
69
71
|
}, [
|
|
70
72
|
uri,
|
|
71
73
|
pageUrl,
|
|
72
74
|
lambdaUrl,
|
|
75
|
+
store,
|
|
73
76
|
mode,
|
|
74
77
|
environment,
|
|
75
78
|
shopperReference,
|
|
@@ -99,6 +102,7 @@ function PaymentJS(props) {
|
|
|
99
102
|
return;
|
|
100
103
|
case "PAYMENT_ERROR":
|
|
101
104
|
case "CONFIG_ERROR":
|
|
105
|
+
// Enhanced error payloads now contain specific codes like CvcRequired or ContractNotFound
|
|
102
106
|
onPaymentFailure === null || onPaymentFailure === void 0 ? void 0 : onPaymentFailure(message.payload);
|
|
103
107
|
return;
|
|
104
108
|
case "ENCRYPT_SUCCESS":
|
|
@@ -130,7 +134,7 @@ function PaymentJS(props) {
|
|
|
130
134
|
onEncryptSuccess,
|
|
131
135
|
onEncryptFailure,
|
|
132
136
|
]);
|
|
133
|
-
//
|
|
137
|
+
// Validation to prevent 800 (Contract Not Found) or 422 (Validation) errors upfront
|
|
134
138
|
const configError = (0, react_1.useMemo)(() => {
|
|
135
139
|
if (!finalUri)
|
|
136
140
|
return "Missing payment page URL";
|
package/dist/types.d.ts
CHANGED
|
@@ -16,18 +16,20 @@ export type PaymentJSProps = {
|
|
|
16
16
|
uri?: string;
|
|
17
17
|
/**
|
|
18
18
|
* Hosted HTML page URL (without querystring).
|
|
19
|
-
* Example: "https://pay.school24.net/payment.html"
|
|
20
19
|
*/
|
|
21
20
|
pageUrl?: string;
|
|
22
21
|
/**
|
|
23
22
|
* Lambda baseUrl (passed to the HTML as baseUrl=...)
|
|
24
|
-
* Example: "https://xxxxx.lambda-url.ap-southeast-2.on.aws"
|
|
25
23
|
*/
|
|
26
24
|
lambdaUrl?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional: The specific store ID for the merchant account.
|
|
27
|
+
*/
|
|
28
|
+
store?: string;
|
|
27
29
|
mode?: PaymentJSMode;
|
|
28
30
|
environment?: PaymentJSEnvironment;
|
|
29
31
|
shopperReference?: string;
|
|
30
|
-
/** Required for pay mode */
|
|
32
|
+
/** Required for pay mode (minor units) */
|
|
31
33
|
amount?: number;
|
|
32
34
|
currency?: string;
|
|
33
35
|
/** If true, ask Adyen to store the card */
|