Skip to content

Commit

Permalink
stripe: Add endpoint for setupintent cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
sashko9807 committed Apr 29, 2024
1 parent c2d293f commit f596144
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apps/api/src/stripe/stripe.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Logger,
NotFoundException,
Param,
Patch,
Post,
Query,
UnauthorizedException,
Expand Down Expand Up @@ -85,6 +86,12 @@ export class StripeController {
return this.stripeService.updateSetupIntent(id, idempotencyKey, updateSetupIntentDto)
}

@Patch('setup-intent/:id/cancel')
@Public()
cancelSetupIntent(@Param('id') id: string) {
return this.stripeService.cancelSetupIntent(id)
}

@Post('setup-intent/:id/payment-intent')
@ApiBody({
description: 'Create payment intent from setup intent',
Expand Down
3 changes: 3 additions & 0 deletions apps/api/src/stripe/stripe.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export class StripeService {
* @returns {Promise<Stripe.Response<Stripe.PaymentIntent>>}
*/

async cancelSetupIntent(id: string) {
return await this.stripeClient.setupIntents.cancel(id)
}
async findSetupIntentById(setupIntentId: string): Promise<Stripe.SetupIntent | Error> {
const setupIntent = await this.stripeClient.setupIntents.retrieve(setupIntentId, {
expand: ['payment_method'],
Expand Down

0 comments on commit f596144

Please sign in to comment.