Skip to content

Commit 9746f20

Browse files
refactor: rename Checkout prefixed types ShopifyCheckout
1 parent cf0ce3d commit 9746f20

File tree

5 files changed

+33
-33
lines changed

5 files changed

+33
-33
lines changed

modules/@shopify/checkout-sheet-kit/src/components/Checkout.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import type {
4141
CheckoutSubmitStart
4242
} from '../events';
4343

44-
export interface CheckoutProps {
44+
export interface ShopifyCheckoutProps {
4545
/**
4646
* The checkout URL to load in the webview
4747
*/
@@ -104,14 +104,14 @@ export interface CheckoutProps {
104104
testID?: string;
105105
}
106106

107-
export interface CheckoutRef {
107+
export interface ShopifyCheckoutRef {
108108
/**
109109
* Reload the current checkout page
110110
*/
111111
reload: () => void;
112112
}
113113

114-
interface NativeCheckoutWebViewProps {
114+
interface NativeShopifyCheckoutWebViewProps {
115115
checkoutUrl: string;
116116
auth?: string;
117117
style?: ViewStyle;
@@ -126,7 +126,7 @@ interface NativeCheckoutWebViewProps {
126126
}
127127

128128
const RCTCheckoutWebView =
129-
requireNativeComponent<NativeCheckoutWebViewProps>('RCTCheckoutWebView');
129+
requireNativeComponent<NativeShopifyCheckoutWebViewProps>('RCTCheckoutWebView');
130130

131131
/**
132132
* Checkout provides a native webview component for displaying
@@ -137,29 +137,29 @@ const RCTCheckoutWebView =
137137
* including Shop Pay, Apple Pay, and other payment methods.
138138
*
139139
* @example Basic usage
140-
* import {Checkout} from '@shopify/checkout-sheet-kit';
140+
* import {ShopifyCheckout} from '@shopify/checkout-sheet-kit';
141141
*
142-
* <Checkout
142+
* <ShopifyCheckout
143143
* checkoutUrl="https://shop.example.com/checkouts/cn/123"
144144
* onComplete={(event) => console.log('Checkout completed!', event.orderDetails)}
145145
* onError={(error) => console.error('Checkout failed:', error.message)}
146146
* style={{flex: 1}}
147147
* />
148148
*
149149
* @example Passing an app authentication token to customize checkout and receive richer events
150-
* <Checkout
150+
* <ShopifyCheckout
151151
* checkoutUrl="https://shop.example.com/checkouts/cn/123"
152152
* auth="your_auth_token_here"
153153
* onComplete={(event) => console.log('Checkout completed!')}
154154
* />
155155
*
156156
* @example Using with ref to reload on error
157157
* import {useRef} from 'react';
158-
* import {Checkout, CheckoutHandle} from '@shopify/checkout-sheet-kit';
158+
* import {ShopifyCheckout, CheckoutHandle} from '@shopify/checkout-sheet-kit';
159159
*
160-
* const checkoutRef = useRef<CheckoutHandle>(null);
160+
* const checkoutRef = useRef<ShopifyCheckoutHandle>(null);
161161
*
162-
* <Checkout
162+
* <ShopifyCheckout
163163
* ref={checkoutRef}
164164
* checkoutUrl={url}
165165
* auth={authToken}
@@ -169,7 +169,7 @@ const RCTCheckoutWebView =
169169
* }}
170170
* />
171171
*/
172-
export const Checkout = forwardRef<CheckoutRef, CheckoutProps>(
172+
export const ShopifyCheckout = forwardRef<ShopifyCheckoutRef, ShopifyCheckoutProps>(
173173
(
174174
{
175175
checkoutUrl,
@@ -201,7 +201,7 @@ export const Checkout = forwardRef<CheckoutRef, CheckoutProps>(
201201

202202

203203
const handleStart = useCallback<
204-
Required<NativeCheckoutWebViewProps>['onStart']
204+
Required<NativeShopifyCheckoutWebViewProps>['onStart']
205205
>(
206206
(event: {nativeEvent: CheckoutStartEvent}) => {
207207
onStart?.(event.nativeEvent);
@@ -210,7 +210,7 @@ export const Checkout = forwardRef<CheckoutRef, CheckoutProps>(
210210
);
211211

212212
const handleError = useCallback<
213-
Required<NativeCheckoutWebViewProps>['onError']
213+
Required<NativeShopifyCheckoutWebViewProps>['onError']
214214
>(
215215
(event: {nativeEvent: CheckoutException}) => {
216216
onError?.(event.nativeEvent);
@@ -219,7 +219,7 @@ export const Checkout = forwardRef<CheckoutRef, CheckoutProps>(
219219
);
220220

221221
const handleComplete = useCallback<
222-
Required<NativeCheckoutWebViewProps>['onComplete']
222+
Required<NativeShopifyCheckoutWebViewProps>['onComplete']
223223
>(
224224
(event: {nativeEvent: CheckoutCompleteEvent}) => {
225225
onComplete?.(event.nativeEvent);
@@ -228,13 +228,13 @@ export const Checkout = forwardRef<CheckoutRef, CheckoutProps>(
228228
);
229229

230230
const handleCancel = useCallback<
231-
Required<NativeCheckoutWebViewProps>['onCancel']
231+
Required<NativeShopifyCheckoutWebViewProps>['onCancel']
232232
>(() => {
233233
onCancel?.();
234234
}, [onCancel]);
235235

236236
const handleLinkClick = useCallback<
237-
Required<NativeCheckoutWebViewProps>['onLinkClick']
237+
Required<NativeShopifyCheckoutWebViewProps>['onLinkClick']
238238
>(
239239
(event: {nativeEvent: {url: string}}) => {
240240
if (!event.nativeEvent.url) return;
@@ -244,7 +244,7 @@ export const Checkout = forwardRef<CheckoutRef, CheckoutProps>(
244244
);
245245

246246
const handleAddressChangeStart = useCallback<
247-
Required<NativeCheckoutWebViewProps>['onAddressChangeStart']
247+
Required<NativeShopifyCheckoutWebViewProps>['onAddressChangeStart']
248248
>(
249249
(event: {nativeEvent: CheckoutAddressChangeStart}) => {
250250
if (!event.nativeEvent) return;
@@ -254,7 +254,7 @@ export const Checkout = forwardRef<CheckoutRef, CheckoutProps>(
254254
);
255255

256256
const handleSubmitStart = useCallback<
257-
Required<NativeCheckoutWebViewProps>['onSubmitStart']
257+
Required<NativeShopifyCheckoutWebViewProps>['onSubmitStart']
258258
>(
259259
(event: {nativeEvent: CheckoutSubmitStart}) => {
260260
if (!event.nativeEvent) return;
@@ -303,6 +303,6 @@ export const Checkout = forwardRef<CheckoutRef, CheckoutProps>(
303303
},
304304
);
305305

306-
Checkout.displayName = 'Checkout';
306+
ShopifyCheckout.displayName = 'Checkout';
307307

308-
export default Checkout;
308+
export default ShopifyCheckout;

modules/@shopify/checkout-sheet-kit/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,15 @@ export type {
523523
AcceleratedCheckoutButtonsProps,
524524
RenderStateChangeEvent,
525525
} from './components/AcceleratedCheckoutButtons';
526-
export type {CheckoutProps, CheckoutRef} from './components/Checkout';
526+
export type {ShopifyCheckoutProps as CheckoutProps, ShopifyCheckoutRef as CheckoutRef} from './components/Checkout';
527527
export type {CheckoutEventProviderProps} from './CheckoutEventProvider';
528528

529529
// Components
530530
export {
531531
AcceleratedCheckoutButtons,
532532
RenderState,
533533
} from './components/AcceleratedCheckoutButtons';
534-
export {Checkout} from './components/Checkout';
534+
export {ShopifyCheckout} from './components/Checkout';
535535
export {
536536
CheckoutEventProvider,
537537
useCheckoutEvents,

modules/@shopify/checkout-sheet-kit/tests/CheckoutAddressChange.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jest.mock('react-native', () => {
2222

2323
import React from 'react';
2424
import {render, act} from '@testing-library/react-native';
25-
import {Checkout} from '../src/components/Checkout';
25+
import {ShopifyCheckout} from '../src/components/Checkout';
2626
import {createTestCart} from './testFixtures';
2727

2828
describe('Checkout Component - Address Change Events', () => {
@@ -32,7 +32,7 @@ describe('Checkout Component - Address Change Events', () => {
3232
const onAddressChangeStart = jest.fn();
3333

3434
const {getByTestId} = render(
35-
<Checkout
35+
<ShopifyCheckout
3636
checkoutUrl={mockCheckoutUrl}
3737
onAddressChangeStart={onAddressChangeStart}
3838
testID="checkout-webview"
@@ -65,7 +65,7 @@ describe('Checkout Component - Address Change Events', () => {
6565

6666
it('does not crash when onAddressChangeStart prop is not provided', () => {
6767
const {getByTestId} = render(
68-
<Checkout checkoutUrl={mockCheckoutUrl} testID="checkout-webview" />,
68+
<ShopifyCheckout checkoutUrl={mockCheckoutUrl} testID="checkout-webview" />,
6969
);
7070

7171
const nativeComponent = getByTestId('checkout-webview');
@@ -88,7 +88,7 @@ describe('Checkout Component - Address Change Events', () => {
8888
const onAddressChangeStart = jest.fn();
8989

9090
const {getByTestId} = render(
91-
<Checkout
91+
<ShopifyCheckout
9292
checkoutUrl={mockCheckoutUrl}
9393
onAddressChangeStart={onAddressChangeStart}
9494
testID="checkout-webview"
@@ -108,7 +108,7 @@ describe('Checkout Component - Address Change Events', () => {
108108
const onAddressChangeStart = jest.fn();
109109

110110
const {getByTestId} = render(
111-
<Checkout
111+
<ShopifyCheckout
112112
checkoutUrl={mockCheckoutUrl}
113113
onAddressChangeStart={onAddressChangeStart}
114114
testID="checkout-webview"

modules/@shopify/checkout-sheet-kit/tests/CheckoutSubmitStart.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jest.mock('react-native', () => {
2222

2323
import React from 'react';
2424
import {render, act} from '@testing-library/react-native';
25-
import {Checkout} from '../src/components/Checkout';
25+
import {ShopifyCheckout} from '../src/components/Checkout';
2626
import {createTestCart, createTestCheckout} from './testFixtures';
2727

2828
describe('Checkout Component - Submit Start Events', () => {
@@ -32,7 +32,7 @@ describe('Checkout Component - Submit Start Events', () => {
3232
const onSubmitStart = jest.fn();
3333

3434
const {getByTestId} = render(
35-
<Checkout
35+
<ShopifyCheckout
3636
checkoutUrl={mockCheckoutUrl}
3737
onSubmitStart={onSubmitStart}
3838
testID="checkout-webview"
@@ -65,7 +65,7 @@ describe('Checkout Component - Submit Start Events', () => {
6565

6666
it('does not crash when onSubmitStart prop is not provided', () => {
6767
const {getByTestId} = render(
68-
<Checkout checkoutUrl={mockCheckoutUrl} testID="checkout-webview" />,
68+
<ShopifyCheckout checkoutUrl={mockCheckoutUrl} testID="checkout-webview" />,
6969
);
7070

7171
const nativeComponent = getByTestId('checkout-webview');
@@ -88,7 +88,7 @@ describe('Checkout Component - Submit Start Events', () => {
8888
const onSubmitStart = jest.fn();
8989

9090
const {getByTestId} = render(
91-
<Checkout
91+
<ShopifyCheckout
9292
checkoutUrl={mockCheckoutUrl}
9393
onSubmitStart={onSubmitStart}
9494
testID="checkout-webview"

sample/src/screens/BuyNow/CheckoutScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import type {NavigationProp, RouteProp} from '@react-navigation/native';
2121
import {useNavigation} from '@react-navigation/native';
2222
import React, {useRef} from 'react';
2323
import {
24-
Checkout,
24+
ShopifyCheckout,
2525
type CheckoutAddressChangeStart,
2626
type CheckoutCompleteEvent,
2727
type CheckoutRef,
@@ -81,7 +81,7 @@ export default function CheckoutScreen(props: {
8181
};
8282

8383
return (
84-
<Checkout
84+
<ShopifyCheckout
8585
ref={ref}
8686
checkoutUrl={props.route.params.url}
8787
auth={props.route.params.auth}

0 commit comments

Comments
 (0)