Payment
Now for the payment logic. In the controller, let's add a route to pay an order.
Register the order inside the TypeOrmModule
in the PaymentsModule
, as we'll use a repository for it in the next step. Now, in the service, we'll create the method that makes a payment.
First, an order
will be searched for, and brought with its payment
. If the order
is not found, or a payment
is already present, an exception is thrown. Then, a payment
will be created. After that, the order
will have the payment
associated with it, and change its status
to AWAITING_SHIPMENT
. Finally, the order
will be saved together with the payment
.
Commit - Implementing payment logic
Last updated