@moneymq/react 0.7.0 → 0.9.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.
@@ -1,5 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
+ import { CheckoutReceipt } from '@moneymq/sdk';
4
+ export { Attachments, CheckoutReceipt, PaymentDetails, BasketItem as ReceiptBasketItem, ReceiptClaims } from '@moneymq/sdk';
3
5
 
4
6
  interface Branding {
5
7
  logo?: string;
@@ -17,6 +19,8 @@ interface MoneyMQProviderProps {
17
19
  children: React.ReactNode;
18
20
  client: MoneyMQClient;
19
21
  branding?: Branding;
22
+ /** Set to true if the parent app already provides wallet connection (AppProvider) */
23
+ skipWalletProvider?: boolean;
20
24
  }
21
25
  interface SandboxAccount {
22
26
  id: string;
@@ -36,7 +40,7 @@ declare const MoneyMQContext: React.Context<MoneyMQClient | null>;
36
40
  declare const SandboxContext: React.Context<SandboxContextState>;
37
41
  declare function useMoneyMQ(): MoneyMQClient;
38
42
  declare function useSandbox(): SandboxContextState;
39
- declare function MoneyMQProvider({ children, client, branding, }: MoneyMQProviderProps): react_jsx_runtime.JSX.Element | null;
43
+ declare function MoneyMQProvider({ children, client, branding, }: MoneyMQProviderProps): react_jsx_runtime.JSX.Element;
40
44
 
41
45
  /**
42
46
  * Represents a completed payment transaction.
@@ -190,42 +194,53 @@ interface CheckoutButtonProps {
190
194
  declare const CheckoutButton: React.ForwardRefExoticComponent<CheckoutButtonProps & React.RefAttributes<HTMLButtonElement>>;
191
195
 
192
196
  /**
193
- * Represents a line item in the checkout, including product, price, quantity, and calculated subtotal.
197
+ * Product information for a line item.
198
+ * Contains the essential fields needed for checkout + experimentId for A/B tracking.
199
+ */
200
+ interface LineItemProduct {
201
+ /** Unique product identifier */
202
+ id: string;
203
+ /** Display name shown to the customer */
204
+ name: string;
205
+ /** Optional description */
206
+ description?: string;
207
+ /** Experiment variant ID (e.g., "surfnet-lite#a") - for A/B test tracking */
208
+ experimentId?: string;
209
+ }
210
+ /**
211
+ * Price information for a line item.
212
+ */
213
+ interface LineItemPrice {
214
+ /** Unique price identifier */
215
+ id: string;
216
+ /** Price amount in cents (e.g., 999 for $9.99) */
217
+ unit_amount: number;
218
+ /** Currency code (e.g., "USDC") */
219
+ currency: string;
220
+ }
221
+ /**
222
+ * Represents a line item in the checkout.
194
223
  *
195
224
  * @example
196
225
  * ```tsx
197
226
  * const lineItem: LineItem = {
198
- * product: { id: 'prod_123', name: 'Pro Plan' },
227
+ * product: { id: 'prod_123', name: 'Pro Plan', experimentId: 'prod_123#a' },
199
228
  * price: { id: 'price_456', unit_amount: 999, currency: 'USDC' },
200
229
  * quantity: 2,
201
- * subtotal: 19.98,
202
230
  * };
231
+ * // Subtotal: (lineItem.price.unit_amount / 100) * lineItem.quantity
203
232
  * ```
204
233
  */
205
234
  interface LineItem {
206
235
  /** Product information */
207
- product: {
208
- /** Unique product identifier */
209
- id: string;
210
- /** Display name shown to the customer */
211
- name: string;
212
- /** Optional description */
213
- description?: string;
214
- };
236
+ product: LineItemProduct;
215
237
  /** Price information */
216
- price: {
217
- /** Unique price identifier */
218
- id: string;
219
- /** Price amount in cents (e.g., 999 for $9.99) */
220
- unit_amount: number;
221
- /** Currency code (e.g., "USDC") */
222
- currency: string;
223
- };
238
+ price: LineItemPrice;
224
239
  /** Quantity of this item */
225
240
  quantity: number;
226
- /** Calculated subtotal (unit_amount / 100 * quantity) */
227
- subtotal: number;
228
241
  }
242
+ /** Calculate subtotal for a line item */
243
+ declare function getLineItemSubtotal(item: LineItem): number;
229
244
  /**
230
245
  * Props for the CheckoutModal component.
231
246
  *
@@ -254,8 +269,8 @@ interface CheckoutModalProps {
254
269
  recipient: string;
255
270
  /** Optional line items to display in the checkout summary */
256
271
  lineItems?: LineItem[];
257
- /** Callback fired when payment completes. Receives the transaction signature. */
258
- onSuccess?: (signature: string) => void;
272
+ /** Callback fired when payment completes. Receives the CheckoutReceipt with helpers. */
273
+ onSuccess?: (receipt: CheckoutReceipt) => void;
259
274
  /** Callback fired when payment fails. Receives the Error with failure details. */
260
275
  onError?: (error: Error) => void;
261
276
  /** Accent color for UI elements. @default "#ec4899" */
@@ -295,7 +310,6 @@ interface CheckoutModalProps {
295
310
  * product: { id: 'prod_1', name: 'Pro Plan' },
296
311
  * price: { id: 'price_1', unit_amount: 999, currency: 'USDC' },
297
312
  * quantity: 1,
298
- * subtotal: 9.99,
299
313
  * },
300
314
  * ]}
