@getopenpay/openpay-js-react 0.2.13 → 0.2.16-alpha.1b02bc3

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
@@ -70,6 +70,13 @@ declare type ApplePayFlowCustomParams = {
70
70
  defaultFieldValues?: DefaultFieldValues;
71
71
  };
72
72
 
73
+ declare enum Blockchain {
74
+ EVM = 'EVM',
75
+ SOL = 'Solana',
76
+ }
77
+
78
+ declare type BlockchainNetwork = keyof typeof Blockchain;
79
+
73
80
  export declare const CardCvcElement: FC<ElementProps>;
74
81
 
75
82
  export declare const CardElement: FC<ElementProps<typeof CardPlaceholder>>;
@@ -90,6 +97,28 @@ declare type CommonSubmitSettings = {
90
97
  defaultFieldValues?: DefaultFieldValues;
91
98
  };
92
99
 
100
+ declare interface CustomerResponse {
101
+ /**
102
+ * The unique identifier that represents the customer
103
+ * @example "1234567890abcdef"
104
+ */
105
+ customerId: string;
106
+ /**
107
+ * The external customer reference ID used to tie this customer to a customer in an external system.
108
+ * @example "1234567890abcdef"
109
+ */
110
+ customerRefId: string | null;
111
+ /**
112
+ * The payment methods configured for this customer to make payments with.
113
+ */
114
+ paymentMethods: Omit<PaymentMethodResponse, 'entityId' | 'customer' | 'dateCreated'>[];
115
+ /**
116
+ * The date the customer record was created, represented as a Unix timestamp in seconds.
117
+ * @example 1716211200
118
+ */
119
+ dateCreated: number;
120
+ }
121
+
93
122
  declare type CustomInitParams = {
94
123
  // You can put custom params for your init flows here
95
124
 
@@ -128,6 +157,8 @@ declare type CustomInitParams = {
128
157
  };
129
158
  };
130
159
 
160
+ declare type CustomStyles = string;
161
+
131
162
  declare type DefaultFieldValues = Partial<Record<FieldNameEnum, string>>;
132
163
 
133
164
  export declare type DynamicPreview = {
@@ -161,6 +192,10 @@ export declare type ElementsFormChildrenProps = {
161
192
  googlePay: InitAirwallexGooglePayFlowResult;
162
193
  applePay: InitAirwallexApplePayFlowResult;
163
194
  };
195
+ loop: {
196
+ widget: LoopCryptoWidgetProps;
197
+ config: LoopConnectConfig;
198
+ } | null;
164
199
  loaded: boolean;
165
200
  preview: DynamicPreview;
166
201
  };
@@ -217,6 +252,14 @@ declare enum ElementTypeEnum {
217
252
  CARD_CVC = 'card-cvc',
218
253
  }
219
254
 
255
+ declare enum Environment {
256
+ Local = 'local',
257
+ Development = 'development',
258
+ Staging = 'staging',
259
+ Demo = 'demo',
260
+ Production = 'production',
261
+ }
262
+
220
263
  /**
221
264
  * Expected input fields
222
265
  */
@@ -270,6 +313,62 @@ export declare type InitAirwallexGooglePayFlowResult = {
270
313
  startFlow: (customParams?: AirwallexGooglePayFlowCustomParams) => Promise<void>;
271
314
  };
272
315
 
316
+ declare interface InitFailedEvent {
317
+ type: 'initFailed';
318
+ message: string;
319
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
320
+ data: Record<string, any>;
321
+ }
322
+
323
+ declare interface InitializedEvent {
324
+ entityId: string;
325
+ }
326
+
327
+ export declare interface LoopConnectConfig {
328
+ apiKey: string;
329
+ entityId: string;
330
+ merchantId?: string;
331
+ environment?: Environment | `${Environment}`;
332
+ customStyles?: CustomStyles;
333
+ onInitialized?: (detail: InitializedEvent) => void;
334
+ onInitFailed?: (detail: InitFailedEvent) => void;
335
+ onWalletChange?: (detail: WalletChangeEvent) => void;
336
+ onNetworkChange?: (detail: NetworkChangeEvent) => void;
337
+ }
338
+
339
+ declare type LoopCryptoFlowCustomParams =
340
+ | {
341
+ customer: Omit<CustomerResponse, 'paymentMethods' | 'merchants' | 'dateCreated'>;
342
+ payin: PayInCompleteEvent;
343
+ // TODO: Move these to nonCdeFormInput prop
344
+ email?: string;
345
+ firstName?: string;
346
+ lastName?: string;
347
+ success: true;
348
+ }
349
+ | {
350
+ detail: PayInFailedEvent;
351
+ // TODO: Move these to nonCdeFormInput prop
352
+ email?: string;
353
+ firstName?: string;
354
+ lastName?: string;
355
+ success: false;
356
+ };
357
+
358
+ export declare type LoopCryptoWidgetProps = {
359
+ paymentUsdAmount: number;
360
+ suggestedAuthorizationUsdAmount: number;
361
+ subscriptionRefId?: string;
362
+ customerRefId?: string;
363
+ invoiceRefId?: string;
364
+ };
365
+
366
+ declare interface NetworkChangeEvent {
367
+ id: number;
368
+ name: string;
369
+ chain: BlockchainNetwork;
370
+ }
371
+
273
372
  declare type OnCheckoutError = (message: string, errorCode?: string) => void;
