Skip to content

Commit 43c670d

Browse files
authored
feat: support customer deletion (#89)
1 parent c744103 commit 43c670d

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This server synchronizes your Stripe account to a Postgres database. It can be a
4444
- [ ] `checkout.session.async_payment_succeeded`
4545
- [ ] `checkout.session.completed`
4646
- [x] `customer.created` 🟢
47-
- [ ] `customer.deleted`
47+
- [x] `customer.deleted` 🟢
4848
- [ ] `customer.source.created`
4949
- [ ] `customer.source.updated`
5050
- [x] `customer.subscription.created` 🟢

src/routes/webhooks.ts

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default async function routes(fastify: FastifyInstance) {
4444
break
4545
}
4646
case 'customer.created':
47+
case 'customer.deleted':
4748
case 'customer.updated': {
4849
const customer = event.data.object as Stripe.Customer
4950
await upsertCustomers([customer])

test/stripe/customer_deleted.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"id": "evt_1IlZRsJDPojXS6LN2AbFmnR4",
3+
"object": "event",
4+
"api_version": "2020-03-02",
5+
"created": 1619701111,
6+
"data": {
7+
"object": {
8+
"id": "cus_IhGfebO16cMIGN",
9+
"object": "customer",
10+
"deleted": true
11+
}
12+
},
13+
"livemode": false,
14+
"pending_webhooks": 4,
15+
"request": {
16+
"id": "req_QyDCzn33ls4m1t",
17+
"idempotency_key": null
18+
},
19+
"type": "customer.deleted"
20+
}

test/webhooks.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('/webhooks', () => {
2525

2626
test.each([
2727
'customer_updated.json',
28+
'customer_deleted.json',
2829
'product_created.json',
2930
'product_deleted.json',
3031
'product_updated.json',

0 commit comments

Comments
 (0)