@@ -92,6 +92,7 @@ export const stripePaymentRow = {
9292 stripeCustomerId : t . option ( t . string ( ) ) ,
9393 stripeInvoiceId : t . option ( t . string ( ) ) ,
9494 amount : t . i64 ( ) ,
95+ amountRefunded : t . i64 ( ) ,
9596 currency : t . string ( ) ,
9697 status : t . string ( ) ,
9798 createdUnix : t . i64 ( ) ,
@@ -102,6 +103,17 @@ export const stripePaymentRow = {
102103 updatedAt : t . timestamp ( ) ,
103104} ;
104105
106+ export const stripeRefundRow = {
107+ stripeRefundId : t . string ( ) . primaryKey ( ) ,
108+ stripePaymentIntentId : t . string ( ) ,
109+ amount : t . i64 ( ) ,
110+ currency : t . string ( ) ,
111+ status : t . string ( ) ,
112+ eventCreatedUnix : t . i64 ( ) ,
113+ insertedAt : t . timestamp ( ) ,
114+ updatedAt : t . timestamp ( ) ,
115+ } ;
116+
105117export const stripeInvoiceRow = {
106118 stripeInvoiceId : t . string ( ) . primaryKey ( ) ,
107119 stripeCustomerId : t . string ( ) ,
@@ -202,6 +214,20 @@ const stripePaymentOptions = {
202214export const stripePaymentTable : ReturnType <
203215 typeof table < typeof stripePaymentRow , typeof stripePaymentOptions >
204216> = table ( stripePaymentOptions , stripePaymentRow ) ;
217+ const stripeRefundOptions = {
218+ name : 'stripe_refund' ,
219+ public : false ,
220+ indexes : [
221+ {
222+ accessor : 'byPaymentIntent' ,
223+ algorithm : 'btree' ,
224+ columns : [ 'stripePaymentIntentId' ] ,
225+ } as const ,
226+ ] ,
227+ } ;
228+ export const stripeRefundTable : ReturnType <
229+ typeof table < typeof stripeRefundRow , typeof stripeRefundOptions >
230+ > = table ( stripeRefundOptions , stripeRefundRow ) ;
205231const stripeInvoiceOptions = {
206232 name : 'stripe_invoice' ,
207233 public : false ,
@@ -292,6 +318,7 @@ const tables: {
292318 stripeSubscription : typeof stripeSubscriptionTable ;
293319 stripeCheckoutSession : typeof stripeCheckoutSessionTable ;
294320 stripePayment : typeof stripePaymentTable ;
321+ stripeRefund : typeof stripeRefundTable ;
295322 stripeInvoice : typeof stripeInvoiceTable ;
296323 stripeWebhookEvent : typeof stripeWebhookEventTable ;
297324 stripeWebhookPruneTick : typeof stripeWebhookPruneTickTable ;
@@ -302,6 +329,7 @@ const tables: {
302329 stripeSubscription : stripeSubscriptionTable ,
303330 stripeCheckoutSession : stripeCheckoutSessionTable ,
304331 stripePayment : stripePaymentTable ,
332+ stripeRefund : stripeRefundTable ,
305333 stripeInvoice : stripeInvoiceTable ,
306334 stripeWebhookEvent : stripeWebhookEventTable ,
307335 stripeWebhookPruneTick : stripeWebhookPruneTickTable ,
@@ -444,6 +472,14 @@ const vInvoicePaymentObject = v.object({
444472 payment : v . object ( { payment_intent : v . optional ( vExpandableId ) } ) ,
445473} ) ;
446474
475+ const vRefundObject = v . object ( {
476+ id : v . string ( ) ,
477+ amount : v . number ( ) ,
478+ currency : v . string ( ) ,
479+ status : v . union ( [ v . string ( ) , v . null ( ) ] ) ,
480+ payment_intent : v . optional ( vExpandableIdOrNull ) ,
481+ } ) ;
482+
447483function vEvent < const T extends string , const O extends v . GenericSchema > (
448484 type : T ,
449485 object : O
@@ -475,6 +511,10 @@ export const vStripeEvent = v.variant('type', [
475511 vEvent ( 'invoice_payment.paid' , vInvoicePaymentObject ) ,
476512 vEvent ( 'payment_intent.succeeded' , vPaymentIntentObject ) ,
477513 vEvent ( 'payment_intent.payment_failed' , vPaymentIntentObject ) ,
514+ vEvent ( 'refund.created' , vRefundObject ) ,
515+ vEvent ( 'refund.updated' , vRefundObject ) ,
516+ vEvent ( 'refund.failed' , vRefundObject ) ,
517+ vEvent ( 'charge.refund.updated' , vRefundObject ) ,
478518] ) ;
479519
480520export type ParsedStripeEvent = v . InferOutput < typeof vStripeEvent > ;
0 commit comments