fn reactivate(env: Env, subscriber: Address, sub_id: u64) -> Result<bool>
Reactivates a subscription that was paused due to failed charges. The function re-approves the token allowance and immediately attempts to charge the overdue period. If the charge succeeds, the subscription returns to Active status.
Parameters
| Name | Type | Description |
|---|
subscriber | Address | The subscriber’s Stellar address. Must sign the transaction. |
sub_id | u64 | The subscription ID to reactivate. |
Authorization
subscriber.require_auth();
Only the subscriber can reactivate their own subscription. The subscriber’s signature covers both the reactivate() call and the nested token.approve() to refresh the allowance.
Return value
Result<bool> - true if the immediate charge succeeded, false if it did not (e.g., still insufficient balance). The subscription is reactivated regardless - the charge attempt is best-effort.
Events emitted
| Event | Topics | Data |
|---|
sub_react | subscriber, sub_id | Reactivation details |
Additional events may be emitted from the implicit charge attempt (charge_ok or charge_fail).
Error cases
| Code | Name | Description |
|---|
| 8 | SubNotFound | No subscription exists with the given sub_id. |
| 9 | Unauthorized | Caller is not the subscriber on this subscription. |
| 13 | NotPaused | The subscription is not in Paused status. Only paused subscriptions can be reactivated. |
Examples
import { VowenaClient, NETWORKS } from "vowena";
const client = new VowenaClient({
contractId: NETWORKS.testnet.contractId,
rpcUrl: NETWORKS.testnet.rpcUrl,
networkPassphrase: NETWORKS.testnet.networkPassphrase,
});
// Subscriber reactivates a paused subscription
const tx = await client.buildReactivate(
"GSUBSCRIBER...ADDR", // Subscriber's address
subscriptionId // Subscription ID
);
const signedXdr = await signTransaction(tx);
const result = await client.submitTransaction(signedXdr);
console.log("Charged on reactivation:", result.charged); // true or false
soroban contract invoke \
--id CONTRACT_ID \
--network testnet \
--source SUBSCRIBER_SECRET \
-- \
reactivate \
--subscriber GSUBSCRIBER...ADDR \
--sub_id 1
Before reactivating, make sure the subscriber’s wallet has sufficient USDC balance. The reactivation will re-approve the token allowance and immediately attempt to charge the overdue period. If the balance is still insufficient, the subscription returns to Active status but the charge will fail again on the next charge() call.