@school24/paymentjs-rn 1.8.0 → 1.9.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.
Files changed (2) hide show
  1. package/dist/PaymentJS.js +14 -4
  2. package/package.json +1 -1
package/dist/PaymentJS.js CHANGED
@@ -52,7 +52,7 @@ function normalizeBase(url) {
52
52
  }
53
53
  function PaymentJS(props) {
54
54
  const {
55
- // These default to internal constants if not provided by Cherian
55
+ // These default to internal constants if not provided
56
56
  pageUrl = DEFAULT_PAGE_URL, lambdaUrl = DEFAULT_LAMBDA_URL, environment = "test",
57
57
  // Auto-select store based on environment if store prop is missing
58
58
  store = STORE_IDS[environment],
@@ -111,13 +111,21 @@ function PaymentJS(props) {
111
111
  onDebug === null || onDebug === void 0 ? void 0 : onDebug(message.payload);
112
112
  return;
113
113
  }
114
+ // Check for our custom S24 Internal Error format within the payload
115
+ const isInternalError = message.payload && message.payload.ok === false;
114
116
  switch (message.event) {
115
117
  case "PAYMENT_SUCCESS":
116
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(message.payload);
118
+ // If the payload itself contains ok: false, treat as failure (S24 Standard)
119
+ if (isInternalError) {
120
+ onPaymentFailure === null || onPaymentFailure === void 0 ? void 0 : onPaymentFailure(message.payload);
121
+ }
122
+ else {
123
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(message.payload);
124
+ }
117
125
  break;
118
126
  case "PAYMENT_ERROR":
119
127
  case "CONFIG_ERROR":
120
- // Receives the granular messages (Insufficient Funds, etc.) from Lambda
128
+ // Pass the mapped S24 message directly to the failure callback
121
129
  onPaymentFailure === null || onPaymentFailure === void 0 ? void 0 : onPaymentFailure(message.payload);
122
130
  break;
123
131
  case "ENCRYPT_SUCCESS":
@@ -136,7 +144,9 @@ function PaymentJS(props) {
136
144
  if (debug)
137
145
  console.error("Failed to parse WebView message:", err);
138
146
  onPaymentFailure === null || onPaymentFailure === void 0 ? void 0 : onPaymentFailure({
139
- message: "WebView Bridge Error",
147
+ ok: false,
148
+ message: "Communication Error",
149
+ internalCode: "S24_PAY_ERR_SYSTEM",
140
150
  error: String(err),
141
151
  });
142
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@school24/paymentjs-rn",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "React Native WebView wrapper for PaymentJS (Adyen)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",