@@ -113,7 +113,8 @@ export class PaymentMethodController extends GivingCrudController {
113113 @httpGet ( "/personid/:id" )
114114 public async getPersonPaymentMethods ( @requestParam ( "id" ) id : string , req : express . Request < { } , { } , null > , res : express . Response ) : Promise < any > {
115115 return this . actionWrapper ( req , res , async ( au ) => {
116- const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { } , this . repos . gateway ) . catch ( ( ) => null ) ;
116+ // Default to Stripe for payment method operations (vault requires Stripe or PayPal)
117+ const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { provider : "stripe" } , this . repos . gateway ) . catch ( ( ) => null ) ;
117118 const permission = gateway && ( au . checkAccess ( Permissions . donations . view ) || id === au . personId ) ;
118119 if ( ! permission ) return this . json ( { } , 401 ) ;
119120
@@ -228,9 +229,10 @@ export class PaymentMethodController extends GivingCrudController {
228229 @httpPost ( "/addcard" )
229230 public async addCard ( req : express . Request < any > , res : express . Response ) : Promise < any > {
230231 return this . actionWrapper ( req , res , async ( au ) => {
231- const { id, personId, customerId, email, name, churchId } = req . body ;
232+ const { id, personId, customerId, email, name, churchId, provider } = req . body ;
232233 const cId = au ?. churchId || churchId ;
233- const gateway = await GatewayService . getGatewayForChurch ( cId , { } , this . repos . gateway ) . catch ( ( ) => null ) ;
234+ // Default to Stripe for card operations, but allow frontend to specify provider
235+ const gateway = await GatewayService . getGatewayForChurch ( cId , { provider : provider || "stripe" } , this . repos . gateway ) . catch ( ( ) => null ) ;
234236
235237 if ( ! gateway ) {
236238 return this . json ( { error : "Payment gateway not configured" } , 400 ) ;
@@ -328,8 +330,8 @@ export class PaymentMethodController extends GivingCrudController {
328330 @httpPost ( "/updatecard" )
329331 public async updateCard ( req : express . Request < any > , res : express . Response ) : Promise < any > {
330332 return this . actionWrapper ( req , res , async ( au ) => {
331- const { personId, paymentMethodId, cardData } = req . body ;
332- const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { } , this . repos . gateway ) . catch ( ( ) => null ) ;
333+ const { personId, paymentMethodId, cardData, provider } = req . body ;
334+ const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { provider : provider || "stripe" } , this . repos . gateway ) . catch ( ( ) => null ) ;
333335 const permission = gateway && ( au . checkAccess ( Permissions . donations . edit ) || personId === au . personId ) ;
334336 if ( ! permission ) return this . json ( { error : "Insufficient permissions" } , 401 ) ;
335337 try {
@@ -356,7 +358,8 @@ export class PaymentMethodController extends GivingCrudController {
356358 return this . actionWrapper ( req , res , async ( au ) => {
357359 const { personId, customerId, email, name, churchId } = req . body ;
358360 const cId = au ?. churchId || churchId ;
359- const gateway = await GatewayService . getGatewayForChurch ( cId , { } , this . repos . gateway ) . catch ( ( ) => null ) ;
361+ // ACH SetupIntent is Stripe-only
362+ const gateway = await GatewayService . getGatewayForChurch ( cId , { provider : "stripe" } , this . repos . gateway ) . catch ( ( ) => null ) ;
360363
361364 if ( ! gateway ) {
362365 return this . json ( { error : "Payment gateway not configured" } , 400 ) ;
@@ -472,7 +475,8 @@ export class PaymentMethodController extends GivingCrudController {
472475 public async addBankAccount ( req : express . Request < any > , res : express . Response ) : Promise < any > {
473476 return this . actionWrapper ( req , res , async ( au ) => {
474477 const { id, personId, customerId, email, name } = req . body ;
475- const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { } , this . repos . gateway ) . catch ( ( ) => null ) ;
478+ // Bank accounts are Stripe-only
479+ const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { provider : "stripe" } , this . repos . gateway ) . catch ( ( ) => null ) ;
476480 const permission = gateway && ( au . checkAccess ( Permissions . donations . edit ) || personId === au . personId ) ;
477481 if ( ! permission ) return this . json ( { error : "Insufficient permissions" } , 401 ) ;
478482
@@ -516,7 +520,8 @@ export class PaymentMethodController extends GivingCrudController {
516520 public async updateBank ( req : express . Request < any > , res : express . Response ) : Promise < any > {
517521 return this . actionWrapper ( req , res , async ( au ) => {
518522 const { paymentMethodId, personId, bankData, customerId } = req . body ;
519- const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { } , this . repos . gateway ) . catch ( ( ) => null ) ;
523+ // Bank operations are Stripe-only
524+ const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { provider : "stripe" } , this . repos . gateway ) . catch ( ( ) => null ) ;
520525 const permission = gateway && ( au . checkAccess ( Permissions . donations . edit ) || personId === au . personId ) ;
521526 if ( ! permission ) return this . json ( { } , 401 ) ;
522527 try {
@@ -531,7 +536,8 @@ export class PaymentMethodController extends GivingCrudController {
531536 public async verifyBank ( req : express . Request < any > , res : express . Response ) : Promise < any > {
532537 return this . actionWrapper ( req , res , async ( au ) => {
533538 const { paymentMethodId, customerId, amountData } = req . body ;
534- const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { } , this . repos . gateway ) . catch ( ( ) => null ) ;
539+ // Bank verification is Stripe-only
540+ const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { provider : "stripe" } , this . repos . gateway ) . catch ( ( ) => null ) ;
535541 const permission =
536542 gateway &&
537543 ( au . checkAccess ( Permissions . donations . edit ) || ( await this . repos . customer . convertToModel ( au . churchId , await this . repos . customer . load ( au . churchId , customerId ) ) . personId ) === au . personId ) ;
@@ -549,7 +555,9 @@ export class PaymentMethodController extends GivingCrudController {
549555 @httpDelete ( "/:id/:customerid" )
550556 public async deletePaymentMethod ( @requestParam ( "id" ) id : string , @requestParam ( "customerid" ) customerId : string , req : express . Request < { } , { } , null > , res : express . Response ) : Promise < any > {
551557 return this . actionWrapper ( req , res , async ( au ) => {
552- const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { } , this . repos . gateway ) . catch ( ( ) => null ) ;
558+ // Determine provider from payment method ID prefix (pm_ and ba_ are Stripe)
559+ const isStripe = id . startsWith ( "pm_" ) || id . startsWith ( "ba_" ) ;
560+ const gateway = await GatewayService . getGatewayForChurch ( au . churchId , { provider : isStripe ? "stripe" : "paypal" } , this . repos . gateway ) . catch ( ( ) => null ) ;
553561 const permission =
554562 gateway &&
555563 ( au . checkAccess ( Permissions . donations . edit ) || ( await this . repos . customer . convertToModel ( au . churchId , await this . repos . customer . load ( au . churchId , customerId ) ) . personId ) === au . personId ) ;
0 commit comments