1
- import { PaymentProvider } from '@prisma/client'
1
+ import { DonationType , PaymentProvider } from '@prisma/client'
2
2
import Stripe from 'stripe'
3
3
import { getCountryRegion , stripeFeeCalculator } from './stripe-fee-calculator'
4
4
import { RecurringDonationStatus , Currency } from '@prisma/client'
@@ -56,7 +56,7 @@ export function getPaymentData(
56
56
billingEmail : charge ?. billing_details ?. email ?? paymentIntent . receipt_email ?? undefined ,
57
57
paymentMethodId : getPaymentMethodId ( paymentIntent ) ,
58
58
stripeCustomerId : getPaymentCustomerId ( paymentIntent ) ,
59
- type : paymentIntent . metadata . type ,
59
+ type : paymentIntent . metadata . type ?? DonationType . donation ,
60
60
personId : ! isAnonymous ? paymentIntent . metadata . personId : undefined ,
61
61
}
62
62
}
@@ -80,7 +80,7 @@ export function getPaymentDataFromCharge(charge: Stripe.Charge): PaymentData {
80
80
billingEmail : charge ?. billing_details ?. email ?? charge . receipt_email ?? undefined ,
81
81
paymentMethodId : 'card' ,
82
82
stripeCustomerId : charge . billing_details ?. email ?? undefined ,
83
- type : charge . metadata . type ,
83
+ type : charge . metadata . type ?? DonationType . donation ,
84
84
personId : ! isAnonymous ? charge . metadata . personId : undefined ,
85
85
}
86
86
}
@@ -96,7 +96,7 @@ export function getInvoiceData(invoice: Stripe.Invoice): PaymentData {
96
96
personId = line . metadata . personId
97
97
}
98
98
if ( line . metadata . type ) {
99
- type = line . metadata . type
99
+ type = line . metadata . type ?? DonationType . donation
100
100
}
101
101
} )
102
102
0 commit comments