274
373
 
275
374
  declare type OnCheckoutStarted = () => void;
@@ -280,8 +379,240 @@ declare type OnSetupPaymentMethodSuccess = (paymentMethodId: string) => void;
280
379
 
281
380
  declare type OnValidationError = (field: AllFieldNames, errors: string[], elementId?: string) => void;
282
381
 
382
+ /**
383
+ * @deprecated Use interface PayInCreatedEvent for data returned from the creation of a PayIn
384
+ */
385
+ declare interface PayInCompleteEvent extends PayinResponse {}
386
+
387
+ declare enum PayInFailed {
388
+ INSUFFICIENT_BALANCE = 'insufficientBalance',
389
+ INSUFFICIENT_AUTHORIZATION = 'insufficientAuthorization',
390
+ SIGNED_MESSAGE_REQUIRED = 'signedMessageRequired',
391
+ CUSTOMER_CREATION_FAILED = 'customerCreationFailed',
392
+ PAYMENT_FAILED = 'paymentFailed',
393
+ TRANSACTION_FAILED = 'transactionFailed',
394
+ }
395
+
396
+ declare interface PayInFailedData {
397
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
398
+ error: Record<string, any> | undefined;
399
+ }
400
+
401
+ declare interface PayInFailedEvent {
402
+ type: PayInFailed;
403
+ message: string;
404
+ data: PayInFailedData;
405
+ }
406
+
407
+ declare interface PayinPaymentMethodResponse
408
+ extends Omit<PaymentMethodResponse, 'merchantId' | 'entityId' | 'dateCreated'> {
409
+ /**
410
+ * The status of the payment method
411
+ */
412
+ status: 'ok' | 'insufficient_balance' | 'insufficient_authorization' | 'insufficient_balance_authorization';
413
+ }
414
+
415
+ declare interface PayinPayoutDestinationResponse
416
+ extends Omit<PayoutDestinationResponse, 'merchantId' | 'entityId' | 'isDefault' | 'dateCreated'> {}
417
+
418
+ declare interface PayinResponse {
419
+ /**
420
+ * The unique identifier for the payin
421
+ * @example "8f47c6e9-2b3a-4d5c-9f8e-1a2b3c4d5e6f"
422
+ */
423
+ payinId: string;
424
+ /**
425
+ * The unique identifier of the merchant this payin is associated with
426
+ * @example "67e55044-10b1-426f-9247-bb680e5fe0c8"
427
+ */
428
+ merchantId: string;
429
+ /**
430
+ * The amount to be paid, specified in either fiat or crypto based on amountType
431
+ * @example "100.00"
432
+ */
433
+ amount: string;
434
+ /**
435
+ * The type of the amount, either "fiat" or "token"
436
+ * @example "fiat"
437
+ */
438
+ amountType: 'fiat' | 'token';
439
+ /**
440
+ * The date the payment will take place, represented as a Unix timestamp
441
+ * @example 1716211200
442
+ */
443
+ billDate: number;
444
+ /**
445
+ * The unique invoice identifier representing this payin transaction
446
+ * @example "1234567890abcdef"
447
+ */
448
+ invoiceId: string;
449
+ /**
450
+ * (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.
451
+ * @example "Payment for Developer plan"
452
+ */
453
+ description: string | null;
454
+ /**
455
+ * (Optional) The external invoice ID used to tie this payin to an invoice in an external system
456
+ * @example "1234567890abcdef"
457
+ */
458
+ externalInvoiceRef: string | null;
459
+ /**
460
+ * The type of the payin, either "subscription" or "invoice"
461
+ * @example "subscription"
462
+ */
463
+ payinType: 'subscription' | 'invoice';
464
+ /**
465
+ * The status of the payin, can be "scheduled", "pending", "completed", or "failed"
466
+ * @example "scheduled"
467
+ */
468
+ payinStatus: 'scheduled' | 'pending' | 'completed' | 'failed' | 'canceled' | 'uncollectible' | 'draft';
469
+ /**
470
+ * The transaction details for the payin
471
+ */
472
+ transaction: PayinTransactionResponse | null;
473
+ /**
474
+ * The payment method used for this payin
475
+ */
476
+ paymentMethod: PayinPaymentMethodResponse;
477
+ /**
478
+ * The payout destination used for this payin
479
+ */
480
+ payoutDestination: PayinPayoutDestinationResponse;
481
+ /**
482
+ * The date the payin record was created, represented as a Unix timestamp in seconds.
483
+ * @example 1716211200
484
+ */
485
+ dateCreated: number;
486
+ }
487
+
488
+ export declare enum PayInState {
489
+ IDLE = 'idle',
490
+ CONFIRMING_BALANCE = 'confirmingBalance',
491
+ CONFIRMING_AUTHORIZATION = 'confirmingAuthorization',
492
+ UPDATING_AUTHORIZATION = 'updatingAuthorization',
493
+ SIGNING_MESSAGE = 'signingMessage',
494
+ CREATING_CUSTOMER = 'creatingCustomer',
495
+ /**
496
+ * @deprecated State CREATING_PAYMENT is used when a payment is awaiting creation confirmation
497
+ */
498
+ PROCESSING_PAYMENT = 'processingPayment',
499
+ CREATING_PAYMENT = 'creatingPayment',
500
+ CONFIRMING_PAYMENT = 'confirmingPayment',
501
+ COMPLETE = 'complete',
502
+ }
503
+
504
+ declare interface PayinTransactionResponse {
505
+ /**
506
+ * The transaction id generated by the blockchain network when the transaction is processed
507
+ * @example "0xcfdfbb523c079e47e9a17ba236fa978257d4331e96ec43997e974b97522047fe"
508
+ */
509
+ transactionId: string;
510
+ /**
511
+ * The URL to view this transaction in a blockchain explorer. The specific explorer URL depends on the blockchain network the transaction was processed on
512
+ * @example "https://etherscan.io/tx/0xcfdfbb523c079e47e9a17ba236fa978257d4331e96ec43997e974b97522047fe"
513
+ */
514
+ transactionUrl: string;
515
+ /**
516
+ * 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"
517
+ * @example "1990000"
518
+ */
519
+ amountTransferred: string | null;
520
+ /**
521
+ * The exchange rate that was applied when the payment was processed on the blockchain
522
+ */
523
+ exchangeRate: PaymentMethodTokenExchangeRate | null;
524
+ }
525
+
283
526
  declare type PaymentDataRequest = google.payments.api.PaymentDataRequest;
