@inflow_pay/sdk 1.0.0 → 1.2.0-beta.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/sdk.d.ts CHANGED
@@ -34,13 +34,15 @@ export declare class CardElement {
34
34
  export declare interface CardElementOptions {
35
35
  /** Container element or CSS selector where the iframe will be mounted */
36
36
  container: string | HTMLElement;
37
- /** Payment ID for this transaction */
38
- paymentId: string;
39
- /** Callback when payment completes */
40
- onComplete?: (result: PaymentResult) => void;
41
- /** Callback when payment fails */
37
+ /** Payment ID for a payment transaction. Mutually exclusive with setupId. */
38
+ paymentId?: string;
39
+ /** CustomerPaymentMethodRequest ID for a save-card session. Mutually exclusive with paymentId. */
40
+ setupId?: string;
41
+ /** Callback when the operation completes (payment or card setup) */
42
+ onComplete?: (result: PaymentResult | SaveCardResult) => void;
43
+ /** Callback when the operation fails */
42
44
  onError?: (error: any) => void;
43
- /** Callback when user closes the payment */
45
+ /** Callback when user closes the element */
44
46
  onClose?: () => void;
45
47
  /** Custom styling for the card element */
46
48
  style?: CSSProperties;
@@ -52,14 +54,14 @@ export declare interface CardElementOptions {
52
54
  expiry?: string;
53
55
  cvc?: string;
54
56
  };
55
- /** Show default success UI after payment (default true). If false, only unmount iframe. */
57
+ /** Show default success UI after completion (default true). If false, only unmount iframe. */
56
58
  showDefaultSuccessUI?: boolean;
57
59
  }
58
60
 
59
61
  export declare interface CardElementProps {
60
62
  paymentId: string;
61
63
  container?: string | HTMLElement;
62
- onComplete?: (result: PaymentResult) => void;
64
+ onComplete?: (result: PaymentResult | SaveCardResult) => void;
63
65
  onError?: (error: any) => void;
64
66
  onClose?: () => void;
65
67
  onReady?: () => void;
@@ -89,7 +91,9 @@ declare interface CSSProperties {
89
91
  disclaimerColor?: string;
90
92
  fieldErrorColor?: string;
91
93
  generalError?: GeneralMessageStyles;
94
+ /** @deprecated generalSuccess was removed from the sdk; this has no effect. Will be removed in the next major version. */
92
95
  generalSuccess?: GeneralMessageStyles;
96
+ successUI?: SuccessUIStyles;
93
97
  dark?: ThemeStyles;
94
98
  }
95
99
 
@@ -187,6 +191,8 @@ export declare interface PaymentConfig {
187
191
  amount?: number;
188
192
  currency?: string;
189
193
  paymentId?: string;
194
+ /** ID of a CustomerPaymentMethodRequest – activates save-card mode in the iframe */
195
+ setupId?: string;
190
196
  /** Custom styling for the card element */
191
197
  style?: CSSProperties;
192
198
  /** Custom button text (default: "Complete Payment") */
@@ -243,29 +249,40 @@ export declare class PaymentSDK {
243
249
  */
244
250
  constructor(config: PaymentSDKConfig);
245
251
  /**
246
- * Create a CardElement for iframe-based payment UI
252
+ * Create a CardElement for iframe-based payment or save-card UI.
253
+ *
254
+ * Pass `paymentId` for a payment transaction, or `setupId` to save
255
+ * a card without charging. The two options are mutually exclusive.
247
256
  *
248
257
  * @param options - CardElement configuration
249
258
  * @returns CardElement instance
250
259
  *
251
- * @example
260
+ * @example – payment
252
261
  * ```typescript
253
262
  * const cardElement = sdk.createCardElement({
254
263
  * container: '#card-container',
255
264
  * paymentId: 'pay_123',
256
- * onComplete: (result) => {
257
- * if (result.status === 'CHECKOUT_SUCCESS') {
258
- * window.location.href = '/success';
259
- * }
260
- * }
265
+ * onComplete: (result) => { ... }
261
266
  * });
267
+ * cardElement.mount();
268
+ * ```
262
269
  *
270
+ * @example – save card
271
+ * ```typescript
272
+ * const cardElement = sdk.createCardElement({
273
+ * container: '#card-container',
274
+ * setupId: 'cus_pm_req_123',
275
+ * onComplete: (result) => { ... }
276
+ * });
263
277
  * cardElement.mount();
264
278
  * ```
265
279
  */
266
280
  createCardElement(options: {
267
281
  container: string | HTMLElement;
268
- paymentId: string;
282
+ /** Payment ID – use for payment flow */
283
+ paymentId?: string;
284
+ /** CustomerPaymentMethodRequest ID – use for save-card flow */
285
+ setupId?: string;
269
286
  style?: CSSProperties;
270
287
  buttonText?: string;
271
288
  placeholders?: {
@@ -273,9 +290,10 @@ export declare class PaymentSDK {
273
290
  expiry?: string;
274
291
  cvc?: string;
275
292
  };
276
- onComplete?: (result: PaymentResult) => void;
293
+ onComplete?: (result: PaymentResult | SaveCardResult) => void;
277
294
  onError?: (error: any) => void;
278
295
  onClose?: () => void;
296
+ showDefaultSuccessUI?: boolean;
279
297
  }): CardElement;
280
298
  /**
281
299
  * Get the iframe URL being used
@@ -294,6 +312,18 @@ export declare interface PaymentSDKConfig {
294
312
  locale?: Locale;
295
313
  }
296
314
 
315
+ export declare interface SaveCardResult {
316
+ status: PaymentResultStatus;
317
+ setupId: string;
318
+ error?: PaymentError;
319
+ }
320
+
321
+ declare interface SuccessUIStyles {
322
+ backgroundColor?: string;
323
+ primaryTextColor?: string;
324
+ secondaryTextColor?: string;
325
+ }
326
+
297
327
  declare interface ThemeStyles {
298
328
  inputContainer?: InputContainerStyles;
299
329
  input?: InputStyles;
@@ -301,9 +331,11 @@ declare interface ThemeStyles {
301
331
  disclaimerColor?: string;
302
332
  fieldErrorColor?: string;
303
333
  generalError?: GeneralMessageStyles;
334
+ /** @deprecated generalSuccess was removed from the sdk; this has no effect. Will be removed in the next major version. */
304
335
  generalSuccess?: GeneralMessageStyles;
336
+ successUI?: SuccessUIStyles;
305
337
  }
306
338
 
307
- export declare const VERSION = "0.8.0";
339
+ export declare const VERSION = "1.1.0";
308
340
 
309
341
  export { }
package/dist/sdk.esm.js CHANGED
@@ -1,65 +1,48 @@
1
- import { P as l } from "./payment-sdk-oRqgQSx5.mjs";
2
- import { C as s, a as y, b as f } from "./payment-sdk-oRqgQSx5.mjs";
3
- class d {
4
- constructor(e) {
5
- const n = {
6
- publicKey: e.config.publicKey,
7
- locale: e.config.locale
8
- };
9
- this.sdk = new l(n);
10
- }
11
- /**
12
- * Create a CardElement (similar to React's <CardElement />)
13
- *
14
- * @param props - CardElement props (same as React SDK)
15
- * @returns CardElement instance
16
- */
17
- createCardElement(e) {
18
- let n;
19
- if (e.container)
20
- n = e.container;
21
- else {
22
- const t = document.createElement("div");
23
- t.id = "inflowpay-card-element-container", document.body.appendChild(t), n = t;
24
- }
25
- const a = {
26
- container: n,
27
- paymentId: e.paymentId,
28
- ...e.style && { style: e.style },
29
- ...e.buttonText && { buttonText: e.buttonText },
30
- ...e.placeholders && { placeholders: e.placeholders },
31
- onComplete: (t) => {
32
- e.onComplete && e.onComplete(t);
33
- },
34
- onError: e.onError,
35
- onClose: e.onClose
36
- }, o = this.sdk.createCardElement(a);
37
- if (e.onReady) {
38
- const t = o.mount.bind(o);
39
- o.mount = () => {
40
- t(), setTimeout(() => {
41
- e.onReady && e.onReady();
42
- }, 100);
43
- };
44
- }
45
- return e.onChange && setTimeout(() => {
46
- e.onChange && e.onChange({ complete: !1 });
47
- }, 100), o;
48
- }
49
- /**
50
- * Get the underlying PaymentSDK instance
51
- */
52
- getSDK() {
53
- return this.sdk;
54
- }
55
- }
56
- const m = "0.8.0";
57
- export {
58
- s as CardElement,
59
- d as InflowPayProvider,
60
- y as PaymentResultErrorCode,
61
- f as PaymentResultStatus,
62
- l as PaymentSDK,
63
- m as VERSION
64
- };
65
- //# sourceMappingURL=sdk.esm.js.map
1
+ import { n as e, o as t, s as n, t as r } from "./payment-sdk-DqfuWSo1.mjs";
2
+ //#region src/inflowpay-provider.ts
3
+ var i = class {
4
+ constructor(e) {
5
+ this.sdk = new r({
6
+ publicKey: e.config.publicKey,
7
+ locale: e.config.locale
8
+ });
9
+ }
10
+ createCardElement(e) {
11
+ let t;
12
+ if (e.container) t = e.container;
13
+ else {
14
+ let e = document.createElement("div");
15
+ e.id = "inflowpay-card-element-container", document.body.appendChild(e), t = e;
16
+ }
17
+ let n = {
18
+ container: t,
19
+ paymentId: e.paymentId,
20
+ ...e.style && { style: e.style },
21
+ ...e.buttonText && { buttonText: e.buttonText },
22
+ ...e.placeholders && { placeholders: e.placeholders },
23
+ onComplete: (t) => {
24
+ e.onComplete && e.onComplete(t);
25
+ },
26
+ onError: e.onError,
27
+ onClose: e.onClose
28
+ }, r = this.sdk.createCardElement(n);
29
+ if (e.onReady) {
30
+ let t = r.mount.bind(r);
31
+ r.mount = () => {
32
+ t(), setTimeout(() => {
33
+ e.onReady && e.onReady();
34
+ }, 100);
35
+ };
36
+ }
37
+ return e.onChange && setTimeout(() => {
38
+ e.onChange && e.onChange({ complete: !1 });
39
+ }, 100), r;
40
+ }
41
+ getSDK() {
42
+ return this.sdk;
43
+ }
44
+ }, a = "1.1.0";
45
+ //#endregion
46
+ export { e as CardElement, i as InflowPayProvider, t as PaymentResultErrorCode, n as PaymentResultStatus, r as PaymentSDK, a as VERSION };
47
+
48
+ //# sourceMappingURL=sdk.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.esm.js","sources":["../src/inflowpay-provider.ts","../src/index.ts"],"sourcesContent":["/**\n * InflowPayProvider - Compatibility layer for React SDK API\n * \n * Provides the same API structure as the original React SDK\n * but works with vanilla JavaScript\n */\n\nimport type { CardElement, CardElementOptions } from './card-element';\nimport type { PaymentSDKConfig } from './payment-sdk';\nimport { PaymentSDK } from './payment-sdk';\nimport { PaymentResult } from './react';\nimport type { Locale } from './types';\n\nexport interface InflowPayProviderConfig {\n publicKey: string;\n locale?: Locale;\n}\n\nexport interface CardElementProps {\n paymentId: string;\n container?: string | HTMLElement;\n onComplete?: (result: PaymentResult) => void;\n onError?: (error: any) => void;\n onClose?: () => void;\n onReady?: () => void;\n onChange?: (state: { complete: boolean }) => void;\n buttonText?: string;\n buttonStyle?: any;\n style?: any;\n placeholders?: {\n cardNumber?: string;\n expiry?: string;\n cvc?: string;\n };\n}\n\n/**\n * InflowPayProvider - Global SDK configuration\n * \n * Similar to React's InflowPayProvider but for vanilla JS\n * \n * @example\n * ```typescript\n * const provider = new InflowPayProvider({\n * config: { apiKey: 'inflow_pub_xxx' }\n * });\n * \n * const cardElement = provider.createCardElement({\n * paymentId: 'pay_xxx',\n * onComplete: (result) => {\n * if (result.status === 'CHECKOUT_SUCCESS') {\n * window.location.href = '/success';\n * }\n * }\n * });\n * \n * cardElement.mount();\n * ```\n */\nexport class InflowPayProvider {\n private sdk: PaymentSDK;\n\n constructor(options: { config: InflowPayProviderConfig }) {\n const config: PaymentSDKConfig = {\n publicKey: options.config.publicKey,\n locale: options.config.locale,\n };\n\n this.sdk = new PaymentSDK(config);\n }\n\n /**\n * Create a CardElement (similar to React's <CardElement />)\n * \n * @param props - CardElement props (same as React SDK)\n * @returns CardElement instance\n */\n createCardElement(props: CardElementProps): CardElement {\n let container: string | HTMLElement;\n if (props.container) {\n container = props.container;\n } else {\n const defaultContainer = document.createElement('div');\n defaultContainer.id = 'inflowpay-card-element-container';\n document.body.appendChild(defaultContainer);\n container = defaultContainer;\n }\n\n const cardElementOptions: CardElementOptions = {\n container: container,\n paymentId: props.paymentId,\n ...(props.style && { style: props.style }),\n ...(props.buttonText && { buttonText: props.buttonText }),\n ...(props.placeholders && { placeholders: props.placeholders }),\n onComplete: (result) => {\n if (props.onComplete) {\n props.onComplete(result);\n }\n },\n onError: props.onError,\n onClose: props.onClose,\n };\n\n const cardElement = this.sdk.createCardElement(cardElementOptions);\n\n if (props.onReady) {\n const originalMount = cardElement.mount.bind(cardElement);\n cardElement.mount = () => {\n originalMount();\n setTimeout(() => {\n if (props.onReady) {\n props.onReady();\n }\n }, 100);\n };\n }\n\n if (props.onChange) {\n setTimeout(() => {\n if (props.onChange) {\n props.onChange({ complete: false });\n }\n }, 100);\n }\n\n return cardElement;\n }\n\n /**\n * Get the underlying PaymentSDK instance\n */\n getSDK(): PaymentSDK {\n return this.sdk;\n }\n}\n\n","/**\n * InflowPay SDK v2 - Entry point\n * \n * Provides the same API as the original React SDK but using iframe-based payment flow\n * Compatible with vanilla JavaScript and easy migration from React SDK\n */\n\nexport { InflowPayProvider } from './inflowpay-provider';\nexport type { CardElementProps, InflowPayProviderConfig } from './inflowpay-provider';\n\nexport { PaymentSDK } from './payment-sdk';\nexport type { PaymentSDKConfig } from './payment-sdk';\n\nexport { CardElement } from './card-element';\nexport type { CardElementOptions } from './card-element';\n\nexport type {\n CardElementState, PaymentConfig,\n PaymentError,\n PaymentResult\n} from './types';\n\nexport { PaymentResultErrorCode, PaymentResultStatus } from './types';\n\nexport const VERSION = '0.8.0';\n"],"names":["InflowPayProvider","options","config","PaymentSDK","props","container","defaultContainer","cardElementOptions","result","cardElement","originalMount","VERSION"],"mappings":";;AA2DO,MAAMA,EAAkB;AAAA,EAG7B,YAAYC,GAA8C;AACxD,UAAMC,IAA2B;AAAA,MAC/B,WAAWD,EAAQ,OAAO;AAAA,MAC1B,QAAQA,EAAQ,OAAO;AAAA,IAAA;AAGzB,SAAK,MAAM,IAAIE,EAAWD,CAAM;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,kBAAkBE,GAAsC;AACtD,QAAIC;AACJ,QAAID,EAAM;AACR,MAAAC,IAAYD,EAAM;AAAA,SACb;AACL,YAAME,IAAmB,SAAS,cAAc,KAAK;AACrD,MAAAA,EAAiB,KAAK,oCACtB,SAAS,KAAK,YAAYA,CAAgB,GAC1CD,IAAYC;AAAA,IACd;AAEA,UAAMC,IAAyC;AAAA,MAC7C,WAAAF;AAAA,MACA,WAAWD,EAAM;AAAA,MACjB,GAAIA,EAAM,SAAS,EAAE,OAAOA,EAAM,MAAA;AAAA,MAClC,GAAIA,EAAM,cAAc,EAAE,YAAYA,EAAM,WAAA;AAAA,MAC5C,GAAIA,EAAM,gBAAgB,EAAE,cAAcA,EAAM,aAAA;AAAA,MAChD,YAAY,CAACI,MAAW;AACtB,QAAIJ,EAAM,cACRA,EAAM,WAAWI,CAAM;AAAA,MAE3B;AAAA,MACA,SAASJ,EAAM;AAAA,MACf,SAASA,EAAM;AAAA,IAAA,GAGXK,IAAc,KAAK,IAAI,kBAAkBF,CAAkB;AAEjE,QAAIH,EAAM,SAAS;AACjB,YAAMM,IAAgBD,EAAY,MAAM,KAAKA,CAAW;AACxD,MAAAA,EAAY,QAAQ,MAAM;AACxB,QAAAC,EAAA,GACA,WAAW,MAAM;AACf,UAAIN,EAAM,WACRA,EAAM,QAAA;AAAA,QAEV,GAAG,GAAG;AAAA,MACR;AAAA,IACF;AAEA,WAAIA,EAAM,YACR,WAAW,MAAM;AACf,MAAIA,EAAM,YACRA,EAAM,SAAS,EAAE,UAAU,GAAA,CAAO;AAAA,IAEtC,GAAG,GAAG,GAGDK;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,SAAqB;AACnB,WAAO,KAAK;AAAA,EACd;AACF;AC9GO,MAAME,IAAU;"}
1
+ {"version":3,"file":"sdk.esm.js","names":[],"sources":["../src/inflowpay-provider.ts","../src/index.ts"],"sourcesContent":["/**\n * InflowPayProvider - Compatibility layer for React SDK API\n * \n * Provides the same API structure as the original React SDK\n * but works with vanilla JavaScript\n */\n\nimport type { CardElement, CardElementOptions } from './card-element';\nimport type { PaymentSDKConfig } from './payment-sdk';\nimport { PaymentSDK } from './payment-sdk';\nimport { PaymentResult } from './react';\nimport type { Locale, SaveCardResult } from './types';\n\nexport interface InflowPayProviderConfig {\n publicKey: string;\n locale?: Locale;\n}\n\nexport interface CardElementProps {\n paymentId: string;\n container?: string | HTMLElement;\n onComplete?: (result: PaymentResult | SaveCardResult) => void;\n onError?: (error: any) => void;\n onClose?: () => void;\n onReady?: () => void;\n onChange?: (state: { complete: boolean }) => void;\n buttonText?: string;\n buttonStyle?: any;\n style?: any;\n placeholders?: {\n cardNumber?: string;\n expiry?: string;\n cvc?: string;\n };\n}\n\n/**\n * InflowPayProvider - Global SDK configuration\n * \n * Similar to React's InflowPayProvider but for vanilla JS\n * \n * @example\n * ```typescript\n * const provider = new InflowPayProvider({\n * config: { apiKey: 'inflow_pub_xxx' }\n * });\n * \n * const cardElement = provider.createCardElement({\n * paymentId: 'pay_xxx',\n * onComplete: (result) => {\n * if (result.status === 'CHECKOUT_SUCCESS') {\n * window.location.href = '/success';\n * }\n * }\n * });\n * \n * cardElement.mount();\n * ```\n */\nexport class InflowPayProvider {\n private sdk: PaymentSDK;\n\n constructor(options: { config: InflowPayProviderConfig }) {\n const config: PaymentSDKConfig = {\n publicKey: options.config.publicKey,\n locale: options.config.locale,\n };\n\n this.sdk = new PaymentSDK(config);\n }\n\n /**\n * Create a CardElement (similar to React's <CardElement />)\n * \n * @param props - CardElement props (same as React SDK)\n * @returns CardElement instance\n */\n createCardElement(props: CardElementProps): CardElement {\n let container: string | HTMLElement;\n if (props.container) {\n container = props.container;\n } else {\n const defaultContainer = document.createElement('div');\n defaultContainer.id = 'inflowpay-card-element-container';\n document.body.appendChild(defaultContainer);\n container = defaultContainer;\n }\n\n const cardElementOptions: CardElementOptions = {\n container: container,\n paymentId: props.paymentId,\n ...(props.style && { style: props.style }),\n ...(props.buttonText && { buttonText: props.buttonText }),\n ...(props.placeholders && { placeholders: props.placeholders }),\n onComplete: (result) => {\n if (props.onComplete) {\n props.onComplete(result);\n }\n },\n onError: props.onError,\n onClose: props.onClose,\n };\n\n const cardElement = this.sdk.createCardElement(cardElementOptions);\n\n if (props.onReady) {\n const originalMount = cardElement.mount.bind(cardElement);\n cardElement.mount = () => {\n originalMount();\n setTimeout(() => {\n if (props.onReady) {\n props.onReady();\n }\n }, 100);\n };\n }\n\n if (props.onChange) {\n setTimeout(() => {\n if (props.onChange) {\n props.onChange({ complete: false });\n }\n }, 100);\n }\n\n return cardElement;\n }\n\n /**\n * Get the underlying PaymentSDK instance\n */\n getSDK(): PaymentSDK {\n return this.sdk;\n }\n}\n\n","/**\n * InflowPay SDK v2 - Entry point\n * \n * Provides the same API as the original React SDK but using iframe-based payment flow\n * Compatible with vanilla JavaScript and easy migration from React SDK\n */\n\nexport { InflowPayProvider } from './inflowpay-provider';\nexport type { CardElementProps, InflowPayProviderConfig } from './inflowpay-provider';\n\nexport { PaymentSDK } from './payment-sdk';\nexport type { PaymentSDKConfig } from './payment-sdk';\n\nexport { CardElement } from './card-element';\nexport type { CardElementOptions } from './card-element';\n\nexport type {\n CardElementState,\n PaymentConfig,\n PaymentError,\n PaymentResult,\n SaveCardResult,\n} from './types';\n\nexport { PaymentResultErrorCode, PaymentResultStatus } from './types';\n\nexport const VERSION = '1.1.0';\n"],"mappings":";;AA2DA,IAAa,IAAb,MAA+B;CAG7B,YAAY,GAA8C;AAMxD,OAAK,MAAM,IAAI,EALkB;GAC/B,WAAW,EAAQ,OAAO;GAC1B,QAAQ,EAAQ,OAAO;GACxB,CAEgC;;CASnC,kBAAkB,GAAsC;EACtD,IAAI;AACJ,MAAI,EAAM,UACR,KAAY,EAAM;OACb;GACL,IAAM,IAAmB,SAAS,cAAc,MAAM;AAGtD,GAFA,EAAiB,KAAK,oCACtB,SAAS,KAAK,YAAY,EAAiB,EAC3C,IAAY;;EAGd,IAAM,IAAyC;GAClC;GACX,WAAW,EAAM;GACjB,GAAI,EAAM,SAAS,EAAE,OAAO,EAAM,OAAO;GACzC,GAAI,EAAM,cAAc,EAAE,YAAY,EAAM,YAAY;GACxD,GAAI,EAAM,gBAAgB,EAAE,cAAc,EAAM,cAAc;GAC9D,aAAa,MAAW;AACtB,IAAI,EAAM,cACR,EAAM,WAAW,EAAO;;GAG5B,SAAS,EAAM;GACf,SAAS,EAAM;GAChB,EAEK,IAAc,KAAK,IAAI,kBAAkB,EAAmB;AAElE,MAAI,EAAM,SAAS;GACjB,IAAM,IAAgB,EAAY,MAAM,KAAK,EAAY;AACzD,KAAY,cAAc;AAExB,IADA,GAAe,EACf,iBAAiB;AACf,KAAI,EAAM,WACR,EAAM,SAAS;OAEhB,IAAI;;;AAYX,SARI,EAAM,YACR,iBAAiB;AACf,GAAI,EAAM,YACR,EAAM,SAAS,EAAE,UAAU,IAAO,CAAC;KAEpC,IAAI,EAGF;;CAMT,SAAqB;AACnB,SAAO,KAAK;;GC1GH,IAAU"}