@moonpay/platform-sdk-react-native 1.21.0 → 1.23.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
@@ -30,8 +30,8 @@ import * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';
30
30
  export { Event as GooglePayEvent, SetupError as SetupGooglePayError } from '@moonpay/platform-protocol/sdks/google-pay';
31
31
  import * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';
32
32
  export { SetupError as SetupWidgetError, Event as WidgetEvent } from '@moonpay/platform-protocol/sdks/widget';
33
- import { FrameTransport, FrameOptions, PresentationMode, ThemeOptions, Credentials, GetCredentialsError, ListAssetsParams, ListTransactionsParams } from '@moonpay/platform-sdk-core';
34
- export { Credentials, GetCredentialsError, ListAssetsParams, ThemeOptions } from '@moonpay/platform-sdk-core';
33
+ import { FrameTransport, FrameOptions, PresentationMode, ThemeOptions, Credentials, GetCredentialsError, GetPaymentMethodsParams, ListAssetsParams, ListTransactionsParams } from '@moonpay/platform-sdk-core';
34
+ export { Credentials, GetCredentialsError, GetPaymentMethodsParams, ListAssetsParams, ThemeOptions } from '@moonpay/platform-sdk-core';
35
35
  import { GetPaymentMethodsError, GetQuoteError, GetAssetsError, GetTransactionsError, SimulateBankTransferError, DevPlatformApiError, GetCustomerError, SubmitCustomerKycError, GetCustomerUploadUrlError, SubmitCustomerFilesError, CreateIdentityError, GetIdentityError, UpdateIdentityError, VerifyIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError } from '@moonpay/platform-protocol/api/errors';
36
36
  import { UpdateIdentityRequestBody, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, SubmitIdentityFilesRequestBody, CreateIdentityRequestBody, Identity, IdentityVerificationResponse } from '@moonpay/platform-protocol/api/identity';
