0:00 All right, so in this lecture, let's go ahead and finish creating our 0:04 create 0:04 payment handler. 0:06 Now that we have the order and the actual 0:09 pricing details for that order, thanks to our pricing adapter, 0:14 we're finally ready to complete it by first checking to see if we already 0:18 have an existing payment 0:20 and transition its state, and then finally create the checkout 0:23 session with 0:23 our payment adapter. So in order to do this, now after we 0:27 validate that pricing does exist, we're gonna create a 0:31 new let to record the underlying payment. 0:35 So let's record the payment entity type, 0:38 and then we'll check to see if existing is true, meaning we already 0:41 have a existing payment by this order ID. 0:46 Then what we want to do is set payment to this dot, 0:50 and now we want to use the event publisher because we are going to 0:54 be emitting events from the payment eventually. 0:57 And so in order for that to work inside of our CQRS, we 1:01 know we need to wrap it with the event publisher. 1:05 So I'm gonna go ahead and inject 1:07 the event publisher 1:10 of type EventPublisher. 1:12 And now what we can do is wrap our payment entity in the 1:17 EventPublisher.MergeObjectContext. 1:21 And now at this point, we can just pass in the existing entity. 1:24 It already exists, and now we're able to emit events from it. 1:27 Now, this will be a key step later on when we do actually emit events. 1:32 So we have the payment that is able to do that. 1:34 Now, this is upsert functionality, remember, we're implementing on this 1:39 handler. If the payment does already exist, we have 1:43 it, and that's fine. Otherwise, we now need to initiate a new payment and 1:47 save it. So for that, we'll go in the else block and now set
The rest of the transcript is for members.
Sign in