Skip to content

Commit ec49979

Browse files
committed
Handles customer.subscription.paused webhook
1 parent a1c6df7 commit ec49979

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/sveltekit/src/lib/server/webhooks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export async function handleWebhook(billing, body, signature) {
1010
case 'customer.subscription.updated':
1111
case 'customer.subscription.deleted':
1212
case 'customer.subscription.trial_will_end':
13+
case 'customer.subscription.paused':
1314
await billing.syncSubscription(object.id)
1415
console.log(`Synced subscription ${object.id}`)
1516
break

packages/sveltekit/src/lib/server/webhooks.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,19 @@ describe('handleWebhook', () => {
8787

8888
expect(billing.syncSubscription).toHaveBeenCalledWith('sub_1234')
8989
})
90+
91+
test('when subscription.paused event, syncs subscription', async () => {
92+
stripe.webhooks.constructEvent.mockReturnValue({
93+
type: 'customer.subscription.paused',
94+
data: {
95+
object: {
96+
id: 'sub_1234'
97+
}
98+
}
99+
})
100+
101+
await handleWebhook(billing, 'fake-body', 'fake-sig')
102+
103+
expect(billing.syncSubscription).toHaveBeenCalledWith('sub_1234')
104+
})
90105
})

0 commit comments

Comments
 (0)