Skip to main content
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

NameTypeDescription
subscriberAddressThe subscriber’s Stellar address. Must sign the transaction.
sub_idu64The 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

EventTopicsData
sub_reactsubscriber, sub_idReactivation details
Additional events may be emitted from the implicit charge attempt (charge_ok or charge_fail).

Error cases

CodeNameDescription
8SubNotFoundNo subscription exists with the given sub_id.
9UnauthorizedCaller is not the subscriber on this subscription.
13NotPausedThe 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
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.