301
315
  * onSuccess={(signature) => {
@@ -311,7 +325,7 @@ interface CheckoutModalProps {
311
325
  * @see {@link CheckoutModalProps} for available props
312
326
  * @see {@link CheckoutButton} for a simpler button-based checkout
313
327
  */
314
- declare function CheckoutModal({ visible, onClose, amount, currency, recipient, lineItems, onSuccess, onError, accentColor, debug, }: CheckoutModalProps): react_jsx_runtime.JSX.Element | null;
328
+ declare function CheckoutModal({ visible, onClose, amount, currency, recipient, lineItems, onSuccess, onError, accentColor, debug, }: CheckoutModalProps): React.ReactPortal | null;
315
329
 
316
330
  interface Payment {
317
331
  id: string;
@@ -327,4 +341,4 @@ interface UsePaymentReturn {
327
341
  }
328
342
  declare function usePayment(): UsePaymentReturn;
329
343
 
330
- export { type BasketItem, type Branding, CheckoutButton, type CheckoutButtonProps, CheckoutModal, type CheckoutModalProps, type LineItem, type MoneyMQClient, MoneyMQContext, MoneyMQProvider, type MoneyMQProviderProps, type Payment$1 as Payment, type Price, type Product, type SandboxAccount, SandboxContext, type UsePaymentReturn, useMoneyMQ, usePayment, useSandbox };
344
+ export { type BasketItem, type Branding, CheckoutButton, type CheckoutButtonProps, CheckoutModal, type CheckoutModalProps, type LineItem, type LineItemPrice, type LineItemProduct, type MoneyMQClient, MoneyMQContext, MoneyMQProvider, type MoneyMQProviderProps, type Payment$1 as Payment, type Price, type Product, type SandboxAccount, SandboxContext, type UsePaymentReturn, getLineItemSubtotal, useMoneyMQ, usePayment, useSandbox };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
+ import { CheckoutReceipt } from '@moneymq/sdk';
4
+ export { Attachments, CheckoutReceipt, PaymentDetails, BasketItem as ReceiptBasketItem, ReceiptClaims } from '@moneymq/sdk';
3
5
 
4
6
  interface Branding {
5
7
  logo?: string;
@@ -17,6 +19,8 @@ interface MoneyMQProviderProps {
17
19
  children: React.ReactNode;
18
20
  client: MoneyMQClient;
19
21
  branding?: Branding;
22
+ /** Set to true if the parent app already provides wallet connection (AppProvider) */
23
+ skipWalletProvider?: boolean;
20
24
  }
21
25
  interface SandboxAccount {
22
26
  id: string;
@@ -36,7 +40,7 @@ declare const MoneyMQContext: React.Context<MoneyMQClient | null>;
36
40
  declare const SandboxContext: React.Context<SandboxContextState>;
37
41
  declare function useMoneyMQ(): MoneyMQClient;
38
42
  declare function useSandbox(): SandboxContextState;
39
- declare function MoneyMQProvider({ children, client, branding, }: MoneyMQProviderProps): react_jsx_runtime.JSX.Element | null;
43
+ declare function MoneyMQProvider({ children, client, branding, }: MoneyMQProviderProps): react_jsx_runtime.JSX.Element;
40
44
 
41
45
  /**
42
46
  * Represents a completed payment transaction.
@@ -190,42 +194,53 @@ interface CheckoutButtonProps {
190
194
  declare const CheckoutButton: React.ForwardRefExoticComponent<CheckoutButtonProps & React.RefAttributes<HTMLButtonElement>>;
191
195
 
192
196
  /**
193
- * Represents a line item in the checkout, including product, price, quantity, and calculated subtotal.
197
+ * Product information for a line item.
198
+ * Contains the essential fields needed for checkout + experimentId for A/B tracking.
199
+ */
200
+ interface LineItemProduct {
201
+ /** Unique product identifier */
202
+ id: string;
203
+ /** Display name shown to the customer */
204
+ name: string;
205
+ /** Optional description */
206
+ description?: string;
207
+ /** Experiment variant ID (e.g., "surfnet-lite#a") - for A/B test tracking */
208
+ experimentId?: string;
209
+ }
210
+ /**
211
+ * Price information for a line item.
212
+ */
213
+ interface LineItemPrice {
214
+ /** Unique price identifier */
215
+ id: string;
216
+ /** Price amount in cents (e.g., 999 for $9.99) */
217
+ unit_amount: number;
218
+ /** Currency code (e.g., "USDC") */
219
+ currency: string;
220
+ }
221
+ /**
222
+ * Represents a line item in the checkout.
194
223
  *
195
224
  * @example
196
225
  * ```tsx
197
226
  * const lineItem: LineItem = {
198
- * product: { id: 'prod_123', name: 'Pro Plan' },
227
+ * product: { id: 'prod_123', name: 'Pro Plan', experimentId: 'prod_123#a' },
199
228
  * price: { id: 'price_456', unit_amount: 999, currency: 'USDC' },
200
229
  * quantity: 2,
201
- * subtotal: 19.98,
202
230
  * };
231
+ * // Subtotal: (lineItem.price.unit_amount / 100) * lineItem.quantity
203
232
  * ```
204
233
  */
205
234
  interface LineItem {
206
235
  /** Product information */
207
- product: {
208
- /** Unique product identifier */
209
- id: string;
210
- /** Display name shown to the customer */
211
- name: string;
212
- /** Optional description */
213
- description?: string;
214
- };
236
+ product: LineItemProduct;
215
237
  /** Price information */
216
- price: {
217
- /** Unique price identifier */
218
- id: string;
219
- /** Price amount in cents (e.g., 999 for $9.99) */
220
- unit_amount: number;
221
- /** Currency code (e.g., "USDC") */
222
- currency: string;
223
- };
238
+ price: LineItemPrice;
224
239
  /** Quantity of this item */
225
240
  quantity: number;
226
- /** Calculated subtotal (unit_amount / 100 * quantity) */
227
- subtotal: number;
228
241
  }
242
+ /** Calculate subtotal for a line item */
243
+ declare function getLineItemSubtotal(item: LineItem): number;
229
244
  /**
230
245
  * Props for the CheckoutModal component.
231
246
  *
@@ -254,8 +269,8 @@ interface CheckoutModalProps {
254
269
  recipient: string;
255
270
  /** Optional line items to display in the checkout summary */
256
271
  lineItems?: LineItem[];
257
- /** Callback fired when payment completes. Receives the transaction signature. */
258
- onSuccess?: (signature: string) => void;
272
+ /** Callback fired when payment completes. Receives the CheckoutReceipt with helpers. */
273
+ onSuccess?: (receipt: CheckoutReceipt) => void;
259
274
  /** Callback fired when payment fails. Receives the Error with failure details. */
260
275
  onError?: (error: Error) => void;
261
276
  /** Accent color for UI elements. @default "#ec4899" */
@@ -295,7 +310,6 @@ interface CheckoutModalProps {
295
310
  * product: { id: 'prod_1', name: 'Pro Plan' },
296
311
  * price: { id: 'price_1', unit_amount: 999, currency: 'USDC' },
297
312
  * quantity: 1,
298
- * subtotal: 9.99,
299
313
  * },
300
314
  * ]}
301
315
  * onSuccess={(signature) => {
@@ -311,7 +325,7 @@ interface CheckoutModalProps {
311
325
  * @see {@link CheckoutModalProps} for available props
312
326
  * @see {@link CheckoutButton} for a simpler button-based checkout
313
327
  */
314
- declare function CheckoutModal({ visible, onClose, amount, currency, recipient, lineItems, onSuccess, onError, accentColor, debug, }: CheckoutModalProps): react_jsx_runtime.JSX.Element | null;
328
+ declare function CheckoutModal({ visible, onClose, amount, currency, recipient, lineItems, onSuccess, onError, accentColor, debug, }: CheckoutModalProps): React.ReactPortal | null;
315
329
 
316
330
  interface Payment {
317
331
  id: string;
@@ -327,4 +341,4 @@ interface UsePaymentReturn {
327
341
  }
328
342
  declare function usePayment(): UsePaymentReturn;
329
343
 
330
- export { type BasketItem, type Branding, CheckoutButton, type CheckoutButtonProps, CheckoutModal, type CheckoutModalProps, type LineItem, type MoneyMQClient, MoneyMQContext, MoneyMQProvider, type MoneyMQProviderProps, type Payment$1 as Payment, type Price, type Product, type SandboxAccount, SandboxContext, type UsePaymentReturn, useMoneyMQ, usePayment, useSandbox };
344
+ export { type BasketItem, type Branding, CheckoutButton, type CheckoutButtonProps, CheckoutModal, type CheckoutModalProps, type LineItem, type LineItemPrice, type LineItemProduct, type MoneyMQClient, MoneyMQContext, MoneyMQProvider, type MoneyMQProviderProps, type Payment$1 as Payment, type Price, type Product, type SandboxAccount, SandboxContext, type UsePaymentReturn, getLineItemSubtotal, useMoneyMQ, usePayment, useSandbox };