Skip to content

chore(plugin-stripe): enable TypeScript strict #12303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/plugin-stripe/src/hooks/createNewInStripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const createNewInStripe: CollectionBeforeValidateHookWithArgs = async (ar
syncedFields = deepen(syncedFields)

// api version can only be the latest, stripe recommends ts ignoring it
const stripe = new Stripe(pluginConfig.stripeSecretKey || '', { apiVersion: '2022-08-01' })
const stripe = new Stripe(pluginConfig?.stripeSecretKey || '', { apiVersion: '2022-08-01' })

if (operation === 'update') {
if (logs) {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-stripe/src/hooks/deleteFromStripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const deleteFromStripe: CollectionAfterDeleteHookWithArgs = async (args)
if (syncConfig) {
try {
// api version can only be the latest, stripe recommends ts ignoring it
const stripe = new Stripe(pluginConfig.stripeSecretKey || '', { apiVersion: '2022-08-01' })
const stripe = new Stripe(pluginConfig?.stripeSecretKey || '', { apiVersion: '2022-08-01' })

const found = await stripe?.[syncConfig.stripeResourceType]?.retrieve(doc.stripeID)

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-stripe/src/hooks/syncExistingWithStripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const syncExistingWithStripe: CollectionBeforeChangeHookWithArgs = async

try {
// api version can only be the latest, stripe recommends ts ignoring it
const stripe = new Stripe(pluginConfig.stripeSecretKey || '', {
const stripe = new Stripe(pluginConfig?.stripeSecretKey || '', {
apiVersion: '2022-08-01',
})

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-stripe/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const stripePlugin =
})
}

for (const collection of collections) {
for (const collection of collections!) {
const { hooks: existingHooks } = collection

const syncConfig = pluginConfig.sync?.find((sync) => sync.collection === collection.slug)
Expand Down
14 changes: 3 additions & 11 deletions packages/plugin-stripe/src/routes/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ export const stripeREST = async (args: {
await addDataAndFileToRequest(req)

const requestWithData = req

const {
data: {
stripeArgs, // example: ['cus_MGgt3Tuj3D66f2'] or [{ limit: 100 }, { stripeAccount: 'acct_1J9Z4pKZ4Z4Z4Z4Z' }]
stripeMethod, // example: 'subscriptions.list',
},
payload,
user,
} = requestWithData
const { data, payload, user } = requestWithData

const { stripeSecretKey } = pluginConfig

Expand All @@ -37,8 +29,8 @@ export const stripeREST = async (args: {
}

responseJSON = await stripeProxy({
stripeArgs,
stripeMethod,
stripeArgs: data?.stripeArgs, // example: ['cus_MGgt3Tuj3D66f2'] or [{ limit: 100 }, { stripeAccount: 'acct_1J9Z4pKZ4Z4Z4Z4Z' }]
stripeMethod: data?.stripeMethod, // example: 'subscriptions.list',
stripeSecretKey,
})

Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-stripe/src/routes/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const stripeWebhooks = async (args: {
},
})

const body = await req.text()
const body = await req.text!()
const stripeSignature = req.headers.get('stripe-signature')

if (stripeSignature) {
Expand All @@ -41,7 +41,7 @@ export const stripeWebhooks = async (args: {
}

if (event) {
handleWebhooks({
void handleWebhooks({
config,
event,
payload: req.payload,
Expand All @@ -52,7 +52,7 @@ export const stripeWebhooks = async (args: {

// Fire external webhook handlers if they exist
if (typeof webhooks === 'function') {
webhooks({
void webhooks({
config,
event,
payload: req.payload,
Expand All @@ -65,7 +65,7 @@ export const stripeWebhooks = async (args: {
if (typeof webhooks === 'object') {
const webhookEventHandler = webhooks[event.type]
if (typeof webhookEventHandler === 'function') {
webhookEventHandler({
void webhookEventHandler({
config,
event,
payload: req.payload,
Expand Down
4 changes: 0 additions & 4 deletions packages/plugin-stripe/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
},
"references": [{ "path": "../payload" }, { "path": "../ui" }, { "path": "../next" }]
}
Loading