bison-web-components 2.0.0 → 3.0.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/.vscode/settings.json +3 -0
- package/api.js +269 -0
- package/bison-operator-payments.js +866 -36
- package/demo-payments.html +91 -64
- package/package.json +1 -1
package/demo-payments.html
CHANGED
|
@@ -150,7 +150,8 @@
|
|
|
150
150
|
<h1>Operator Bank Account Mgt.</h1>
|
|
151
151
|
<p>
|
|
152
152
|
Set the operator attributes below, then click the button to open the
|
|
153
|
-
Bank Management modal.
|
|
153
|
+
Bank Management modal. Link Account uses the latest Plaid Link flow.
|
|
154
|
+
Both lookup fields empty = component disabled.
|
|
154
155
|
</p>
|
|
155
156
|
|
|
156
157
|
<!-- Attribute controls -->
|
|
@@ -191,84 +192,110 @@
|
|
|
191
192
|
</div>
|
|
192
193
|
|
|
193
194
|
<!-- ── Scripts ──────────────────────────────────── -->
|
|
194
|
-
<script src="
|
|
195
|
+
<script type="module" src="./bison-operator-payments.js"></script>
|
|
195
196
|
<script type="module">
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
// ── API Bootstrap ─────────────────────────────
|
|
199
|
-
const API_BASE =
|
|
200
|
-
"https://bison-backend-development-hhgrdbhcbwhahdfk.southeastasia-01.azurewebsites.net";
|
|
201
|
-
const API_KEY = "BwVEfJ2u5y2JPsX8qGxtXlIhHyhu3qU2VW2y6Nf9Qc6KTsETvr";
|
|
202
|
-
|
|
203
|
-
const api = new BisonJibPayAPI(API_BASE, API_KEY);
|
|
204
|
-
window.__bisonApi = api;
|
|
205
|
-
|
|
206
|
-
// ── DOM References ────────────────────────────
|
|
207
|
-
const comp = document.querySelector("bison-operator-payments");
|
|
197
|
+
const paymentsEl = document.querySelector("bison-operator-payments");
|
|
208
198
|
const logEl = document.getElementById("log");
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
const
|
|
199
|
+
const embeddableKeyInput = document.getElementById("input-embeddableKey");
|
|
200
|
+
const opOrgIdInput = document.getElementById("input-opOrgId");
|
|
201
|
+
const orgNumberInput = document.getElementById("input-orgNumber");
|
|
212
202
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
logEl.appendChild(
|
|
203
|
+
function log(message, type = "") {
|
|
204
|
+
const row = document.createElement("div");
|
|
205
|
+
row.className = `entry ${type}`.trim();
|
|
206
|
+
const timestamp = new Date().toLocaleTimeString();
|
|
207
|
+
row.textContent = `[${timestamp}] ${message}`;
|
|
208
|
+
logEl.appendChild(row);
|
|
219
209
|
logEl.scrollTop = logEl.scrollHeight;
|
|
220
210
|
}
|
|
221
211
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
} else {
|
|
230
|
-
comp.removeAttribute(attrName);
|
|
231
|
-
addLog(`REMOVED ${attrName}`, "disabled");
|
|
232
|
-
}
|
|
233
|
-
});
|
|
212
|
+
function setOrRemoveAttr(el, attr, value) {
|
|
213
|
+
const cleaned = (value || "").trim();
|
|
214
|
+
if (cleaned) {
|
|
215
|
+
el.setAttribute(attr, cleaned);
|
|
216
|
+
} else {
|
|
217
|
+
el.removeAttribute(attr);
|
|
218
|
+
}
|
|
234
219
|
}
|
|
235
220
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
comp.addEventListener("bop-close", () => {
|
|
242
|
-
addLog("bop-close fired", "close");
|
|
243
|
-
});
|
|
221
|
+
function applyComponentAttributes() {
|
|
222
|
+
setOrRemoveAttr(paymentsEl, "x-embeddable-key", embeddableKeyInput.value);
|
|
223
|
+
setOrRemoveAttr(paymentsEl, "op-org-id", opOrgIdInput.value);
|
|
224
|
+
setOrRemoveAttr(paymentsEl, "org-number", orgNumberInput.value);
|
|
225
|
+
}
|
|
244
226
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
227
|
+
// Property callbacks
|
|
228
|
+
paymentsEl.onOpen = () => log("Modal opened");
|
|
229
|
+
paymentsEl.onClose = () => log("Modal closed", "close");
|
|
230
|
+
paymentsEl.onLookupSuccess = (data) => {
|
|
231
|
+
const operatorId = data?.operatorId || data?.data?.operatorId || "n/a";
|
|
232
|
+
log(`Lookup success (operatorId=${operatorId})`, "lookup");
|
|
233
|
+
};
|
|
234
|
+
paymentsEl.onLookupError = (error) => {
|
|
235
|
+
const msg = error?.message || "Lookup failed";
|
|
236
|
+
log(`Lookup error: ${msg}`, "error");
|
|
237
|
+
};
|
|
238
|
+
paymentsEl.onBankFetchSuccess = (accounts) => {
|
|
239
|
+
const count = Array.isArray(accounts) ? accounts.length : 0;
|
|
240
|
+
log(`Fetched ${count} bank account(s)`, "success");
|
|
241
|
+
};
|
|
242
|
+
paymentsEl.onBankFetchError = (error) => {
|
|
243
|
+
const msg = error?.message || "Bank account fetch failed";
|
|
244
|
+
log(`Bank fetch error: ${msg}`, "error");
|
|
245
|
+
};
|
|
246
|
+
paymentsEl.onLinkSuccess = (payload) => {
|
|
247
|
+
const succeeded = payload?.allSucceeded;
|
|
248
|
+
log(
|
|
249
|
+
`Link success${typeof succeeded === "boolean" ? ` (allSucceeded=${succeeded})` : ""}`,
|
|
250
|
+
"success",
|
|
250
251
|
);
|
|
252
|
+
};
|
|
253
|
+
paymentsEl.onLinkError = (error) => {
|
|
254
|
+
const msg = error?.message || "Link account failed";
|
|
255
|
+
log(`Link error: ${msg}`, "error");
|
|
256
|
+
};
|
|
257
|
+
paymentsEl.onUnlinkSuccess = (accounts) => {
|
|
258
|
+
const count = Array.isArray(accounts) ? accounts.length : 0;
|
|
259
|
+
log(`Unlinked ${count} account(s)`, "success");
|
|
260
|
+
};
|
|
261
|
+
paymentsEl.onUnlinkError = (errors) => {
|
|
262
|
+
const count = Array.isArray(errors) ? errors.length : 0;
|
|
263
|
+
log(`Unlink error for ${count} account(s)`, "error");
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
// Custom events
|
|
267
|
+
paymentsEl.addEventListener("bop-operator-lookup", (event) => {
|
|
268
|
+
const status = event?.detail?.status || "unknown";
|
|
269
|
+
const cssClass =
|
|
270
|
+
status === "success"
|
|
271
|
+
? "lookup"
|
|
272
|
+
: status === "disabled"
|
|
273
|
+
? "disabled"
|
|
274
|
+
: status === "error"
|
|
275
|
+
? "error"
|
|
276
|
+
: "";
|
|
277
|
+
log(`Lookup event status: ${status}`, cssClass);
|
|
251
278
|
});
|
|
252
279
|
|
|
253
|
-
|
|
254
|
-
const
|
|
280
|
+
paymentsEl.addEventListener("bop-success", (event) => {
|
|
281
|
+
const detail = event.detail || {};
|
|
282
|
+
const bankName = detail.bankName || "Unknown bank";
|
|
283
|
+
const lastFour = detail.lastFour || "----";
|
|
284
|
+
log(`bop-success: ${bankName} ••••${lastFour}`, "success");
|
|
285
|
+
});
|
|
255
286
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
addLog("bop-operator-lookup → SUCCESS", "success");
|
|
259
|
-
addLog(` Data: ${JSON.stringify(data)}`, "success");
|
|
260
|
-
break;
|
|
261
|
-
case "error":
|
|
262
|
-
addLog("bop-operator-lookup → ERROR", "error");
|
|
263
|
-
addLog(` ${JSON.stringify(error)}`, "error");
|
|
264
|
-
break;
|
|
265
|
-
case "disabled":
|
|
266
|
-
addLog(`bop-operator-lookup → DISABLED: ${reason}`, "disabled");
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
287
|
+
paymentsEl.addEventListener("bop-close", () => {
|
|
288
|
+
log("bop-close emitted", "close");
|
|
269
289
|
});
|
|
270
290
|
|
|
271
|
-
|
|
291
|
+
// Attribute controls
|
|
292
|
+
embeddableKeyInput.addEventListener("input", applyComponentAttributes);
|
|
293
|
+
opOrgIdInput.addEventListener("input", applyComponentAttributes);
|
|
294
|
+
orgNumberInput.addEventListener("input", applyComponentAttributes);
|
|
295
|
+
|
|
296
|
+
applyComponentAttributes();
|
|
297
|
+
log("Demo ready. Set embeddable key and operator lookup fields.");
|
|
298
|
+
log("Link Account now uses Plaid Link + registerPlaidBankAccount.");
|
|
272
299
|
</script>
|
|
273
300
|
</body>
|
|
274
301
|
</html>
|