@moonpay/platform-sdk-web 1.25.0 → 1.26.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/index.d.cts CHANGED
@@ -2,6 +2,7 @@ import { ListPaymentMethodsResponse, GetQuoteParams, Quote, ListAssetsResponse,
2
2
  export { AssetStatus, GetQuoteParams, ListAssetsResponse, ListPaymentMethodsResponse, PaginationInfo, PaymentMethodConfig, PaymentMethodType, PlatformAsset, Quote, SimulateBankTransferOutcome, SimulateBankTransferParams, SimulateSenderBankAccount, StoredCardPaymentMethod, StoredPaymentMethod, Transaction, TransactionWithStages } from '@moonpay/platform-protocol/api';
3
3
  import { Customer } from '@moonpay/platform-protocol/api/customer';
4
4
  export { Customer } from '@moonpay/platform-protocol/api/customer';
5
+ export { EnterpriseQuote } from '@moonpay/platform-protocol/api/enterprise';
5
6
  export { CardResponse } from '@moonpay/platform-protocol/frames/add-card';
6
7
  import * as ApplePayFrameTypes from '@moonpay/platform-protocol/frames/apple-pay';
7
8
  export { ApplePayButtonSettings } from '@moonpay/platform-protocol/frames/apple-pay';
@@ -119,6 +120,7 @@ interface GooglePayFrame {
119
120
  setQuote(signature: string): void;
120
121
  dispose(): void;
121
122
  }
123
+ /** @deprecated Use `SetupBuyButtonOptions` with `headless: true`. */
122
124
  interface SetupBuyOptions {
123
125
  /** Quote signature from getQuote(). */
124
126
  quote: string;
@@ -129,6 +131,7 @@ interface SetupBuyOptions {
129
131
  /** Callback for buy frame lifecycle events. */
130
132
  onEvent?: (event: BuySdk.Event) => void;
131
133
  }
134
+ /** @deprecated Use `BuyButtonFrame` from `setupBuyButton({ headless: true })`. */
132
135
  interface BuyFrame {
133
136
  /** Update the quote (e.g., after expiry). */
134
137
  setQuote(signature: string): void;
@@ -145,6 +148,11 @@ interface SetupBuyButtonOptions {
145
148
  presentation?: PresentationMode;
146
149
  /** Styling for the Apple Pay button variant. Passed through to the frame, which is authoritative. */
147
150
  applePayButtonSettings?: ApplePayFrameTypes.ApplePayButtonSettings;
151
+ /**
152
+ * Run the frame hidden, with no button: it processes the quote on load, the
153
+ * way the deprecated `setupBuy` did. `container` still hosts the hidden frame.
154
+ */
155
+ headless?: boolean;
148
156
  /** Callback for buy-button frame lifecycle events. */
149
157
  onEvent?: (event: BuyButtonSdk.Event) => void;
150
158
  }
@@ -278,6 +286,7 @@ interface Client {
278
286
  * can be captured before disposal since the client token is held internally).
279
287
  */
280
288
  resetConnection(): Promise<Result<void, ResetConnectionError>>;
289
+ /** @deprecated Use `setupBuyButton({ ...options, headless: true })`. The buy frame is being removed. */
281
290
  setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, BuySdk.SetupError>>;
282
291
  setupBuyButton(options: SetupBuyButtonOptions): Promise<Result<BuyButtonFrame, BuyButtonSdk.SetupError>>;
283
292
  setupChallenge(options: SetupChallengeOptions): Promise<Result<ChallengeFrame, ChallengeSdk.SetupError>>;
@@ -334,6 +343,23 @@ interface Client {
334
343
  }, SubmitIdentityFilesError>>;
335
344
  }
336
345
  declare function createClient(options: CreateClientOptions): Client;
346
+ /** The payment frame methods available on both the standard and enterprise clients. */
347
+ type PaymentFrameMethods = Pick<Client, 'setupBuy' | 'setupBuyButton' | 'setupChallenge' | 'setupAddCard'>;
348
+ interface CreateEnterpriseClientOptions {
349
+ /** Client token from your server. Authorizes every enterprise frame. */
350
+ clientToken: string;
351
+ /** Override the frame base URL. Defaults to production. */
352
+ frameBaseUrl?: string;
353
+ /** Theme applied to every visible MoonPay frame. */
354
+ theme?: ThemeOptions;
355
+ }
356
+ /**
357
+ * The enterprise client exposes only the payment frames. Quotes, customers
358
+ * and transactions are API-driven for enterprise — call them from your server.
359
+ * For a buy without a visible button, use `setupBuyButton({ headless: true })`.
360
+ */
361
+ type EnterpriseClient = Omit<PaymentFrameMethods, 'setupBuy'>;
362
+ declare function createEnterpriseClient(options: CreateEnterpriseClientOptions): EnterpriseClient;
337
363
 
338
364
  /**
339
365
  * FrameTransport implementation for web browsers using HTMLIFrameElement
@@ -352,4 +378,4 @@ declare class IframeTransport implements FrameTransport {
352
378
  private handleMessage;
353
379
  }
354
380
 
355
- export { type AddCardFrame, type ApplePayFrame, type AuthFrame, type BuyButtonFrame, type BuyFrame, type ChallengeFrame, type Client, type ConnectFrame, type ConnectOptions, type CreateClientOptions, type CustomerExportFrame, type GetConnectionOptions, type GooglePayFrame, IframeTransport, type SetupAddCardOptions, type SetupApplePayOptions, type SetupAuthOptions, type SetupBuyButtonOptions, type SetupBuyOptions, type SetupChallengeOptions, type SetupCustomerExportOptions, type SetupGooglePayOptions, type SetupWidgetOptions, type WidgetFrame, createClient };
381
+ export { type AddCardFrame, type ApplePayFrame, type AuthFrame, type BuyButtonFrame, type BuyFrame, type ChallengeFrame, type Client, type ConnectFrame, type ConnectOptions, type CreateClientOptions, type CreateEnterpriseClientOptions, type CustomerExportFrame, type EnterpriseClient, type GetConnectionOptions, type GooglePayFrame, IframeTransport, type SetupAddCardOptions, type SetupApplePayOptions, type SetupAuthOptions, type SetupBuyButtonOptions, type SetupBuyOptions, type SetupChallengeOptions, type SetupCustomerExportOptions, type SetupGooglePayOptions, type SetupWidgetOptions, type WidgetFrame, createClient, createEnterpriseClient };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { ListPaymentMethodsResponse, GetQuoteParams, Quote, ListAssetsResponse,
2
2
  export { AssetStatus, GetQuoteParams, ListAssetsResponse, ListPaymentMethodsResponse, PaginationInfo, PaymentMethodConfig, PaymentMethodType, PlatformAsset, Quote, SimulateBankTransferOutcome, SimulateBankTransferParams, SimulateSenderBankAccount, StoredCardPaymentMethod, StoredPaymentMethod, Transaction, TransactionWithStages } from '@moonpay/platform-protocol/api';
3
3
  import { Customer } from '@moonpay/platform-protocol/api/customer';
4
4
  export { Customer } from '@moonpay/platform-protocol/api/customer';
5
+ export { EnterpriseQuote } from '@moonpay/platform-protocol/api/enterprise';
5
6
  export { CardResponse } from '@moonpay/platform-protocol/frames/add-card';
6
7
  import * as ApplePayFrameTypes from '@moonpay/platform-protocol/frames/apple-pay';
7
8
  export { ApplePayButtonSettings } from '@moonpay/platform-protocol/frames/apple-pay';
@@ -119,6 +120,7 @@ interface GooglePayFrame {
119
120
  setQuote(signature: string): void;
120
121
  dispose(): void;
121
122
  }
123
+ /** @deprecated Use `SetupBuyButtonOptions` with `headless: true`. */
122
124
  interface SetupBuyOptions {
123
125
  /** Quote signature from getQuote(). */
124
126
  quote: string;
@@ -129,6 +131,7 @@ interface SetupBuyOptions {
129
131
  /** Callback for buy frame lifecycle events. */
130
132
  onEvent?: (event: BuySdk.Event) => void;
131
133
  }
134
+ /** @deprecated Use `BuyButtonFrame` from `setupBuyButton({ headless: true })`. */
132
135
  interface BuyFrame {
133
136
  /** Update the quote (e.g., after expiry). */
134
137
  setQuote(signature: string): void;
@@ -145,6 +148,11 @@ interface SetupBuyButtonOptions {
145
148
  presentation?: PresentationMode;
146
149
  /** Styling for the Apple Pay button variant. Passed through to the frame, which is authoritative. */
147
150
  applePayButtonSettings?: ApplePayFrameTypes.ApplePayButtonSettings;
151
+ /**
152
+ * Run the frame hidden, with no button: it processes the quote on load, the
153
+ * way the deprecated `setupBuy` did. `container` still hosts the hidden frame.
154
+ */
155
+ headless?: boolean;
148
156
  /** Callback for buy-button frame lifecycle events. */
149
157
  onEvent?: (event: BuyButtonSdk.Event) => void;
150
158
  }
@@ -278,6 +286,7 @@ interface Client {
278
286
  * can be captured before disposal since the client token is held internally).
279
287
  */
280
288
  resetConnection(): Promise<Result<void, ResetConnectionError>>;
289
+ /** @deprecated Use `setupBuyButton({ ...options, headless: true })`. The buy frame is being removed. */
281
290
  setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, BuySdk.SetupError>>;
282
291
  setupBuyButton(options: SetupBuyButtonOptions): Promise<Result<BuyButtonFrame, BuyButtonSdk.SetupError>>;
283
292
  setupChallenge(options: SetupChallengeOptions): Promise<Result<ChallengeFrame, ChallengeSdk.SetupError>>;
@@ -334,6 +343,23 @@ interface Client {
334
343
  }, SubmitIdentityFilesError>>;
335
344
  }
336
345
  declare function createClient(options: CreateClientOptions): Client;
346
+ /** The payment frame methods available on both the standard and enterprise clients. */
347
+ type PaymentFrameMethods = Pick<Client, 'setupBuy' | 'setupBuyButton' | 'setupChallenge' | 'setupAddCard'>;
348
+ interface CreateEnterpriseClientOptions {
349
+ /** Client token from your server. Authorizes every enterprise frame. */
350
+ clientToken: string;
351
+ /** Override the frame base URL. Defaults to production. */
352
+ frameBaseUrl?: string;
353
+ /** Theme applied to every visible MoonPay frame. */
354
+ theme?: ThemeOptions;
355
+ }
356
+ /**
357
+ * The enterprise client exposes only the payment frames. Quotes, customers
358
+ * and transactions are API-driven for enterprise — call them from your server.
359
+ * For a buy without a visible button, use `setupBuyButton({ headless: true })`.
360
+ */
361
+ type EnterpriseClient = Omit<PaymentFrameMethods, 'setupBuy'>;
362
+ declare function createEnterpriseClient(options: CreateEnterpriseClientOptions): EnterpriseClient;
337
363
 
338
364
  /**
339
365
  * FrameTransport implementation for web browsers using HTMLIFrameElement
@@ -352,4 +378,4 @@ declare class IframeTransport implements FrameTransport {
352
378
  private handleMessage;
353
379
  }
354
380
 
355
- export { type AddCardFrame, type ApplePayFrame, type AuthFrame, type BuyButtonFrame, type BuyFrame, type ChallengeFrame, type Client, type ConnectFrame, type ConnectOptions, type CreateClientOptions, type CustomerExportFrame, type GetConnectionOptions, type GooglePayFrame, IframeTransport, type SetupAddCardOptions, type SetupApplePayOptions, type SetupAuthOptions, type SetupBuyButtonOptions, type SetupBuyOptions, type SetupChallengeOptions, type SetupCustomerExportOptions, type SetupGooglePayOptions, type SetupWidgetOptions, type WidgetFrame, createClient };
381
+ export { type AddCardFrame, type ApplePayFrame, type AuthFrame, type BuyButtonFrame, type BuyFrame, type ChallengeFrame, type Client, type ConnectFrame, type ConnectOptions, type CreateClientOptions, type CreateEnterpriseClientOptions, type CustomerExportFrame, type EnterpriseClient, type GetConnectionOptions, type GooglePayFrame, IframeTransport, type SetupAddCardOptions, type SetupApplePayOptions, type SetupAuthOptions, type SetupBuyButtonOptions, type SetupBuyOptions, type SetupChallengeOptions, type SetupCustomerExportOptions, type SetupGooglePayOptions, type SetupWidgetOptions, type WidgetFrame, createClient, createEnterpriseClient };
package/dist/index.js CHANGED
@@ -564,6 +564,99 @@ function createClient(options) {
564
564
  return ok(void 0);
565
565
  }
566
566
  }
567
+ const { setupBuy, setupBuyButton, setupChallenge, setupAddCard } = createPaymentFrameMethods({
568
+ core,
569
+ frameBaseUrl,
570
+ theme
571
+ });
572
+ async function setupCustomerExport(opts) {
573
+ const channelId = `customer-export-${crypto.randomUUID()}`;
574
+ const url = buildFrameUrl(
575
+ FRAME_PATHS.customerExport,
576
+ {
577
+ channelId,
578
+ clientToken: core.context.clientToken,
579
+ ...themeParams(theme),
580
+ ...presentationParams(opts.presentation)
581
+ },
582
+ { frameBaseUrl }
583
+ );
584
+ const transport = core.createTransport();
585
+ try {
586
+ const handle = await createFrameOrchestrator({
587
+ transport,
588
+ channelId,
589
+ url,
590
+ container: opts.container
591
+ });
592
+ handle.onMessage((msg) => {
593
+ switch (msg.kind) {
594
+ case "ready":
595
+ opts.onEvent?.({ kind: "ready" });
596
+ break;
597
+ case "complete":
598
+ opts.onEvent?.({
599
+ kind: "complete",
600
+ payload: msg.payload
601
+ });
602
+ break;
603
+ case "error":
604
+ opts.onEvent?.({
605
+ kind: "error",
606
+ payload: msg.payload
607
+ });
608
+ break;
609
+ case "close":
610
+ opts.onEvent?.({ kind: "close" });
611
+ break;
612
+ }
613
+ });
614
+ return ok({ dispose: () => handle.dispose() });
615
+ } catch (e) {
616
+ return err({
617
+ kind: "genericError",
618
+ message: e instanceof Error ? e.message : "Customer export setup failed"
619
+ });
620
+ }
621
+ }
622
+ return {
623
+ getConnection,
624
+ connect,
625
+ setupAuth,
626
+ getCredentials: () => core.getCredentials(),
627
+ getPaymentMethods: (params) => core.getPaymentMethods(params),
628
+ getQuote: (params) => core.getQuote(params),
629
+ getAssets: (params) => core.getAssets(params),
630
+ listTransactions: (params) => core.listTransactions(params),
631
+ getTransaction: (id) => core.getTransaction(id),
632
+ simulateBankTransfer: (id, params) => core.simulateBankTransfer(id, params),
633
+ deletePaymentMethod: (id) => core.deletePaymentMethod(id),
634
+ resetConnection,
635
+ setupWidget,
636
+ setupApplePay,
637
+ setupGooglePay,
638
+ setupBuy,
639
+ setupBuyButton,
640
+ setupChallenge,
641
+ setupAddCard,
642
+ setupCustomerExport,
643
+ getCustomer: (id) => core.getCustomer(id),
644
+ submitCustomerKyc: (id, body) => core.submitCustomerKyc(id, body),
645
+ getCustomerUploadUrl: (id, body) => core.getCustomerUploadUrl(id, body),
646
+ submitCustomerFiles: (id, body) => core.submitCustomerFiles(id, body),
647
+ createIdentity: (body) => core.createIdentity(body),
648
+ getIdentity: (id) => core.getIdentity(id),
649
+ updateIdentity: (id, body) => core.updateIdentity(id, body),
650
+ verifyIdentity: (id) => core.verifyIdentity(id),
651
+ getIdentityUploadUrl: (id, body) => core.getIdentityUploadUrl(id, body),
652
+ submitIdentityFiles: (id, body) => core.submitIdentityFiles(id, body)
653
+ };
654
+ }
655
+ function createPaymentFrameMethods({
656
+ core,
657
+ frameBaseUrl,
658
+ theme
659
+ }) {
567
660
  async function setupBuy(opts) {
568
661
  const channelId = `buy-${crypto.randomUUID()}`;
569
662
  const url = buildFrameUrl(
@@ -636,6 +729,7 @@ function createClient(options) {
636
729
  signature: opts.quote,
637
730
  ...opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId },
638
731
  ...opts.applePayButtonSettings && { applePayButtonSettings: opts.applePayButtonSettings },
732
+ ...opts.headless && { headless: true },
639
733
  ...themeParams(theme),
640
734
  ...presentationParams(opts.presentation)
641
735
  },
@@ -647,7 +741,8 @@ function createClient(options) {
647
741
  transport,
648
742
  channelId,
649
743
  url,
650
- container: opts.container
744
+ container: opts.container,
745
+ hidden: opts.headless
651
746
  });
652
747
  const setQuote = (signature) => {
653
748
  handle.sendMessage({
@@ -811,92 +906,26 @@ function createClient(options) {
811
906
  });
812
907
  }
813
908
  }
814
- async function setupCustomerExport(opts) {
815
- const channelId = `customer-export-${crypto.randomUUID()}`;
816
- const url = buildFrameUrl(
817
- FRAME_PATHS.customerExport,
818
- {
819
- channelId,
820
- clientToken: core.context.clientToken,
821
- ...themeParams(theme),
822
- ...presentationParams(opts.presentation)
823
- },
824
- { frameBaseUrl }
825
- );
826
- const transport = core.createTransport();
827
- try {
828
- const handle = await createFrameOrchestrator({
829
- transport,
830
- channelId,
831
- url,
832
- container: opts.container
833
- });
834
- handle.onMessage((msg) => {
835
- switch (msg.kind) {
836
- case "ready":
837
- opts.onEvent?.({ kind: "ready" });
838
- break;
839
- case "complete":
840
- opts.onEvent?.({
841
- kind: "complete",
842
- payload: msg.payload
843
- });
844
- break;
845
- case "error":
846
- opts.onEvent?.({
847
- kind: "error",
848
- payload: msg.payload
849
- });
850
- break;
851
- case "close":
852
- opts.onEvent?.({ kind: "close" });
853
- break;
854
- }
855
- });
856
- return ok({ dispose: () => handle.dispose() });
857
- } catch (e) {
858
- return err({
859
- kind: "genericError",
860
- message: e instanceof Error ? e.message : "Customer export setup failed"
861
- });
862
- }
863
- }
864
- return {
865
- getConnection,
866
- connect,
867
- setupAuth,
868
- getCredentials: () => core.getCredentials(),
869
- getPaymentMethods: (params) => core.getPaymentMethods(params),
870
- getQuote: (params) => core.getQuote(params),
871
- getAssets: (params) => core.getAssets(params),
872
- listTransactions: (params) => core.listTransactions(params),
873
- getTransaction: (id) => core.getTransaction(id),
874
- simulateBankTransfer: (id, params) => core.simulateBankTransfer(id, params),
875
- deletePaymentMethod: (id) => core.deletePaymentMethod(id),
876
- resetConnection,
877
- setupWidget,
878
- setupApplePay,
879
- setupGooglePay,
880
- setupBuy,
881
- setupBuyButton,
882
- setupChallenge,
883
- setupAddCard,
884
- setupCustomerExport,
885
- getCustomer: (id) => core.getCustomer(id),
886
- submitCustomerKyc: (id, body) => core.submitCustomerKyc(id, body),
887
- getCustomerUploadUrl: (id, body) => core.getCustomerUploadUrl(id, body),
888
- submitCustomerFiles: (id, body) => core.submitCustomerFiles(id, body),
889
- createIdentity: (body) => core.createIdentity(body),
890
- getIdentity: (id) => core.getIdentity(id),
891
- updateIdentity: (id, body) => core.updateIdentity(id, body),
892
- verifyIdentity: (id) => core.verifyIdentity(id),
893
- getIdentityUploadUrl: (id, body) => core.getIdentityUploadUrl(id, body),
894
- submitIdentityFiles: (id, body) => core.submitIdentityFiles(id, body)
895
- };
909
+ return { setupBuy, setupBuyButton, setupChallenge, setupAddCard };
910
+ }
911
+ function createEnterpriseClient(options) {
912
+ const { clientToken, frameBaseUrl, theme } = options;
913
+ const core = createClientCore({
914
+ frameBaseUrl,
915
+ createTransport: () => new IframeTransport()
916
+ });
917
+ core.context.setClientToken(clientToken);
918
+ const { setupBuyButton, setupChallenge, setupAddCard } = createPaymentFrameMethods({
919
+ core,
920
+ frameBaseUrl,
921
+ theme
922
+ });
923
+ return { setupBuyButton, setupChallenge, setupAddCard };
896
924
  }
897
925
  export {
898
926
  ConnectionStatus2 as ConnectionStatus,
899
927
  IframeTransport,
900
- createClient
928
+ createClient,
929
+ createEnterpriseClient
901
930
  };
902
931
  //# sourceMappingURL=index.js.map