284
527
 
528
+ declare interface PaymentMethodPreAuthorization {
529
+ /**
530
+ * The balance of the payment method formatted in the token amount
531
+ * @example "100"
532
+ */
533
+ balance: string;
534
+ /**
535
+ * The authorization amount of the payment method formatted in the token amount
536
+ * @example "49.9"
537
+ */
538
+ authorization: string;
539
+ }
540
+
541
+ declare interface PaymentMethodResponse {
542
+ /**
543
+ * The unique identifier for the payment method
544
+ * @example "1234567890abcdef"
545
+ */
546
+ paymentMethodId: string;
547
+ /**
548
+ * The unique identifier of the merchant this payment method is associated with
549
+ * @example "67e55044-10b1-426f-9247-bb680e5fe0c8"
550
+ */
551
+ merchantId: string;
552
+ /**
553
+ * The name of the payment method
554
+ * @example "My Crypto Wallet"
555
+ */
556
+ paymentMethodName: string;
557
+ /**
558
+ * The customers that are associated with the payment method
559
+ */
560
+ customer: Omit<CustomerResponse, 'paymentMethods' | 'merchants' | 'dateCreated'>;
561
+ /**
562
+ * The blockchain network ID the payment method is associated with
563
+ * @example 1
564
+ */
565
+ networkId: number;
566
+ /**
567
+ * The blockchain wallet address where payments will be sent from
568
+ * @example "0x1234567890abcdef"
569
+ */
570
+ walletAddress: string;
571
+ /**
572
+ * Whether the payment method is the default payment method for wallet address
573
+ * @example true
574
+ */
575
+ isDefault: boolean;
576
+ /**
577
+ * The token associated with the payment method
578
+ */
579
+ token: PaymentMethodToken;
580
+ /**
581
+ * The status of the payment method, including the wallet's balance and authorization status
582
+ */
583
+ preAuthorization: PaymentMethodPreAuthorization | null;
584
+ /**
585
+ * The date the payment method record was created, represented as a Unix timestamp in seconds.
586
+ * @example 1716211200
587
+ */
588
+ dateCreated: number;
589
+ }
590
+
591
+ declare interface PaymentMethodToken extends Omit<TokenResponse, 'networkId'> {
592
+ /**
593
+ * The exchange rate of the token
594
+ */
595
+ exchangeRates: PaymentMethodTokenExchangeRate[];
596
+ }
597
+
598
+ declare interface PaymentMethodTokenExchangeRate {
599
+ /**
600
+ * The currency code. Only "USD" is supported at this time.
601
+ * @example "USD"
602
+ */
603
+ currency: string;
604
+ /**
605
+ * 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
606
+ * @example "10000"
607
+ */
608
+ price: string;
609
+ /**
610
+ * The Unix timestamp (in seconds) when this exchange rate was last updated
611
+ * @example 1715731200
612
+ */
613
+ timestamp: number;
614
+ }
615
+
285
616
  declare const PaymentProcessor = z.enum(['stripe', 'airwallex', 'authorize_net']);
