A developer demonstrates integrating Stripe payments into a NestJS microservice architecture. The tutorial covers creating and billing reservations, handling observables, implementing global validation pipes, managing unauthorized requests, and dynamically extracting Stripe invoice IDs for persistence while troubleshooting API payment method requirements.
Length 9:41
Captions English (Generated), Spanish (Auto-translated), French (Auto-translated), Korean (Auto-translated), Portuguese (Auto-translated), Vietnamese (Auto-translated) #nestjs #microservices #stripe #typescript #backend #api #programming #web development #validation #debugging
0:00 Before we actually go ahead and create the reservation in our 0:03 database, I wanna go ahead and actually bill the user for this 0:07 using the newly created charge DTO and our payments service. 0:12 So let's go ahead and change this out to be a new cons 0:14 called 0:15 reservation, 0:17 and this will be equal to 0:20 await this.reservationsrepository.create. 0:23 We'll go ahead and call our payment service, and to use this, 0:26 make sure we actually 0:27 label this as a private read-only variable. 0:30 And then we'll go ahead and call await 0:32 this.paymentservice.send, where we know we, of course, 0:36 need to specify the pattern here, and we know that in the 0:39 payments controller, 0:41 we called this create charge. So let's go ahead and send 0:45 a create charge. And then the data itself here is going 0:49 to be the createreservationdto.charge 0:53 object here. And recall that this is actually returning an observable 0:57 here, so we won't await this actually, but we're gonna go ahead 1:01 and actually subscribe to this observable 1:05 here. Will be executed after the response gets 1:08 sent back 1:09 successfully. And so after we actually send the charge 1:13 off and in the subscribe block, this is where we want to actually go ahead and 1:16 create the reservation. So we'll make this an 1:20 async function here where we can go ahead and create the 1:23 reservation, and I'll go ahead and return it directly in this 1:27 async block. And additionally, let's go ahead and actually get the 1:31 response back in the subscribe block here so that we can 1:35 actually go ahead and log it out. 1:38 So before we return the reservation, we can actually log out 1:42 the response here just for some debugging purposes. 1:46 So if I go ahead and send a request off to our reservations route 1:50 here and make sure we are, of course, authenticated first, I
The rest of the transcript is for members.
Sign in