37
37
  import { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';
@@ -252,7 +252,7 @@ interface RNClient {
252
252
  * Synchronous — returns a `Result`, not a Promise.
253
253
  */
254
254
  getCredentials(): Result<Credentials, GetCredentialsError>;
255
- getPaymentMethods(): Promise<Result<{
255
+ getPaymentMethods(params?: GetPaymentMethodsParams): Promise<Result<{
256
256
  data: ListPaymentMethodsResponse;
257
257
  }, GetPaymentMethodsError>>;
258
258
  getQuote(params: GetQuoteParams): Promise<Result<{
@@ -355,9 +355,16 @@ interface MoonPayApplePayButtonProps {
355
355
  style?: ViewStyle;
356
356
  /** Advanced props forwarded to the underlying react-native-webview. `ref`, `source`, and `onMessage` are SDK-managed. */
357
357
  webViewProps?: Partial<WebViewProps>;
358
+ /**
359
+ * Called with the underlying WebView instance once the button mounts, and
360
+ * with `null` on unmount. The Apple Pay button is rendered inside this
361
+ * WebView; use the instance to inject JS into the frame (e.g. via
362
+ * `injectJavaScript`).
363
+ */
364
+ onRef?: (webView: WebView | null) => void;
358
365
  }
359
366
  /** Inline Apple Pay button. Render it wherever it should appear in your layout. */
360
- declare function MoonPayApplePayButton({ quote, externalTransactionId, applePayButtonSettings, onEvent, style, webViewProps, }: MoonPayApplePayButtonProps): JSX.Element;
367
+ declare function MoonPayApplePayButton({ quote, externalTransactionId, applePayButtonSettings, onEvent, style, webViewProps, onRef, }: MoonPayApplePayButtonProps): JSX.Element;
361
368
 
362
369
  interface MoonPayAuthProps {
363
370
  /** Callback for auth lifecycle events. */
@@ -526,12 +533,17 @@ interface MoonPayFrameProps {
526
533
  * overridden; all other props (including `originWhitelist`) may be set here.
527
534
  */
528
535
  webViewProps?: Partial<WebViewProps>;
536
+ /**
537
+ * Called with the underlying WebView instance once it mounts, and with `null`
538
+ * on unmount. Lets callers inject JS into the frame (e.g. `injectJavaScript`).
539
+ */
540
+ onRef?: (webView: WebView | null) => void;
529
541
  }
530
542
  /**
531
543
  * Reusable React Native component that renders a MoonPay frame as a WebView.
532
544
  * Bridges the WebViewTransport to the actual WebView instance.
533
545
  */
534
- declare function MoonPayFrame({ transport, hidden, style, webViewProps, }: MoonPayFrameProps): JSX.Element | null;
546
+ declare function MoonPayFrame({ transport, hidden, style, webViewProps, onRef, }: MoonPayFrameProps): JSX.Element | null;
535
547
 
536
548
  interface MoonPayProviderProps {
537
549
  /**
package/dist/index.d.ts CHANGED
@@ -30,8 +30,8 @@ import * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';
30
30
  export { Event as GooglePayEvent, SetupError as SetupGooglePayError } from '@moonpay/platform-protocol/sdks/google-pay';
31
31
  import * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';
32
32
  export { SetupError as SetupWidgetError, Event as WidgetEvent } from '@moonpay/platform-protocol/sdks/widget';
33
- import { FrameTransport, FrameOptions, PresentationMode, ThemeOptions, Credentials, GetCredentialsError, ListAssetsParams, ListTransactionsParams } from '@moonpay/platform-sdk-core';
34
- export { Credentials, GetCredentialsError, ListAssetsParams, ThemeOptions } from '@moonpay/platform-sdk-core';
33
+ import { FrameTransport, FrameOptions, PresentationMode, ThemeOptions, Credentials, GetCredentialsError, GetPaymentMethodsParams, ListAssetsParams, ListTransactionsParams } from '@moonpay/platform-sdk-core';
34
+ export { Credentials, GetCredentialsError, GetPaymentMethodsParams, ListAssetsParams, ThemeOptions } from '@moonpay/platform-sdk-core';
35
35
  import { GetPaymentMethodsError, GetQuoteError, GetAssetsError, GetTransactionsError, SimulateBankTransferError, DevPlatformApiError, GetCustomerError, SubmitCustomerKycError, GetCustomerUploadUrlError, SubmitCustomerFilesError, CreateIdentityError, GetIdentityError, UpdateIdentityError, VerifyIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError } from '@moonpay/platform-protocol/api/errors';
36
36
  import { UpdateIdentityRequestBody, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, SubmitIdentityFilesRequestBody, CreateIdentityRequestBody, Identity, IdentityVerificationResponse } from '@moonpay/platform-protocol/api/identity';
37
37
  import { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';
@@ -252,7 +252,7 @@ interface RNClient {
252
252
  * Synchronous — returns a `Result`, not a Promise.
253
253
  */
254
254
  getCredentials(): Result<Credentials, GetCredentialsError>;
255
- getPaymentMethods(): Promise<Result<{
255
+ getPaymentMethods(params?: GetPaymentMethodsParams): Promise<Result<{
256
256
  data: ListPaymentMethodsResponse;
257
257
  }, GetPaymentMethodsError>>;
258
258
  getQuote(params: GetQuoteParams): Promise<Result<{
@@ -355,9 +355,16 @@ interface MoonPayApplePayButtonProps {
355
355
  style?: ViewStyle;
356
356
  /** Advanced props forwarded to the underlying react-native-webview. `ref`, `source`, and `onMessage` are SDK-managed. */
357
357
  webViewProps?: Partial<WebViewProps>;
358
+ /**
359
+ * Called with the underlying WebView instance once the button mounts, and
360
+ * with `null` on unmount. The Apple Pay button is rendered inside this
361
+ * WebView; use the instance to inject JS into the frame (e.g. via
362
+ * `injectJavaScript`).
363
+ */
364
+ onRef?: (webView: WebView | null) => void;
358
365
  }
359
366
  /** Inline Apple Pay button. Render it wherever it should appear in your layout. */
360
- declare function MoonPayApplePayButton({ quote, externalTransactionId, applePayButtonSettings, onEvent, style, webViewProps, }: MoonPayApplePayButtonProps): JSX.Element;
367
+ declare function MoonPayApplePayButton({ quote, externalTransactionId, applePayButtonSettings, onEvent, style, webViewProps, onRef, }: MoonPayApplePayButtonProps): JSX.Element;
361
368
 
362
369
  interface MoonPayAuthProps {
363
370
  /** Callback for auth lifecycle events. */
@@ -526,12 +533,17 @@ interface MoonPayFrameProps {
526
533
  * overridden; all other props (including `originWhitelist`) may be set here.
527
534
  */
528
535
  webViewProps?: Partial<WebViewProps>;
536
+ /**
537
+ * Called with the underlying WebView instance once it mounts, and with `null`
538
+ * on unmount. Lets callers inject JS into the frame (e.g. `injectJavaScript`).
539
+ */
540
+ onRef?: (webView: WebView | null) => void;
529
541
  }
530
542
  /**
531
543
  * Reusable React Native component that renders a MoonPay frame as a WebView.
532
544
  * Bridges the WebViewTransport to the actual WebView instance.
533
545
  */
534
- declare function MoonPayFrame({ transport, hidden, style, webViewProps, }: MoonPayFrameProps): JSX.Element | null;
546
+ declare function MoonPayFrame({ transport, hidden, style, webViewProps, onRef, }: MoonPayFrameProps): JSX.Element | null;
535
547
 
536
548
  interface MoonPayProviderProps {
537
549
  /**
package/dist/index.js CHANGED
@@ -473,7 +473,8 @@ function MoonPayFrame({
473
473
  transport,
474
474
  hidden,
475
475
  style,
476
- webViewProps
476
+ webViewProps,
477
+ onRef
477
478
  }) {
478
479
  const webViewRef = useRef(null);
479
480
  useEffect(() => {
@@ -481,6 +482,10 @@ function MoonPayFrame({
481
482
  return () => {
482
483
  };
483
484
  }, [transport]);
485
+ useEffect(() => {
486
+ onRef?.(webViewRef.current);
487
+ return () => onRef?.(null);
488
+ }, [onRef]);
484
489
  const url = transport.url;
485
490
  if (!url) return null;
486
491
  const handleMessage = (event) => {
@@ -975,7 +980,7 @@ function createRNClient(deps) {
975
980
  connect: (opts) => connect(deps, opts),
976
981
  setupAuth: (opts) => setupAuth(deps, opts),
977
982
  getCredentials: () => core.getCredentials(),
978
- getPaymentMethods: () => core.getPaymentMethods(),
983
+ getPaymentMethods: (params) => core.getPaymentMethods(params),
979
984
  getQuote: (params) => core.getQuote(params),
980
985
  getAssets: (params) => core.getAssets(params),
981
986
  listTransactions: (params) => core.listTransactions(params),
@@ -1341,7 +1346,8 @@ function MoonPayFrameView({
1341
1346
  style,
1342
1347
  defaultStyle,
1343
1348
  onEvent,
1344
- webViewProps
1349
+ webViewProps,
1350
+ onRef
1345
1351
  }) {
1346
1352
  const { sessionToken, core, frameBaseUrl, theme } = useMoonPayContext();
1347
1353
  const [transport, setTransport] = useState3(null);
@@ -1409,10 +1415,10 @@ function MoonPayFrameView({
1409
1415
  applyReactiveProps(spec, reactiveKeys, propsRef.current, appliedRef.current, handle);
1410
1416
  }, [liveKey]);
1411
1417
  if (spec.hidden) {
1412
- return transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, hidden: true, webViewProps }) : null;
1418
+ return transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, hidden: true, webViewProps, onRef }) : null;
1413
1419
  }
1414
1420
  const resolvedStyle = { ...defaultStyle, ...style };
1415
- return /* @__PURE__ */ jsx4(View3, { style: resolvedStyle, children: transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, webViewProps }) : null });
1421
+ return /* @__PURE__ */ jsx4(View3, { style: resolvedStyle, children: transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, webViewProps, onRef }) : null });
1416
1422
  }
1417
1423
 
1418
1424
  // src/components/add-card.tsx
@@ -1439,7 +1445,8 @@ function MoonPayApplePayButton({
1439
1445
  applePayButtonSettings,
1440
1446
  onEvent,
1441
1447
  style,
1442
- webViewProps
1448
+ webViewProps,
1449
+ onRef
1443
1450
  }) {
1444
1451
  return /* @__PURE__ */ jsx6(
1445
1452
  MoonPayFrameView,
@@ -1449,7 +1456,8 @@ function MoonPayApplePayButton({
1449
1456
  style,
1450
1457
  defaultStyle: { height: 48 },
1451
1458
  onEvent,
1452
- webViewProps
1459
+ webViewProps,
1460
+ onRef
1453
1461
  }
1454
1462
  );
1455
1463
  }