@melio-eng/web-sdk 1.0.39 → 1.0.40-pr.86.97072e0

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/README.md CHANGED
@@ -35,6 +35,7 @@ init.on("authenticationSucceeded", () => {
35
35
  const payFlow = melioSDK.openPayFlow({
36
36
  containerId: "melio-payflow-container",
37
37
  billIds: ["bill_abc123"],
38
+ billIdType: "melio",
38
39
  });
39
40
 
40
41
  payFlow.on("completed", (data) => {
@@ -101,11 +102,15 @@ Each environment uses a different base URL:
101
102
  ### Flow Methods
102
103
 
103
104
  #### Pay Flow
104
- Pay one or more bills. Pass the **Melio bill IDs** returned by `POST /pay-flow/prepare`.
105
+ Pay one or more bills. Pass the **Melio bill IDs** returned by `POST /pay-flow/prepare` together with `billIdType: "melio"`.
105
106
  ```typescript
106
107
  melioSDK.openPayFlow(config: PayFlowConfig): FlowInstance
107
108
  ```
108
109
 
110
+ `billIdType` controls how the platform resolves `billIds` (defaults to `"accounting"`):
111
+ - `"melio"` — `billIds` are Melio bill IDs from `/pay-flow/prepare`; the payment screen opens directly. **Use this for the prepare-based pay-flow integration.**
112
+ - `"accounting"` — `billIds` are external accounting-software IDs, imported on demand (for accounting-software partners such as Xero / QuickBooks).
113
+
109
114
  #### Just Pay Flow
110
115
  Vendor-based payment (start from a vendor rather than a specific bill).
111
116
  ```typescript
@@ -138,6 +143,7 @@ Each flow method returns a `FlowInstance` that allows you to register event list
138
143
  const flow = melioSDK.openPayFlow({
139
144
  containerId: "melio-payflow-container",
140
145
  billIds: ["bill_abc123"],
146
+ billIdType: "melio",
141
147
  });
142
148
 
143
149
  flow.on("loaded", () => console.log("Flow rendered"));
@@ -163,6 +169,7 @@ flow.on("navigated", (p) => console.log("Navigated to:", p.target));
163
169
  const payFlow = melioSDK.openPayFlow({
164
170
  containerId: "melio-payflow-container",
165
171
  billIds: ["bill_abc123", "bill_def456"], // Melio bill IDs from /pay-flow/prepare
172
+ billIdType: "melio",
166
173
  });
167
174
 
168
175
  payFlow.on("completed", (data) => {
@@ -187,6 +194,7 @@ init.on("authenticationSucceeded", () => {
187
194
  melioSDK.openPayFlow({
188
195
  containerId: "payment-container",
189
196
  billIds: ["bill_abc123"],
197
+ billIdType: "melio",
190
198
  });
191
199
  });
192
200
  ```
@@ -7,9 +7,20 @@ export declare class PayFlow extends Flow {
7
7
  private billIds;
8
8
  private authCode;
9
9
  private entryPoint?;
10
+ private billIdType;
10
11
  constructor(containerId: string, config: PayFlowConfig, partnerName: string, environment: Environment, authCode: string, branchOverride?: string);
11
12
  /**
12
13
  * Construct the specific flow URL for bill payment - now goes through /auth
13
14
  */
14
15
  protected constructFlowUrl(baseUrl: string): string;
16
+ /**
17
+ * Native Melio bill ids (from POST /pay-flow/prepare) already exist in Melio,
18
+ * so open the payment screen directly instead of importing via external-entries.
19
+ */
20
+ private buildMelioTarget;
21
+ /**
22
+ * External accounting-software bill ids are imported on demand through the
23
+ * external-entries flow before payment.
24
+ */
25
+ private buildAccountingTarget;
15
26
  }
@@ -9,6 +9,7 @@ export class PayFlow extends Flow {
9
9
  this.billIds = config.billIds;
10
10
  this.authCode = authCode;
11
11
  this.entryPoint = config.entryPoint;
12
+ this.billIdType = config.billIdType ?? 'accounting';
12
13
  if (isEmptyString(this.authCode)) {
13
14
  throw new Error('Authorization code is required for pay flow. Please call init() before opening pay flow.');
14
15
  }
@@ -17,10 +18,26 @@ export class PayFlow extends Flow {
17
18
  * Construct the specific flow URL for bill payment - now goes through /auth
18
19
  */
19
20
  constructFlowUrl(baseUrl) {
20
- const billIdsParam = this.billIds.join(',');
21
- const externalOrigin = this.entryPoint ? `${this.partnerName}-${this.entryPoint}` : this.partnerName;
22
- const target = `/external-entries/payment-flow?billIds=${billIdsParam}&externalOrigin=${externalOrigin}`;
21
+ const target = this.billIdType === 'melio' ? this.buildMelioTarget() : this.buildAccountingTarget();
23
22
  const encodedTarget = encodeURIComponent(target);
24
23
  return `${baseUrl}/${this.partnerName}/auth?token=${this.authCode}&redirectUrl=${encodedTarget}`;
25
24
  }
25
+ /**
26
+ * Native Melio bill ids (from POST /pay-flow/prepare) already exist in Melio,
27
+ * so open the payment screen directly instead of importing via external-entries.
28
+ */
29
+ buildMelioTarget() {
30
+ return this.billIds.length === 1
31
+ ? `/payment/new?billId=${this.billIds[0]}`
32
+ : `/batch-payments/${this.billIds.join(',')}`;
33
+ }
34
+ /**
35
+ * External accounting-software bill ids are imported on demand through the
36
+ * external-entries flow before payment.
37
+ */
38
+ buildAccountingTarget() {
39
+ const billIdsParam = this.billIds.join(',');
40
+ const externalOrigin = this.entryPoint ? `${this.partnerName}-${this.entryPoint}` : this.partnerName;
41
+ return `/external-entries/payment-flow?billIds=${billIdsParam}&externalOrigin=${externalOrigin}`;
42
+ }
26
43
  }
package/dist/types.d.ts CHANGED
@@ -63,6 +63,16 @@ export interface PayFlowConfig extends BaseFlowConfig {
63
63
  billIds: Array<string>;
64
64
  /** Optional entry point context — affects the externalOrigin passed to the platform */
65
65
  entryPoint?: ExternalEntryPoint;
66
+ /**
67
+ * How the platform should resolve the provided `billIds`. Defaults to `'accounting'`.
68
+ * - `'accounting'`: `billIds` are external accounting-software ids. The platform imports
69
+ * them on demand through the external-entries flow. Use this for accounting-software
70
+ * partners (e.g. Xero, QuickBooks) whose bills originate in the external system.
71
+ * - `'melio'`: `billIds` are native Melio bill ids returned by `POST /pay-flow/prepare`.
72
+ * The bills already exist in Melio, so the payment screen opens directly — no
73
+ * accounting-platform sync. Use this for the prepare-based pay-flow integration.
74
+ */
75
+ billIdType?: 'accounting' | 'melio';
66
76
  }
67
77
  /**
68
78
  * Configuration for just pay flow (vendor-based payment)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melio-eng/web-sdk",
3
- "version": "1.0.39",
3
+ "version": "1.0.40-pr.86.97072e0",
4
4
  "description": "Melio Web SDK - Embed core Melio workflows directly into partner UI with minimal effort",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",