@getopenpay/openpay-js 0.4.0 → 0.5.0-alpha.62d9c95

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.
@@ -1,4 +1,4 @@
1
- import { R as Le } from "./index-CM28ZKY-.js";
1
+ import { R as Le } from "./index-Ca030TDy.js";
2
2
  function Et(e) {
3
3
  return e === void 0 && (e = {}), typeof e.addEventListener == "function" && typeof e.removeEventListener == "function";
4
4
  }
@@ -1,8 +1,8 @@
1
- import { m as s } from "./metrics-api-eu-JwCZQ.js";
2
- import { t as d } from "./index-CM28ZKY-.js";
3
- import { l as u } from "./utils-BYrqqSgW.js";
4
- import { I as N, i as T, s as w, a as E } from "./utils-BYrqqSgW.js";
5
- import { d as f } from "./diag-api-BZd81gXR.js";
1
+ import { m as s } from "./metrics-api-DlHxJhGO.js";
2
+ import { t as d } from "./index-Ca030TDy.js";
3
+ import { l as u } from "./utils-CT2-sflt.js";
4
+ import { I as N, i as T, s as w, a as E } from "./utils-CT2-sflt.js";
5
+ import { d as f } from "./diag-api-DPGn2Sdx.js";
6
6
  function l(e, r, t, o) {
7
7
  for (var n = 0, a = e.length; n < a; n++) {
8
8
  var i = e[n];
@@ -1,7 +1,7 @@
1
- import { R as l } from "./Resource-qCFgdIPQ.js";
2
- import { d as ee } from "./Resource-qCFgdIPQ.js";
3
- import { d as v } from "./diag-api-BZd81gXR.js";
4
- import { e as A, f as m, g as b, h as w, S as D } from "./sdk-info-zR2TjJEO.js";
1
+ import { R as l } from "./Resource-DdbPJLpu.js";
2
+ import { d as ee } from "./Resource-DdbPJLpu.js";
3
+ import { d as v } from "./diag-api-DPGn2Sdx.js";
4
+ import { e as A, f as m, g as b, h as w, S as D } from "./sdk-info-DKlCcJvg.js";
5
5
  var T = (
6
6
  /** @class */
7
7
  function() {
package/dist/index.d.ts CHANGED
@@ -5,6 +5,16 @@ import { PaymentRequest as PaymentRequest_2 } from '@stripe/stripe-js';
5
5
  import { Subject } from 'rxjs';
6
6
  import { z } from 'zod';
7
7
 
8
+ declare type AirwallexApplePayFlowCustomParams = {
9
+ overridePaymentRequest?: {
10
+ amount: Amount;
11
+ pending?: boolean;
12
+ label?: string;
13
+ applePayPaymentRequest?: ApplePayPaymentRequest;
14
+ };
15
+ defaultFieldValues?: DefaultFieldValues;
16
+ };
17
+
8
18
  declare type AllCallbacks = {
9
19
  onFocus?: (elementId: string, field: AllFieldNames) => void;
10
20
  onBlur?: (
@@ -22,6 +32,9 @@ declare type AllCallbacks = {
22
32
  onCheckoutSuccess?: OnCheckoutSuccess;
23
33
  onSetupPaymentMethodSuccess?: OnSetupPaymentMethodSuccess;
24
34
  onCheckoutError?: OnCheckoutError;
35
+ /**
36
+ * @deprecated - use `getAvailablePaymentMethods` and `generalSubmit` instead
37
+ */
25
38
  onPaymentRequestLoad?: (paymentRequests: PRStatuses) => void;
26
39
  };
27
40
 
@@ -44,14 +57,14 @@ declare type Amount = z.infer<typeof Amount>;
44
57
 
45
58
  declare type ApplePayFlowCustomParams = {
46
59
  /**
47
- * In case of multiple processors available for ApplePay, the preferredProcessor setting will
60
+ * In case of multiple processors available for ApplePay, the processor setting will
48
61
  * determine which processor to use.
49
- * If `preferredProcessor` is not set or is not available, the first available processor will be used
62
+ * If `processor` is not set or is not available, the first available processor will be used
50
63
  *
51
64
  * **Note**: this processor choice is for the whole process of showing PaymentRequest UI, verification and charging.
52
65
  * It won't perform fallback processor charging when payment failed.
53
66
  */
54
- preferredProcessor?: PaymentProcessor;
67
+ processor?: PaymentProcessor;
55
68
  overridePaymentRequest?: {
56
69
  amount: Amount;
57
70
  pending?: boolean;
@@ -316,16 +329,22 @@ declare class FormCallbacks {
316
329
  }
317
330
  }
318
331
 
332
+ declare type GeneralSubmit = typeof _generalSubmit;
333
+
334
+ declare const _generalSubmit = async <T extends SubmitMethod>(method: T, settings?: SubmitSettings<T>) => {
335
+ console.log('generalSubmit', method, settings);
336
+ };
337
+
319
338
  declare type GooglePayFlowCustomParams = {
320
339
  /**
321
- * In case of multiple processors available for GooglePay, the preferredProcessor setting will
340
+ * In case of multiple processors available for GooglePay, the processor setting will
322
341
  * determine which processor to use.
323
- * If `preferredProcessor` is not set or is not available, the first available processor will be used
342
+ * If `processor` is not set or is not available, the first available processor will be used
324
343
  *
325
344
  * **Note**: this processor choice is for the whole process of showing PaymentRequest UI, verification and charging.
326
345
  * It won't perform fallback processor charging when payment failed.
327
346
  */
328
- preferredProcessor?: PaymentProcessor;
347
+ processor?: PaymentProcessor;
329
348
  overridePaymentRequest?: {
330
349
  amount: Amount;
331
350
  pending?: boolean;
@@ -339,6 +358,12 @@ declare type GooglePayPaymentRequest =
339
358
  | ((current: PaymentDataRequest) => Partial<PaymentDataRequest>)
340
359
  | Partial<PaymentDataRequest>;
341
360
 
361
+ declare type InitAirwallexApplePayFlowResult = {
362
+ isAvailable: boolean;
363
+ isLoading: boolean;
364
+ startFlow: (customParams?: AirwallexApplePayFlowCustomParams) => Promise<void>;
365
+ };
366
+
342
367
  declare type InitApplePayFlowResult = {
343
368
  processor: PaymentProcessor;
344
369
  isAvailable: boolean;
@@ -675,6 +700,7 @@ declare const OjsFlows = {
675
700
 
676
701
  // Pockyt
677
702
  pockytPaypal: {
703
+ init: initPockytPaypalFlow,
678
704
  run: runPockytPaypalFlow,
679
705
  },
680
706
 
@@ -790,6 +816,14 @@ export declare class OpenPayForm {
790
816
  }>;
791
817
  initialize: (initParams: InitOjsFlowParams) => Promise<void>;
792
818
  };
819
+ readonly pockytPaypal: {
820
+ publisher: LoadedOncePublisher<{
821
+ isLoading: boolean;
822
+ isAvailable: boolean;
823
+ startFlow: () => Promise<void>;
824
+ }>;
825
+ initialize: (initParams: InitOjsFlowParams) => Promise<void>;
826
+ };
793
827
  readonly authorizeNetGooglePay: {
794
828
  publisher: LoadedOncePublisher<InitGooglePayFlowResult>;
795
829
  initialize: (initParams: InitOjsFlowParams) => Promise<void>;
@@ -840,49 +874,12 @@ export declare class OpenPayForm {
840
874
  */
841
875
  submitCard: (params?: CCSubmitParams) => Promise<void>;
842
876
  private checkValidFormInstance;
843
- getAvailablePaymentMethods: () => Promise<({
844
- name: string;
845
- } | {
846
- isAvailable: true;
847
- widgetProps: LoopCryptoWidgetProps;
848
- initLoopConnectProps: LoopConnectConfig;
849
- name: string;
850
- } | {
851
- isAvailable: false;
852
- name: string;
853
- } | {
854
- processor: PaymentProcessor;
855
- isAvailable: boolean;
856
- isLoading: boolean;
857
- startFlow: (customParams?: ApplePayFlowCustomParams) => Promise<void>;
858
- name: string;
859
- } | {
860
- processor: "stripe";
861
- isAvailable: true;
862
- pr: PaymentRequest_2;
863
- availableProviders: {
864
- applePay: boolean;
865
- googlePay: boolean;
866
- };
867
- startFlow: (provider: PaymentRequestProvider, params?: PaymentRequestStartParams) => Promise<void>;
868
- name: string;
869
- } | {
870
- isAvailable: true;
871
- controller: StripeLinkController;
872
- name: string;
873
- } | {
874
- isLoading: boolean;
875
- isAvailable: boolean;
876
- startFlow: () => Promise<void>;
877
- name: string;
878
- } | {
879
- processor: PaymentProcessor;
877
+ getAvailablePaymentMethods: () => Promise<{
878
+ name: SubmitMethods;
879
+ processors: PaymentProcessor[];
880
880
  isAvailable: boolean;
881
- isLoading: boolean;
882
- startFlow: (customParams?: GooglePayFlowCustomParams) => Promise<void>;
883
- name: string;
884
- })[]>;
885
- generalSubmit: <T extends SubmitMethod>(method: T, settings?: SubmitSettings<T>) => Promise<void>;
881
+ }[]>;
882
+ generalSubmit: GeneralSubmit;
886
883
  /**
887
884
  * Alias for submitCard
888
885
  */
@@ -1115,7 +1112,7 @@ declare interface PaymentMethodTokenExchangeRate {
1115
1112
  timestamp: number;
1116
1113
  }
1117
1114
 
1118
- declare const PaymentProcessor = z.enum(['stripe', 'airwallex', 'authorize_net', 'adyen']);
1115
+ declare const PaymentProcessor = z.enum(['stripe', 'airwallex', 'authorize_net', 'adyen', 'paypal', 'pockyt', 'loop']);
1119
1116
 
1120
1117
  declare type PaymentProcessor = z.infer<typeof PaymentProcessor>;
1121
1118
 
@@ -1177,15 +1174,19 @@ declare type PaypalFlowCustomParams = {
1177
1174
  };
1178
1175
 
1179
1176
  declare type ProcessorSpecificSubmitSettings<T extends SubmitMethod = SubmitMethod> = {
1180
- 'pockyt-paypal': { useRedirectFlow?: boolean };
1181
- 'airwallex-google-pay': GooglePayFlowCustomParams;
1182
- 'airwallex-apple-pay': ApplePayFlowCustomParams;
1183
- 'authorizenet-google-pay': GooglePayFlowCustomParams;
1184
- 'authorizenet-apple-pay': ApplePayFlowCustomParams;
1185
- 'adyen-google-pay': GooglePayFlowCustomParams;
1186
- 'adyen-apple-pay': ApplePayFlowCustomParams;
1187
- 'loop-crypto': LoopCryptoFlowCustomParams;
1188
- paypal: PaypalFlowCustomParams;
1177
+ [SubmitMethods.pockytPaypal]: { useRedirectFlow?: boolean };
1178
+ [SubmitMethods.applePay]: ApplePayFlowCustomParams;
1179
+ [SubmitMethods.googlePay]: GooglePayFlowCustomParams;
1180
+ [SubmitMethods.loopCrypto]: LoopCryptoFlowCustomParams;
1181
+ [SubmitMethods.paypal]: PaypalFlowCustomParams;
1182
+ // TODO: The following methods are deprecated and will be removed in the future.
1183
+ // Use googlePay/applePay instead
1184
+ [SubmitMethods.airwallexGooglePay]: ApplePayFlowCustomParams;
1185
+ [SubmitMethods.airwallexApplePay]: InitAirwallexApplePayFlowResult;
1186
+ [SubmitMethods.authorizenetGooglePay]: GooglePayFlowCustomParams;
1187
+ [SubmitMethods.authorizenetApplePay]: ApplePayFlowCustomParams;
1188
+ [SubmitMethods.adyenGooglePay]: GooglePayFlowCustomParams;
1189
+ [SubmitMethods.adyenApplePay]: ApplePayFlowCustomParams;
1189
1190
  }[T];
1190
1191
 
1191
1192
  declare type PRStatuses = Record<PaymentRequestProvider, PaymentRequestStatus>;
@@ -1206,20 +1207,41 @@ declare type StripeLinkController = {
1206
1207
  waitForButtonToMount: () => Promise<HTMLElement>;
1207
1208
  };
1208
1209
 
1209
- export declare const SubmitMethod = z.nativeEnum(SubmitMethods);
1210
+ declare const SubmitMethod = z.nativeEnum(SubmitMethods);
1210
1211
 
1211
- export declare type SubmitMethod = z.infer<typeof SubmitMethod>;
1212
+ declare type SubmitMethod = z.infer<typeof SubmitMethod>;
1212
1213
 
1213
1214
  export declare enum SubmitMethods {
1214
1215
  pockytPaypal = 'pockyt-paypal',
1216
+ applePay = 'apple-pay',
1217
+ googlePay = 'google-pay',
1218
+ loopCrypto = 'loop-crypto',
1219
+ paypal = 'paypal',
1220
+ // TODO: The following methods are deprecated and will be removed in the future.
1221
+ /**
1222
+ * @deprecated Use googlePay instead
1223
+ */
1215
1224
  airwallexGooglePay = 'airwallex-google-pay',
1225
+ /**
1226
+ * @deprecated Use googlePay instead
1227
+ */
1216
1228
  airwallexApplePay = 'airwallex-apple-pay',
1229
+ /**
1230
+ * @deprecated Use googlePay instead
1231
+ */
1217
1232
  authorizenetGooglePay = 'authorizenet-google-pay',
1233
+ /**
1234
+ * @deprecated Use applePay instead
1235
+ */
1218
1236
  authorizenetApplePay = 'authorizenet-apple-pay',
1237
+ /**
1238
+ * @deprecated Use googlePay instead
1239
+ */
1219
1240
  adyenGooglePay = 'adyen-google-pay',
1241
+ /**
1242
+ * @deprecated Use applePay instead
1243
+ */
1220
1244
  adyenApplePay = 'adyen-apple-pay',
1221
- loopCrypto = 'loop-crypto',
1222
- paypal = 'paypal',
1223
1245
  }
1224
1246
 
1225
1247
  export declare type SubmitSettings<T extends SubmitMethod = SubmitMethod> = ProcessorSpecificSubmitSettings<T> &
package/dist/index.es.js CHANGED
@@ -1,11 +1,10 @@
1
- import { F as i, O as r, l as p, m as s } from "./index-CM28ZKY-.js";
1
+ import { F as e, O as i, l as p } from "./index-Ca030TDy.js";
2
2
  import "penpal";
3
3
  import "zod";
4
4
  import "uuid";
5
5
  export {
6
- i as FieldName,
7
- r as OpenPayForm,
8
- p as SubmitMethod,
9
- s as SubmitMethods
6
+ e as FieldName,
7
+ i as OpenPayForm,
8
+ p as SubmitMethods
10
9
  };
11
- //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiaW5kZXguZXMuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImV4cG9ydCB7IEYgYXMgRmllbGROYW1lLCBPIGFzIE9wZW5QYXlGb3JtLCBsIGFzIFN1Ym1pdE1ldGhvZCwgbSBhcyBTdWJtaXRNZXRob2RzIH0gZnJvbSAnLi9pbmRleC0hfnswMDV9fi5qcyc7XG5pbXBvcnQgJ3BlbnBhbCc7XG5pbXBvcnQgJ3pvZCc7XG5pbXBvcnQgJ3V1aWQnOyJdLAogICJtYXBwaW5ncyI6ICJBQUFBLFNBQWMsS0FBTEEsR0FBcUIsS0FBTEMsR0FBdUIsS0FBTEMsR0FBd0IsS0FBTEMsU0FBMEI7QUFDeEYsT0FBTztBQUNQLE9BQU87QUFDUCxPQUFPOyIsCiAgIm5hbWVzIjogWyJGIiwgIk8iLCAibCIsICJtIl0KfQo=
10
+ //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiaW5kZXguZXMuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImV4cG9ydCB7IEYgYXMgRmllbGROYW1lLCBPIGFzIE9wZW5QYXlGb3JtLCBsIGFzIFN1Ym1pdE1ldGhvZHMgfSBmcm9tICcuL2luZGV4LSF+ezAwNX1+LmpzJztcbmltcG9ydCAncGVucGFsJztcbmltcG9ydCAnem9kJztcbmltcG9ydCAndXVpZCc7Il0sCiAgIm1hcHBpbmdzIjogIkFBQUEsU0FBYyxLQUFMQSxHQUFxQixLQUFMQyxHQUF1QixLQUFMQyxTQUEwQjtBQUNyRSxPQUFPO0FBQ1AsT0FBTztBQUNQLE9BQU87IiwKICAibmFtZXMiOiBbIkYiLCAiTyIsICJsIl0KfQo=