Skip to content

fix(subscriptions): do not silently fall back to one-time payment on create failure (#15) - #102

Open
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/subscription-create-fallback-15
Open

fix(subscriptions): do not silently fall back to one-time payment on create failure (#15)#102
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/subscription-create-fallback-15

Conversation

@ghzhost

@ghzhost ghzhost commented Sep 2, 2026

Copy link
Copy Markdown

Closes #15

Problem

In useCreateSubscription, when subscriptionApi.buildCreateTransaction threw an error (for example 501 / backend unavailable / invalid params), the catch block silently fell back to building a plain, one-time buildPaymentTransaction locally and proceeded through signing and submission to subscriptionApi.create.

This meant the user unknowingly signed and submitted an immediate, full one-time payment instead of a recurring subscription schedule.

Solution

  • Removed the silent fallback to buildPaymentTransaction in useCreateSubscription.
  • Propagated any failure from subscriptionApi.buildCreateTransaction directly so the mutation transitions to error state and warns the user.
  • Added comprehensive unit tests in src/hooks/useCreateSubscription.test.tsx verifying errors properly reject the mutation without calling buildPaymentTransaction or subscriptionApi.create.

Verification

  • Ran test suite with NODE_ENV=test npm test: 28 test files passed (117 tests total).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useCreateSubscription silently substitutes a one-time payment for a failed subscription build, then registers it as a recurring schedule

1 participant