To allow charge payment from user periodically, you can request user to create a subscription
const { address } = useAccount();
const sessionConfig = usePrepareContractWrite({
address: address,
abi: SubscriptionFacetABI,
functionName: 'addSubscription',
args: [
cartItemsInfos[0].name,
cartItemsInfos[0].description,
SubscriptionType.Monthly,
RAISE_SUBSCRIPTIONS_ORACLE_ADDRESS,
payToken,
price,
],
});
const { data, isLoading, isSuccess, write } = useContractWrite(
sessionConfig.config,
);
This call triggers subscription creation request window in user wallet. After user approve and transaction execution the subscription can be charged periodically