@melio-eng/web-sdk 1.0.36 → 1.0.37-pr.74.a959b05

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.
@@ -0,0 +1,16 @@
1
+ import { JustPayFlowConfig, Environment } from '../types.js';
2
+ import { Flow } from './Flow.js';
3
+ /**
4
+ * JustPayFlow subclass - opens payment flow with vendor and amount prefilled
5
+ * Uses externalVendorIds instead of billIds
6
+ */
7
+ export declare class JustPayFlow extends Flow {
8
+ private externalVendorIds;
9
+ private amount?;
10
+ private authCode;
11
+ constructor(containerId: string, config: JustPayFlowConfig, partnerName: string, environment: Environment, authCode: string, branchOverride?: string);
12
+ /**
13
+ * Construct the specific flow URL for vendor payment - goes through /auth
14
+ */
15
+ protected constructFlowUrl(baseUrl: string): string;
16
+ }
@@ -0,0 +1,29 @@
1
+ import { Flow } from './Flow.js';
2
+ import { isEmptyString } from './utils.js';
3
+ /**
4
+ * JustPayFlow subclass - opens payment flow with vendor and amount prefilled
5
+ * Uses externalVendorIds instead of billIds
6
+ */
7
+ export class JustPayFlow extends Flow {
8
+ constructor(containerId, config, partnerName, environment, authCode, branchOverride) {
9
+ super(containerId, config, partnerName, environment, branchOverride);
10
+ this.externalVendorIds = config.externalVendorIds;
11
+ this.amount = config.amount;
12
+ this.authCode = authCode;
13
+ if (isEmptyString(this.authCode)) {
14
+ throw new Error('Authorization code is required for just pay flow. Please call init() before opening just pay flow.');
15
+ }
16
+ }
17
+ /**
18
+ * Construct the specific flow URL for vendor payment - goes through /auth
19
+ */
20
+ constructFlowUrl(baseUrl) {
21
+ const vendorIdsParam = this.externalVendorIds.join(',');
22
+ let target = `/external-entries/payment-flow?externalVendorIds=${vendorIdsParam}&externalOrigin=${this.partnerName}`;
23
+ if (this.amount !== undefined) {
24
+ target += `&amount=${this.amount}`;
25
+ }
26
+ const encodedTarget = encodeURIComponent(target);
27
+ return `${baseUrl}/${this.partnerName}/auth?token=${this.authCode}&redirectUrl=${encodedTarget}`;
28
+ }
29
+ }
@@ -2,6 +2,7 @@ export { Flow } from './Flow.js';
2
2
  export { InitFlow } from './InitFlow.js';
3
3
  export { OnboardingFlow } from './OnboardingFlow.js';
4
4
  export { PayFlow } from './PayFlow.js';
5
+ export { JustPayFlow } from './JustPayFlow.js';
5
6
  export { SettingsFlow } from './SettingsFlow.js';
6
7
  export { PaymentsDashboardFlow } from './PaymentsDashboardFlow.js';
7
8
  export { getBaseUrl, isEmptyString } from './utils.js';
@@ -2,6 +2,7 @@ export { Flow } from './Flow.js';
2
2
  export { InitFlow } from './InitFlow.js';
3
3
  export { OnboardingFlow } from './OnboardingFlow.js';
4
4
  export { PayFlow } from './PayFlow.js';
5
+ export { JustPayFlow } from './JustPayFlow.js';
5
6
  export { SettingsFlow } from './SettingsFlow.js';
6
7
  export { PaymentsDashboardFlow } from './PaymentsDashboardFlow.js';
7
8
  export { getBaseUrl, isEmptyString } from './utils.js';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { InitOptions, OnboardingConfig, SettingsConfig, FlowInstance, PaymentsDashboardConfig, PayFlowConfig, InitFlowInstance } from './types.js';
1
+ import { InitOptions, OnboardingConfig, SettingsConfig, FlowInstance, PaymentsDashboardConfig, PayFlowConfig, JustPayFlowConfig, InitFlowInstance } from './types.js';
2
2
  /**
3
3
  * Main SDK implementation - now partner agnostic
4
4
  */
@@ -22,6 +22,10 @@ export declare class MelioSDK implements MelioSDK {
22
22
  * Launch the pay flow
23
23
  */
24
24
  openPayFlow(config: PayFlowConfig): FlowInstance;
25
+ /**
26
+ * Launch the just pay flow (vendor-based payment)
27
+ */
28
+ openJustPayFlow(config: JustPayFlowConfig): FlowInstance;
25
29
  /**
26
30
  * Launch the settings flow
27
31
  */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { InitFlow, OnboardingFlow, PayFlow, SettingsFlow, PaymentsDashboardFlow, isEmptyString, } from './flows/index.js';
1
+ import { InitFlow, OnboardingFlow, PayFlow, JustPayFlow, SettingsFlow, PaymentsDashboardFlow, isEmptyString, } from './flows/index.js';
2
2
  /**
3
3
  * Main SDK implementation - now partner agnostic
4
4
  */
@@ -57,6 +57,17 @@ export class MelioSDK {
57
57
  flow.initialize();
58
58
  return flow;
59
59
  }
60
+ /**
61
+ * Launch the just pay flow (vendor-based payment)
62
+ */
63
+ openJustPayFlow(config) {
64
+ if (isEmptyString(this.authCode)) {
65
+ throw new Error('SDK not initialized. Please call init() before opening just pay flow.');
66
+ }
67
+ const flow = new JustPayFlow(config.containerId, config, this.partnerName, this.environment, this.authCode, this.branchOverride);
68
+ flow.initialize();
69
+ return flow;
70
+ }
60
71
  /**
61
72
  * Launch the settings flow
62
73
  */
package/dist/types.d.ts CHANGED
@@ -55,6 +55,15 @@ export interface OnboardingConfig extends BaseFlowConfig {
55
55
  export interface PayFlowConfig extends BaseFlowConfig {
56
56
  billIds: Array<string>;
57
57
  }
58
+ /**
59
+ * Configuration for just pay flow (vendor-based payment)
60
+ */
61
+ export interface JustPayFlowConfig extends BaseFlowConfig {
62
+ /** External vendor IDs to sync and pay */
63
+ externalVendorIds: Array<string>;
64
+ /** Optional amount to prefill in the payment flow */
65
+ amount?: number;
66
+ }
58
67
  /**
59
68
  * Configuration for settings flow
60
69
  */
@@ -171,6 +180,12 @@ export interface MelioSDK {
171
180
  * @returns Flow instance for event handling
172
181
  */
173
182
  openOnboarding(config: OnboardingConfig): FlowInstance;
183
+ /**
184
+ * Launch the just pay flow (vendor-based payment)
185
+ * @param config - Configuration for the just pay flow
186
+ * @returns Flow instance for event handling
187
+ */
188
+ openJustPayFlow(config: JustPayFlowConfig): FlowInstance;
174
189
  /**
175
190
  * Launch the settings flow
176
191
  * @param config - Configuration for the settings flow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melio-eng/web-sdk",
3
- "version": "1.0.36",
3
+ "version": "1.0.37-pr.74.a959b05",
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",