@@ -13,15 +13,9 @@ import {
1313import {
1414 DefaultPaymentMethod ,
1515 SubPlatPaymentMethodType ,
16- StripePaymentMethod ,
17- PayPalPaymentMethod ,
16+ type PaymentMethodTypeResponse ,
1817} from './types' ;
1918
20- type PaymentMethodTypeResponse =
21- | StripePaymentMethod
22- | PayPalPaymentMethod
23- | null ;
24-
2519@Injectable ( )
2620export class PaymentMethodManager {
2721 constructor (
@@ -46,10 +40,7 @@ export class PaymentMethodManager {
4640 uid : string
4741 ) {
4842 let defaultPaymentMethod : DefaultPaymentMethod | undefined ;
49- const paymentMethodType = await this . determineType (
50- customer ,
51- subscriptions
52- ) ;
43+ const paymentMethodType = await this . determineType ( customer , subscriptions ) ;
5344 switch ( paymentMethodType ?. type ) {
5445 case SubPlatPaymentMethodType . Link :
5546 case SubPlatPaymentMethodType . Card :
@@ -82,10 +73,10 @@ export class PaymentMethodManager {
8273 return defaultPaymentMethod ;
8374 }
8475
85- async determineType (
76+ async determineType (
8677 customer ?: StripeCustomer ,
8778 subscriptions ?: StripeSubscription [ ]
88- ) : Promise < PaymentMethodTypeResponse > {
79+ ) : Promise < PaymentMethodTypeResponse > {
8980 // First check if payment method is PayPal
9081 // Note, this needs to happen first since a customer could also have a
9182 // default payment method. However if PayPal is set as the payment method,
@@ -107,22 +98,22 @@ export class PaymentMethodManager {
10798 return {
10899 type : SubPlatPaymentMethodType . ApplePay ,
109100 paymentMethodId : customer . invoice_settings . default_payment_method ,
110- }
101+ } ;
111102 } else if ( paymentMethod . card ?. wallet ?. type === 'google_pay' ) {
112103 return {
113104 type : SubPlatPaymentMethodType . GooglePay ,
114105 paymentMethodId : customer . invoice_settings . default_payment_method ,
115- }
106+ } ;
116107 } else if ( paymentMethod . type === 'link' ) {
117108 return {
118109 type : SubPlatPaymentMethodType . Link ,
119110 paymentMethodId : customer . invoice_settings . default_payment_method ,
120- }
111+ } ;
121112 } else if ( paymentMethod . type === 'card' ) {
122113 return {
123114 type : SubPlatPaymentMethodType . Card ,
124115 paymentMethodId : customer . invoice_settings . default_payment_method ,
125- }
116+ } ;
126117 } else {
127118 return {
128119 type : SubPlatPaymentMethodType . Stripe ,
@@ -132,6 +123,5 @@ export class PaymentMethodManager {
132123 }
133124
134125 return null ;
135- } ;
136-
126+ }
137127}
0 commit comments