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
5 changes: 5 additions & 0 deletions .changeset/slimy-chefs-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix `onSuccess` callback was not called correctly on `CheckoutWidget`, `BuyWidget` components
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,13 @@
const [state, send] = usePaymentMachine(adapters, uiOptions.mode);

// Handle buy completion
const handleBuyComplete = useCallback(() => {
const handleDoneOrContinueClick = useCallback(() => {

Check warning on line 183 in packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx#L183

Added line #L183 was not covered by tests
if (uiOptions.mode === "transaction") {
send({ type: "CONTINUE_TO_TRANSACTION" });
} else {
onComplete?.();
send({ type: "RESET" });
}
}, [onComplete, send, uiOptions.mode]);
}, [send, uiOptions.mode]);

Check warning on line 189 in packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx#L189

Added line #L189 was not covered by tests

// Handle post-buy transaction completion
const handlePostBuyTransactionComplete = useCallback(() => {
Expand Down Expand Up @@ -230,8 +229,11 @@
const handleExecutionComplete = useCallback(
(completedStatuses: CompletedStatusResult[]) => {
send({ completedStatuses, type: "EXECUTION_COMPLETE" });
if (uiOptions.mode !== "transaction") {
onComplete?.();
}

Check warning on line 234 in packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx#L232-L234

Added lines #L232 - L234 were not covered by tests
},
[send],
[send, onComplete, uiOptions.mode],

Check warning on line 236 in packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx#L236

Added line #L236 was not covered by tests
);

// Handle retry
Expand Down Expand Up @@ -390,7 +392,7 @@
<SuccessScreen
client={client}
completedStatuses={state.context.completedStatuses}
onDone={handleBuyComplete}
onDone={handleDoneOrContinueClick}

Check warning on line 395 in packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx#L395

Added line #L395 was not covered by tests
preparedQuote={state.context.quote}
uiOptions={uiOptions}
windowAdapter={webWindowAdapter}
Expand Down
Loading