@getopenpay/openpay-js 0.2.12 → 0.2.13-alpha.16b22e4

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/index.d.ts CHANGED
@@ -52,6 +52,13 @@ declare type ApplePayFlowCustomParams = {
52
52
  defaultFieldValues?: DefaultFieldValues;
53
53
  };
54
54
 
55
+ declare enum Blockchain {
56
+ EVM = 'EVM',
57
+ SOL = 'Solana',
58
+ }
59
+
60
+ declare type BlockchainNetwork = keyof typeof Blockchain;
61
+
55
62
  declare type CdeConnection = {
56
63
  send: (data: CdeMessage) => Promise<unknown>;
57
64
  };
@@ -79,6 +86,28 @@ export declare type Config = ElementsFormProps & AllCallbacks;
79
86
 
80
87
  declare type CurrentStatus<T> = InitialStatus | SuccessStatus<T> | ErrorStatus;
81
88
 
89
+ declare interface CustomerResponse {
90
+ /**
91
+ * The unique identifier that represents the customer
92
+ * @example "1234567890abcdef"
93
+ */
94
+ customerId: string;
95
+ /**
96
+ * The external customer reference ID used to tie this customer to a customer in an external system.
97
+ * @example "1234567890abcdef"
98
+ */
99
+ customerRefId: string | null;
100
+ /**
101
+ * The payment methods configured for this customer to make payments with.
102
+ */
103
+ paymentMethods: Omit<PaymentMethodResponse, 'entityId' | 'customer' | 'dateCreated'>[];
104
+ /**
105
+ * The date the customer record was created, represented as a Unix timestamp in seconds.
106
+ * @example 1716211200
107
+ */
108
+ dateCreated: number;
109
+ }
110
+
82
111
  declare type CustomInitParams = {
83
112
  // You can put custom params for your init flows here
84
113
 
@@ -117,6 +146,8 @@ declare type CustomInitParams = {
117
146
  };
118
147
  };
119
148
 
149
+ declare type CustomStyles = string;
150
+
120
151
  declare type DefaultFieldValues = Partial<Record<FieldNameEnum, string>>;
121
152
 
