Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.
Merged
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
10 changes: 8 additions & 2 deletions src/hooks/deleteFromStripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ export const deleteFromStripe: CollectionAfterDeleteHookWithArgs = async (args)

if (syncConfig) {
try {
await stripe?.[syncConfig.stripeResourceType]?.del(doc.stripeID);
if (logs) payload.logger.info(`✅ Successfully deleted Stripe document with ID: '${doc.stripeID}'.`);
const found = await stripe?.[syncConfig.stripeResourceType]?.retrieve(doc.stripeID);

if (found) {
await stripe?.[syncConfig.stripeResourceType]?.del(doc.stripeID);
if (logs) payload.logger.info(`✅ Successfully deleted Stripe document with ID: '${doc.stripeID}'.`);
} else {
if (logs) payload.logger.info(`- Stripe document with ID: '${doc.stripeID}' not found, skipping...`);
}
} catch (error: any) {
throw new APIError(`Failed to delete Stripe document with ID: '${doc.stripeID}': ${error?.message || ''}`)
}
Expand Down