So I suspect that challenge wasn't terribly difficult for you, but just to be safe, let me show you
how I achieved the goal.
So back over to our idea, and I'll start by looking at the roots apart.
So if you look at the roots for our back end right here on line twenty five where we call API slash,
create customer and subscribe to plan, that's the handler where I have all the information I need in
order to generate an invoice.
So let's look at that.
So the first thing I did was just before this customer and subscribed to Plan Handler is the same thing
I did in the front end.
I created this invoice type which describes the adjacent payload that will be sending to the micro service.
Then a little bit further down, we have this call right here.
It's in the if statement.
So we try to get our subscription.
Then if everything is OK, then we get our product and we got our customer and we save our customer
all the way down here.
I create an invoice and like last time I needed the order ID, so I got it from right here where I called
Save Order.
So that gives me the info that I need.
I just hard coded two zero zero zero for twenty dollars a month and I also hardcoded bronze plan, monthly
subscription, everything else.
I got pretty much the same way I did last time.
But instead of being on data where I get first, first name, last name and email, I happened to call
the variable date of this time around.
And then I call Invoice Micro and then I define that function, which is pretty much exactly the same
as it is.
And the other one, the only difference is that I didn't bother printing out the response body because
I didn't need to.
I know that it works and I tested it and everything works as expected.
So there you have a fully functional micro service and it's a working example that you can use to create
as many micro services as you want.
And as you probably know, sometimes micro services have a database.
Sometimes they don't, as in our case.
And in some cases they'll have their own database.
They won't share the one with other applications that are calling them.
So in this example where we're creating an invoice and sending it in production, I would almost certainly
have this with its own database.
And then I'd create additional routes to this micro service that allows me to do more than just send
an invoice.
I maybe I could retrieve an existing invoice and that would be a pretty straightforward exercise.
You create a new route, you create a new handler and you're off to the races.
So this has been fun.
Let's move on.