@stigg/react-sdk 4.4.1 → 4.4.3

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,2 +1,2 @@
1
- import { GetCheckoutState, GetCheckoutStateResults } from '../../../../../js-client-sdk';
1
+ import { GetCheckoutState, GetCheckoutStateResults } from '@stigg/js-client-sdk';
2
2
  export declare function mockCheckoutState(params: GetCheckoutState): GetCheckoutStateResults;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.4.1",
2
+ "version": "4.4.3",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -23,7 +23,11 @@ type StripeManualMode = { mode: 'setup' | 'payment' | 'subscription'; currency:
23
23
 
24
24
  const getStepProps = (
25
25
  currentStep: CheckoutStep,
26
- { onBillingAddressChange, onChangePlan }: Pick<CheckoutContainerProps, 'onBillingAddressChange' | 'onChangePlan'>,
26
+ {
27
+ onBillingAddressChange,
28
+ onChangePlan,
29
+ collectPhoneNumber,
30
+ }: Pick<CheckoutContainerProps, 'onBillingAddressChange' | 'onChangePlan' | 'collectPhoneNumber'>,
27
31
  ): StepProps => {
28
32
  switch (currentStep.key) {
29
33
  case CheckoutStepKey.PLAN:
@@ -31,7 +35,11 @@ const getStepProps = (
31
35
  case CheckoutStepKey.ADDONS:
32
36
  return { content: <CheckoutAddonsStep /> };
33
37
  case CheckoutStepKey.PAYMENT:
34
- return { content: <PaymentStep onBillingAddressChange={onBillingAddressChange} /> };
38
+ return {
39
+ content: (
40
+ <PaymentStep onBillingAddressChange={onBillingAddressChange} collectPhoneNumber={collectPhoneNumber} />
41
+ ),
42
+ };
35
43
  default:
36
44
  return { content: null };
37
45
  }
@@ -50,6 +58,7 @@ export type CheckoutContainerProps = {
50
58
  onBillingAddressChange?: (params: { billingAddress: BillingAddress }) => Promise<void>;
51
59
  disablePromotionCode?: boolean;
52
60
  disableSuccessAnimation?: boolean;
61
+ collectPhoneNumber?: boolean;
53
62
  onMockCheckoutPreview?: MockCheckoutPreviewCallback;
54
63
  };
55
64
 
@@ -58,6 +67,7 @@ export function CheckoutContainer({
58
67
  onCheckoutCompleted,
59
68
  onChangePlan,
60
69
  onBillingAddressChange,
70
+ collectPhoneNumber,
61
71
  disablePromotionCode,
62
72
  disableSuccessAnimation,
63
73
  onMockCheckoutPreview,
@@ -76,16 +86,16 @@ export function CheckoutContainer({
76
86
  !!activeSubscription &&
77
87
  activeSubscription.pricingType !== PricingType.Free;
78
88
 
79
- const { content } = getStepProps(currentStep, { onBillingAddressChange, onChangePlan });
89
+ const { content } = getStepProps(currentStep, { onBillingAddressChange, onChangePlan, collectPhoneNumber });
80
90
 
81
91
  const checkoutContent = (
82
92
  <>
83
93
  {isFreeDowngrade ? (
84
94
  <DowngradeToFreePlan
85
- checkoutLocalization={checkoutLocalization}
86
95
  freePlan={plan!}
87
96
  activeSubscription={activeSubscription!}
88
97
  allowChangePlan
98
+ checkoutLocalization={checkoutLocalization}
89
99
  onChangePlan={onChangePlan}
90
100
  />
91
101
  ) : (
@@ -1,5 +1,11 @@
1
1
  export { CheckoutTheme } from './theme';
2
- export { Checkout, CheckoutProps } from './Checkout';
3
- export { OnCheckoutCompletedParams, OnCheckoutParams, CheckoutResult } from './CheckoutContainer';
2
+ export {
3
+ OnCheckoutCompletedParams,
4
+ OnCheckoutParams,
5
+ CheckoutResult,
6
+ CheckoutContainerProps,
7
+ } from './CheckoutContainer';
8
+ export { CheckoutProviderProps } from './CheckoutProvider';
4
9
  export { CheckoutLocalization } from './textOverrides';
10
+ export { Checkout, CheckoutProps } from './Checkout';
5
11
  export * from './types';
@@ -16,6 +16,18 @@ const AppliedCouponContainer = styled(Grid)`
16
16
  border: 1px solid ${({ theme }) => theme.stigg.palette.primary};
17
17
  `;
18
18
 
19
+ export const StyledIcon = styled(Icon, { shouldForwardProp: (prop) => prop !== 'style' })<{ $shouldFill?: boolean }>`
20
+ display: flex;
21
+
22
+ g {
23
+ stroke: ${({ theme }) => theme.stigg.palette.primary};
24
+ }
25
+
26
+ path {
27
+ fill: ${({ theme, $shouldFill }) => ($shouldFill ? theme.stigg.palette.primary : undefined)};
28
+ }
29
+ `;
30
+
19
31
  export type AppliedPromotionCodeProps = {
20
32
  promotionCode: string;
21
33
  onClearPromotionCode: () => void;
@@ -24,14 +36,14 @@ export type AppliedPromotionCodeProps = {
24
36
  export const AppliedPromotionCode = ({ promotionCode, onClearPromotionCode }: AppliedPromotionCodeProps) => (
25
37
  <AppliedCouponContainer container>
26
38
  <Grid item display="flex" gap={1} alignItems="center">
27
- <Icon icon="Coupon" style={{ display: 'flex' }} />
39
+ <StyledIcon icon="Coupon" />
28
40
  <Typography variant="body1" color="primary.main" lineHeight="auto">
29
41
  {promotionCode}
30
42
  </Typography>
31
43
  </Grid>
32
44
  <Grid item>
33
45
  <Button variant="text" sx={{ minWidth: 'unset', padding: 0 }} onClick={onClearPromotionCode}>
34
- <Icon icon="Close" style={{ display: 'flex' }} />
46
+ <StyledIcon icon="Close" $shouldFill />
35
47
  </Button>
36
48
  </Grid>
37
49
  </AppliedCouponContainer>
@@ -29,7 +29,7 @@ export type PaymentMethodProps = Pick<Customer, 'paymentMethodDetails'> &
29
29
  export type NewPaymentMethodProps = Pick<PaymentMethodLayoutProps, 'checked' | 'readOnly'> & {
30
30
  onSelect: () => void;
31
31
  checkoutLocalization: CheckoutLocalization;
32
- } & Pick<CheckoutContainerProps, 'onBillingAddressChange'>;
32
+ } & Pick<CheckoutContainerProps, 'onBillingAddressChange' | 'collectPhoneNumber'>;
33
33
 
34
34
  function PaymentMethodLayout({ checked, icon, text, subtitle, readOnly }: PaymentMethodLayoutProps) {
35
35
  return (
@@ -76,6 +76,7 @@ export function NewPaymentMethod({
76
76
  readOnly,
77
77
  checkoutLocalization,
78
78
  onBillingAddressChange,
79
+ collectPhoneNumber,
79
80
  }: NewPaymentMethodProps) {
80
81
  return (
81
82
  <NewPaymentMethodContainer item onClick={onSelect} $disabled={readOnly}>
@@ -86,7 +87,7 @@ export function NewPaymentMethod({
86
87
  text={<Typography variant="h6">{checkoutLocalization.newPaymentMethodText}</Typography>}
87
88
  />
88
89
  <Collapse in={checked}>
89
- <StripePaymentForm onBillingAddressChange={onBillingAddressChange} />
90
+ <StripePaymentForm onBillingAddressChange={onBillingAddressChange} collectPhoneNumber={collectPhoneNumber} />
90
91
  </Collapse>
91
92
  </NewPaymentMethodContainer>
92
93
  );
@@ -12,7 +12,10 @@ const PaymentContainer = styled(Grid)`
12
12
  gap: 24px;
13
13
  `;
14
14
 
15
- export function PaymentStep({ onBillingAddressChange }: Pick<CheckoutContainerProps, 'onBillingAddressChange'>) {
15
+ export function PaymentStep({
16
+ onBillingAddressChange,
17
+ collectPhoneNumber,
18
+ }: Pick<CheckoutContainerProps, 'onBillingAddressChange' | 'collectPhoneNumber'>) {
16
19
  const { checkoutState, checkoutLocalization, widgetState } = useCheckoutModel();
17
20
  const { customer } = checkoutState || {};
18
21
  const { errorMessage, useNewPaymentMethod, setUseNewPaymentMethod } = usePaymentStepModel();
@@ -45,6 +48,7 @@ export function PaymentStep({ onBillingAddressChange }: Pick<CheckoutContainerPr
45
48
  checkoutLocalization={checkoutLocalization}
46
49
  onSelect={() => handleOnSelect(true)}
47
50
  onBillingAddressChange={onBillingAddressChange}
51
+ collectPhoneNumber={collectPhoneNumber}
48
52
  />
49
53
  </PaymentContainer>
50
54
  );
@@ -7,11 +7,15 @@ import { Typography } from '../../../../common/Typography';
7
7
  import { useCheckoutModel, usePaymentStepModel } from '../../../hooks';
8
8
  import { CheckoutContainerProps } from '../../../CheckoutContainer';
9
9
 
10
- export function StripePaymentForm({ onBillingAddressChange }: Pick<CheckoutContainerProps, 'onBillingAddressChange'>) {
10
+ export function StripePaymentForm({
11
+ onBillingAddressChange,
12
+ collectPhoneNumber,
13
+ }: Pick<CheckoutContainerProps, 'onBillingAddressChange' | 'collectPhoneNumber'>) {
11
14
  const { checkoutState, checkoutLocalization, widgetState, setWidgetReadOnly } = useCheckoutModel();
12
15
  const { setBillingAddress } = usePaymentStepModel();
13
16
  const { customer, configuration } = checkoutState || {};
14
17
  const { readOnly } = widgetState;
18
+ const shouldCollectPhoneNumber = !!(collectPhoneNumber ?? configuration?.content?.collectPhoneNumber);
15
19
 
16
20
  const handleAddressChange = (args: StripeAddressElementChangeEvent) => {
17
21
  if (!args.complete) {
@@ -47,7 +51,7 @@ export function StripePaymentForm({ onBillingAddressChange }: Pick<CheckoutConta
47
51
  onChange={handleAddressChange}
48
52
  options={{
49
53
  mode: 'billing',
50
- fields: { phone: configuration?.content?.collectPhoneNumber ? 'always' : 'auto' },
54
+ fields: { phone: shouldCollectPhoneNumber ? 'always' : 'auto' },
51
55
  defaultValues: {
52
56
  ...(customer?.name && { name: customer.name }),
53
57
  },
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import './styles.css';
2
+
2
3
  export * from '@stigg/js-client-sdk';
3
4
  export {
4
5
  Paywall,
@@ -29,7 +30,22 @@ export {
29
30
  StiggContextValue,
30
31
  StiggContext,
31
32
  } from './components/StiggProvider';
32
- export { Checkout, CheckoutProps, CheckoutTheme } from './components/checkout';
33
+ export {
34
+ Checkout,
35
+ CheckoutProps,
36
+ CheckoutProviderProps,
37
+ CheckoutContainerProps,
38
+ CheckoutLocalization,
39
+ CheckoutResult,
40
+ OnCheckoutCompletedParams,
41
+ OnCheckoutParams,
42
+ CheckoutTheme,
43
+ CheckoutMockProps,
44
+ MockCheckoutPreviewCallback,
45
+ MockCheckoutStateCallback,
46
+ BillingInformation,
47
+ TaxDetailsInput,
48
+ } from './components/checkout';
33
49
  export { useWaitForCheckoutCompleted, ProvisionStatus } from './components/hooks';
34
50
  export { HorizontalAlignment, TextAlignment } from './theme/types';
35
51
  export { CustomizedTheme as Theme } from './theme/Theme';
@@ -16,7 +16,7 @@ import {
16
16
  PromotionalEntitlement,
17
17
  Subscription,
18
18
  Addon,
19
- } from '../../../../../js-client-sdk';
19
+ } from '@stigg/js-client-sdk';
20
20
  import {
21
21
  BASE_FEE_MONTHLY,
22
22
  TIERS_PRICE_MONTHLY,