286
617
 
287
618
  declare type PaymentProcessor = z.infer<typeof PaymentProcessor>;
@@ -304,12 +635,46 @@ export declare type PaymentRequestStatus = {
304
635
  startFlow: (params?: PaymentRequestStartParams) => Promise<void>;
305
636
  };
306
637
 
638
+ declare interface PayoutDestinationResponse {
639
+ /**
640
+ * The unique identifier for the payout destination
641
+ * @example "1234567890abcdef"
642
+ */
643
+ payoutDestinationId: string;
644
+ /**
645
+ * The merchant ID associated with this payout destination
646
+ * @example "1234567890abcdef"
647
+ */
648
+ merchantId: string;
649
+ /**
650
+ * The blockchain network ID the payout destination is associated with
651
+ * @example 1
652
+ */
653
+ networkId: number;
654
+ /**
655
+ * The blockchain wallet address where payments will be sent. Must be a valid address for the specified network.
656
+ * @example "0x1234567890abcdef"
657
+ */
658
+ walletAddress: string;
659
+ /**
660
+ * Whether the payout destination is the default payout destination for the merchant.
661
+ * @example true
662
+ */
663
+ isDefault: boolean;
664
+ /**
665
+ * The date the payout destination record was created, represented as a Unix timestamp in seconds.
666
+ * @example 1716211200
667
+ */
668
+ dateCreated: number;
669
+ }
670
+
307
671
  declare type ProcessorSpecificSubmitSettings<T extends SubmitMethod = SubmitMethod> = {
308
672
  'pockyt-paypal': { useRedirectFlow?: boolean };
309
673
  'airwallex-google-pay': GooglePayFlowCustomParams;
310
674
  'airwallex-apple-pay': ApplePayFlowCustomParams;
311
675
  'authorizenet-google-pay': GooglePayFlowCustomParams;
312
676
  'authorizenet-apple-pay': ApplePayFlowCustomParams;
677
+ 'loop-crypto': LoopCryptoFlowCustomParams;
313
678
  }[T];
314
679
 
315
680
  declare type PRStatuses = Record<PaymentRequestProvider, PaymentRequestStatus>;
@@ -324,9 +689,42 @@ declare const SubmitMethod = z.nativeEnum(SubmitMethods);
324
689
 
325
690
  declare type SubmitMethod = z.infer<typeof SubmitMethod>;
326
691
 
327
- declare type SubmitSettings<T extends SubmitMethod = SubmitMethod> = ProcessorSpecificSubmitSettings<T> &
692
+ export declare type SubmitSettings<T extends SubmitMethod = SubmitMethod> = ProcessorSpecificSubmitSettings<T> &
328
693
  CommonSubmitSettings;
329
694
 
695
+ declare interface TokenResponse {
696
+ /**
697
+ * The unique identifier for the token used by the payment type.
698
+ * @example "123e4567-e89b-12d3-a456-426614174000"
699
+ */
700
+ tokenId: string;
701
+ /**
702
+ * The blockchain network ID the token is associated with
703
+ * @example 1
704
+ */
705
+ networkId: number;
706
+ /**
707
+ * The token symbol that identifies the token on the blockchain network
708
+ * @example "USDC"
709
+ */
710
+ symbol: string;
711
+ /**
712
+ * The token contract address for the payment type
713
+ * @example "0x1234567890abcdef"
714
+ */
715
+ address: string;
716
+ /**
717
+ * The number of decimal places used to represent token amounts
718
+ * @example 6
719
+ */
720
+ decimals: number;
721
+ }
722
+
330
723
  export declare const useOpenPayElements: () => ElementsContextValue;
331
724
 
725
+ declare interface WalletChangeEvent {
726
+ address: string;
727
+ ens: string | undefined;
728
+ }
729
+
332
730
  export { }