Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public enum CheckoutEventType {
ON_START("onStart"),
ON_ERROR("onError"),
ON_FAIL("onFail"),
ON_COMPLETE("onComplete"),
ON_CANCEL("onCancel"),
ON_LINK_CLICK("onLinkClick"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public void onComplete(@NonNull CheckoutCompleteEvent event) {

@Override
public void onFail(@NonNull CheckoutException error) {
sendEvent(CheckoutEventType.ON_ERROR, buildErrorMap(error));
sendEvent(CheckoutEventType.ON_FAIL, buildErrorMap(error));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void testGetExportedCustomDirectEventTypeConstants_includesAllEventTypes(
.containsKeys(
"onStart",
"onComplete",
"onError",
"onFail",
"onCancel",
"onLinkClick",
"onAddressChangeStart",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class RCTCheckoutWebView: UIView {
}

@objc var onStart: RCTBubblingEventBlock?
@objc var onError: RCTBubblingEventBlock?
@objc var onFail: RCTBubblingEventBlock?
@objc var onComplete: RCTBubblingEventBlock?
@objc var onCancel: RCTBubblingEventBlock?
@objc var onLinkClick: RCTBubblingEventBlock?
Expand Down Expand Up @@ -246,7 +246,7 @@ class RCTCheckoutWebView: UIView {
errorCode = "UNKNOWN_ERROR"
}

onError?([
onFail?([
"error": errorMessage,
"eventId": id,
"code": errorCode
Expand Down Expand Up @@ -276,7 +276,7 @@ extension RCTCheckoutWebView: CheckoutDelegate {
}

func checkoutDidFail(error: ShopifyCheckoutSheetKit.CheckoutError) {
onError?(ShopifyEventSerialization.serialize(checkoutError: error))
onFail?(ShopifyEventSerialization.serialize(checkoutError: error))
}

func checkoutDidClickLink(url: URL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ @interface RCT_EXTERN_MODULE (RCTCheckoutWebViewManager, RCTViewManager)
/**
* Emitted when checkout fails
*/
RCT_EXPORT_VIEW_PROPERTY(onError, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onFail, RCTBubblingEventBlock)

/**
* Emitted when checkout completes successfully
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface ShopifyCheckoutProps {
/**
* Called when checkout fails
*/
onError?: (error: CheckoutException) => void;
onFail?: (error: CheckoutException) => void;

/**
* Called when checkout is completed successfully
Expand Down Expand Up @@ -129,7 +129,7 @@ interface NativeShopifyCheckoutWebViewProps {
style?: ViewStyle;
testID?: string;
onStart?: (event: {nativeEvent: CheckoutStartEvent}) => void;
onError?: (event: {nativeEvent: CheckoutNativeError}) => void;
onFail?: (event: {nativeEvent: CheckoutNativeError}) => void;
onComplete?: (event: {nativeEvent: CheckoutCompleteEvent}) => void;
onCancel?: () => void;
onLinkClick?: (event: {nativeEvent: {url: string}}) => void;
Expand Down Expand Up @@ -161,7 +161,7 @@ const RCTCheckoutWebView =
* <ShopifyCheckout
* checkoutUrl="https://shop.example.com/checkouts/cn/123"
* onComplete={(event) => console.log('Checkout completed!', event.orderDetails)}
* onError={(error) => console.error('Checkout failed:', error.message)}
* onFail={(error) => console.error('Checkout failed:', error.message)}
* style={{flex: 1}}
* />
*
Expand All @@ -182,7 +182,7 @@ const RCTCheckoutWebView =
* ref={checkoutRef}
* checkoutUrl={url}
* auth={authToken}
* onError={() => {
* onFail={() => {
* // Reload on error
* checkoutRef.current?.reload();
* }}
Expand All @@ -197,7 +197,7 @@ export const ShopifyCheckout = forwardRef<
checkoutUrl,
auth,
onStart,
onError,
onFail,
onComplete,
onCancel,
onLinkClick,
Expand Down Expand Up @@ -232,13 +232,13 @@ export const ShopifyCheckout = forwardRef<
);

const handleError = useCallback<
Required<NativeShopifyCheckoutWebViewProps>['onError']
Required<NativeShopifyCheckoutWebViewProps>['onFail']
>(
event => {
const transformedError = parseCheckoutError(event.nativeEvent);
onError?.(transformedError);
onFail?.(transformedError);
},
[onError],
[onFail],
);

const handleComplete = useCallback<
Expand Down Expand Up @@ -322,7 +322,7 @@ export const ShopifyCheckout = forwardRef<
style={style}
testID={testID}
onStart={handleStart}
onError={handleError}
onFail={handleError}
onComplete={handleComplete}
onCancel={handleCancel}
onLinkClick={handleLinkClick}
Expand Down
Loading
Loading