122
153
  declare type ElementProps<PlaceholderType extends z.ZodTypeAny = z.ZodString> = {
@@ -161,6 +192,14 @@ declare enum ElementTypeEnum {
161
192
 
162
193
  declare type ElementTypeEnumValue = ElementTypeEnum[keyof ElementTypeEnum];
163
194
 
195
+ declare enum Environment {
196
+ Local = 'local',
197
+ Development = 'development',
198
+ Staging = 'staging',
199
+ Demo = 'demo',
200
+ Production = 'production',
201
+ }
202
+
164
203
  declare type ErrorStatus = {
165
204
  status: 'error';
166
205
  isSuccess: false;
@@ -260,6 +299,13 @@ declare type InitApplePayFlowResult = {
260
299
  startFlow: (customParams?: ApplePayFlowCustomParams) => Promise<void>;
261
300
  };
262
301
 
302
+ declare interface InitFailedEvent {
303
+ type: 'initFailed';
304
+ message: string;
305
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
306
+ data: Record<string, any>;
307
+ }
308
+
263
309
  declare type InitGooglePayFlowResult = {
264
310
  processor: PaymentProcessor;
265
311
  isAvailable: boolean;
@@ -267,11 +313,25 @@ declare type InitGooglePayFlowResult = {
267
313
  startFlow: (customParams?: GooglePayFlowCustomParams) => Promise<void>;
268
314
  };
269
315
 
316
+ declare interface InitializedEvent {
317
+ entityId: string;
318
+ }
319
+
270
320
  declare type InitialStatus = {
271
321
  status: 'initial';
272
322
  isSuccess: false;
273
323
  };
274
324
 
325
+ declare type InitLoopCryptoFlowSuccess =
326
+ | {
327
+ isAvailable: true;
328
+ widgetProps: LoopCryptoWidgetProps;
329
+ initLoopConnectProps: LoopConnectConfig;
330
+ }
331
+ | {
332
+ isAvailable: false;
333
+ };
334
+
275
335
  declare type InitOjsFlow<T extends InitOjsFlowResult> = (params: InitOjsFlowParams) => Promise<T>;
276
336
 
277
337
  declare type InitOjsFlowParams = {
@@ -419,6 +479,51 @@ declare class LoadedOncePublisher<T> {
419
479
  };
420
480
  }
421
481
 
482
+ declare interface LoopConnectConfig {
483
+ apiKey: string;
484
+ entityId: string;
485
+ merchantId?: string;
486
+ environment?: Environment | `${Environment}`;
487
+ customStyles?: CustomStyles;
488
+ onInitialized?: (detail: InitializedEvent) => void;
489
+ onInitFailed?: (detail: InitFailedEvent) => void;
490
+ onWalletChange?: (detail: WalletChangeEvent) => void;
491
+ onNetworkChange?: (detail: NetworkChangeEvent) => void;
492
+ }
493
+
494
+ declare type LoopCryptoFlowCustomParams =
495
+ | {
496
+ customer: Omit<CustomerResponse, 'paymentMethods' | 'merchants' | 'dateCreated'>;
497
+ payin: PayInCompleteEvent;
498
+ // TODO: Move these to nonCdeFormInput prop
499
+ email?: string;
500
+ firstName?: string;
501
+ lastName?: string;
502
+ success: true;
503
+ }
504
+ | {
505
+ detail: PayInFailedEvent;
506
+ // TODO: Move these to nonCdeFormInput prop
507
+ email?: string;
508
+ firstName?: string;
509
+ lastName?: string;
510
+ success: false;
511
+ };
512
+
513
+ declare type LoopCryptoWidgetProps = {
514
+ paymentUsdAmount: number;
515
+ suggestedAuthorizationUsdAmount: number;
516
+ subscriptionRefId?: string;
517
+ customerRefId?: string;
518
+ invoiceRefId?: string;
519
+ };
520
+
521
+ declare interface NetworkChangeEvent {
522
+ id: number;
523
+ name: string;
524
+ chain: BlockchainNetwork;
525
+ }
526
+
422
527
  declare type OjsContext = {
423
528
  /**
424
529
  * The secure token for the checkout session.
@@ -529,6 +634,12 @@ declare const OjsFlows = {
529
634
  run: runAirwallexApplePayFlow,
530
635
  },
531
636
 
637
+ // Loop
638
+ loopCrypto: {
639
+ init: initLoopFlow,
640
+ run: runLoopFlow,
641
+ },
642
+
532
643
  authorizeNetApplePay: {
533
644
  init: initAuthnetApplePayFlow,
534
645
  run: runAuthnetApplePayFlow,
@@ -589,6 +700,10 @@ export declare class OpenPayForm {
589
700
  publisher: LoadedOncePublisher<InitApplePayFlowResult>;
590
701
  initialize: (initParams: InitOjsFlowParams) => Promise<void>;
591
702
  };
703
+ readonly loop: {
704
+ publisher: LoadedOncePublisher<InitLoopCryptoFlowSuccess>;
705
+ initialize: (initParams: InitOjsFlowParams) => Promise<void>;
706
+ };
592
707
  readonly authorizeNetGooglePay: {
593
708
  publisher: LoadedOncePublisher<InitGooglePayFlowResult>;
594
709
  initialize: (initParams: InitOjsFlowParams) => Promise<void>;
@@ -659,6 +774,11 @@ export declare class OpenPayForm {
659
774
  } | {
660
775
  isAvailable: false;
661
776
  name: string;
777
+ } | {
778
+ isAvailable: true;
779
+ widgetProps: LoopCryptoWidgetProps;
780
+ initLoopConnectProps: LoopConnectConfig;
781
+ name: string;
662
782
  })[] | undefined;
663
783
  generalSubmit: <T extends SubmitMethod>(method: T, settings?: SubmitSettings<T>) => Promise<void> | undefined;
664
784
  /**
@@ -672,8 +792,224 @@ export declare class OpenPayForm {
672
792
  updateCallbacks: (newCallbacks: AllCallbacks) => void;
673
793
  }
674
794
 
795
+ /**
796
+ * @deprecated Use interface PayInCreatedEvent for data returned from the creation of a PayIn
797
+ */
798
+ declare interface PayInCompleteEvent extends PayinResponse {}
799
+
800
+ declare enum PayInFailed {
801
+ INSUFFICIENT_BALANCE = 'insufficientBalance',
802
+ INSUFFICIENT_AUTHORIZATION = 'insufficientAuthorization',
803
+ SIGNED_MESSAGE_REQUIRED = 'signedMessageRequired',
804
+ CUSTOMER_CREATION_FAILED = 'customerCreationFailed',
805
+ PAYMENT_FAILED = 'paymentFailed',
806
+ TRANSACTION_FAILED = 'transactionFailed',
807
+ }
808
+
809
+ declare interface PayInFailedData {
810
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
811
+ error: Record<string, any> | undefined;
812
+ }
813
+
814
+ declare interface PayInFailedEvent {
815
+ type: PayInFailed;
816
+ message: string;
817
+ data: PayInFailedData;
818
+ }
819
+
820
+ declare interface PayinPaymentMethodResponse
821
+ extends Omit<PaymentMethodResponse, 'merchantId' | 'entityId' | 'dateCreated'> {
822
+ /**
823
+ * The status of the payment method
824
+ */
825
+ status: 'ok' | 'insufficient_balance' | 'insufficient_authorization' | 'insufficient_balance_authorization';
826
+ }
827
+
828
+ declare interface PayinPayoutDestinationResponse
829
+ extends Omit<PayoutDestinationResponse, 'merchantId' | 'entityId' | 'isDefault' | 'dateCreated'> {}
830
+
831
+ declare interface PayinResponse {
832
+ /**
833
+ * The unique identifier for the payin
834
+ * @example "8f47c6e9-2b3a-4d5c-9f8e-1a2b3c4d5e6f"
835
+ */
836
+ payinId: string;
837
+ /**
838
+ * The unique identifier of the merchant this payin is associated with
839
+ * @example "67e55044-10b1-426f-9247-bb680e5fe0c8"
840
+ */
841
+ merchantId: string;
842
+ /**
843
+ * The amount to be paid, specified in either fiat or crypto based on amountType
844
+ * @example "100.00"
845
+ */
846
+ amount: string;
847
+ /**
848
+ * The type of the amount, either "fiat" or "token"
849
+ * @example "fiat"
850
+ */
851
+ amountType: 'fiat' | 'token';
852
+ /**
853
+ * The date the payment will take place, represented as a Unix timestamp
854
+ * @example 1716211200
855
+ */
856
+ billDate: number;
857
+ /**
858
+ * The unique invoice identifier representing this payin transaction
859
+ * @example "1234567890abcdef"
860
+ */
861
+ invoiceId: string;
862
+ /**
863
+ * (Optional) A description or note that provides additional context about this payin. This can be used to help identify or provide details about the payment for internal reference or customer communications.
864
+ * @example "Payment for Developer plan"
865
+ */
866
+ description: string | null;
867
+ /**
868
+ * (Optional) The external invoice ID used to tie this payin to an invoice in an external system
869
+ * @example "1234567890abcdef"
870
+ */
871
+ externalInvoiceRef: string | null;
872
+ /**
873
+ * The type of the payin, either "subscription" or "invoice"
874
+ * @example "subscription"
875
+ */
876
+ payinType: 'subscription' | 'invoice';
877
+ /**
878
+ * The status of the payin, can be "scheduled", "pending", "completed", or "failed"
879
+ * @example "scheduled"
880
+ */
881
+ payinStatus: 'scheduled' | 'pending' | 'completed' | 'failed' | 'canceled' | 'uncollectible' | 'draft';
882
+ /**
883
+ * The transaction details for the payin
884
+ */
885
+ transaction: PayinTransactionResponse | null;
886
+ /**
887
+ * The payment method used for this payin
888
+ */
889
+ paymentMethod: PayinPaymentMethodResponse;
890
+ /**
891
+ * The payout destination used for this payin
892
+ */
893
+ payoutDestination: PayinPayoutDestinationResponse;
894
+ /**
895
+ * The date the payin record was created, represented as a Unix timestamp in seconds.
896
+ * @example 1716211200
897
+ */
898
+ dateCreated: number;
899
+ }
900
+
901
+ declare interface PayinTransactionResponse {
902
+ /**
903
+ * The transaction id generated by the blockchain network when the transaction is processed
904
+ * @example "0xcfdfbb523c079e47e9a17ba236fa978257d4331e96ec43997e974b97522047fe"
905
+ */
906
+ transactionId: string;
907
+ /**
908
+ * The URL to view this transaction in a blockchain explorer. The specific explorer URL depends on the blockchain network the transaction was processed on
909
+ * @example "https://etherscan.io/tx/0xcfdfbb523c079e47e9a17ba236fa978257d4331e96ec43997e974b97522047fe"
910
+ */
911
+ transactionUrl: string;
912
+ /**
913
+ * The actual token amount that was transferred including all decimal places. For example - an amount of 1.99 USDC will result in a `amountTransferred` of "1990000"
914
+ * @example "1990000"
915
+ */
916
+ amountTransferred: string | null;
917
+ /**
918
+ * The exchange rate that was applied when the payment was processed on the blockchain
919
+ */
920
+ exchangeRate: PaymentMethodTokenExchangeRate | null;
921
+ }
922
+
675
923
  declare type PaymentDataRequest = google.payments.api.PaymentDataRequest;
676
924
 
925
+ declare interface PaymentMethodPreAuthorization {
926
+ /**
927
+ * The balance of the payment method formatted in the token amount
928
+ * @example "100"
929
+ */
930
+ balance: string;
931
+ /**
932
+ * The authorization amount of the payment method formatted in the token amount
933
+ * @example "49.9"
934
+ */
935
+ authorization: string;
936
+ }
937
+
938
+ declare interface PaymentMethodResponse {
939
+ /**
940
+ * The unique identifier for the payment method
941
+ * @example "1234567890abcdef"
942
+ */
943
+ paymentMethodId: string;
944
+ /**
945
+ * The unique identifier of the merchant this payment method is associated with
946
+ * @example "67e55044-10b1-426f-9247-bb680e5fe0c8"
947
+ */
948
+ merchantId: string;
949
+ /**
950
+ * The name of the payment method
951
+ * @example "My Crypto Wallet"
952
+ */
953
+ paymentMethodName: string;
954
+ /**
955
+ * The customers that are associated with the payment method
956
+ */
957
+ customer: Omit<CustomerResponse, 'paymentMethods' | 'merchants' | 'dateCreated'>;
958
+ /**
959
+ * The blockchain network ID the payment method is associated with
960
+ * @example 1
961
+ */
962
+ networkId: number;
963
+ /**
964
+ * The blockchain wallet address where payments will be sent from
965
+ * @example "0x1234567890abcdef"
966
+ */
967
+ walletAddress: string;
968
+ /**
969
+ * Whether the payment method is the default payment method for wallet address
970
+ * @example true
971
+ */
972
+ isDefault: boolean;
973
+ /**
974
+ * The token associated with the payment method
975
+ */
976
+ token: PaymentMethodToken;
977
+ /**
978
+ * The status of the payment method, including the wallet's balance and authorization status
979
+ */
980
+ preAuthorization: PaymentMethodPreAuthorization | null;
981
+ /**
982
+ * The date the payment method record was created, represented as a Unix timestamp in seconds.
983
+ * @example 1716211200
984
+ */
985
+ dateCreated: number;
986
+ }
987
+
988
+ declare interface PaymentMethodToken extends Omit<TokenResponse, 'networkId'> {
989
+ /**
990
+ * The exchange rate of the token
991
+ */
992
+ exchangeRates: PaymentMethodTokenExchangeRate[];
993
+ }
994
+
995
+ declare interface PaymentMethodTokenExchangeRate {
996
+ /**
997
+ * The currency code. Only "USD" is supported at this time.
998
+ * @example "USD"
999
+ */
1000
+ currency: string;
1001
+ /**
1002
+ * The price of the token in the specified currency code. Accurate to 4 decimal places, e.g. a price of "1.9900" represents $1.99
1003
+ * @example "10000"
1004
+ */
1005
+ price: string;
1006
+ /**
1007
+ * The Unix timestamp (in seconds) when this exchange rate was last updated
1008
+ * @example 1715731200
1009
+ */
1010
+ timestamp: number;
1011
+ }
1012
+
677
1013
  declare const PaymentProcessor = z.enum(['stripe', 'airwallex', 'authorize_net']);
678
1014
 
679
1015
  declare type PaymentProcessor = z.infer<typeof PaymentProcessor>;
@@ -696,12 +1032,46 @@ declare type PaymentRequestStatus = {
696
1032
  startFlow: (params?: PaymentRequestStartParams) => Promise<void>;
697
1033
  };
698
1034
 
1035
+ declare interface PayoutDestinationResponse {
1036
+ /**
1037
+ * The unique identifier for the payout destination
1038
+ * @example "1234567890abcdef"
1039
+ */
1040
+ payoutDestinationId: string;
1041
+ /**
1042
+ * The merchant ID associated with this payout destination
1043
+ * @example "1234567890abcdef"
1044
+ */
1045
+ merchantId: string;
1046
+ /**
1047
+ * The blockchain network ID the payout destination is associated with
1048
+ * @example 1
1049
+ */
1050
+ networkId: number;
1051
+ /**
1052
+ * The blockchain wallet address where payments will be sent. Must be a valid address for the specified network.
1053
+ * @example "0x1234567890abcdef"
1054
+ */
1055
+ walletAddress: string;
1056
+ /**
1057
+ * Whether the payout destination is the default payout destination for the merchant.
1058
+ * @example true
1059
+ */
1060
+ isDefault: boolean;
1061
+ /**
1062
+ * The date the payout destination record was created, represented as a Unix timestamp in seconds.
1063
+ * @example 1716211200
1064
+ */
1065
+ dateCreated: number;
1066
+ }
1067
+
699
1068
  declare type ProcessorSpecificSubmitSettings<T extends SubmitMethod = SubmitMethod> = {
700
1069
  'pockyt-paypal': { useRedirectFlow?: boolean };
701
1070
  'airwallex-google-pay': GooglePayFlowCustomParams;
702
1071
  'airwallex-apple-pay': ApplePayFlowCustomParams;
703
1072
  'authorizenet-google-pay': GooglePayFlowCustomParams;
704
1073
  'authorizenet-apple-pay': ApplePayFlowCustomParams;
1074
+ 'loop-crypto': LoopCryptoFlowCustomParams;
705
1075
  }[T];
706
1076
 
707
1077
  declare type PRStatuses = Record<PaymentRequestProvider, PaymentRequestStatus>;
@@ -732,6 +1102,7 @@ export declare enum SubmitMethods {
732
1102
  airwallexApplePay = 'airwallex-apple-pay',
733
1103
  authorizenetGooglePay = 'authorizenet-google-pay',
734
1104
  authorizenetApplePay = 'authorizenet-apple-pay',
1105
+ loopCrypto = 'loop-crypto',
735
1106
  }
736
1107
 
737
1108
  export declare type SubmitSettings<T extends SubmitMethod = SubmitMethod> = ProcessorSpecificSubmitSettings<T> &
@@ -743,4 +1114,37 @@ declare type SuccessStatus<T> = {
743
1114
  loadedValue: T;
744
1115
  };
745
1116
 
1117
+ declare interface TokenResponse {
1118
+ /**
1119
+ * The unique identifier for the token used by the payment type.
1120
+ * @example "123e4567-e89b-12d3-a456-426614174000"
1121
+ */
1122
+ tokenId: string;
1123
+ /**
1124
+ * The blockchain network ID the token is associated with
1125
+ * @example 1
1126
+ */
1127
+ networkId: number;
1128
+ /**
1129
+ * The token symbol that identifies the token on the blockchain network
1130
+ * @example "USDC"
1131
+ */
1132
+ symbol: string;
1133
+ /**
1134
+ * The token contract address for the payment type
1135
+ * @example "0x1234567890abcdef"
1136
+ */
1137
+ address: string;
1138
+ /**
1139
+ * The number of decimal places used to represent token amounts
1140
+ * @example 6
1141
+ */
1142
+ decimals: number;
1143
+ }
1144
+
1145
+ declare interface WalletChangeEvent {
1146
+ address: string;
1147
+ ens: string | undefined;
1148
+ }
1149
+
746
1150
  export { }