WEBVTT 00:02.210 --> 00:07.010 So I suspect that challenge wasn't terribly difficult for you, but just to be safe, let me show you 00:07.010 --> 00:08.530 how I achieved the goal. 00:08.930 --> 00:14.250 So back over to our idea, and I'll start by looking at the roots apart. 00:14.870 --> 00:22.910 So if you look at the roots for our back end right here on line twenty five where we call API slash, 00:23.030 --> 00:28.850 create customer and subscribe to plan, that's the handler where I have all the information I need in 00:28.850 --> 00:30.020 order to generate an invoice. 00:30.140 --> 00:30.950 So let's look at that. 00:32.150 --> 00:38.360 So the first thing I did was just before this customer and subscribed to Plan Handler is the same thing 00:38.360 --> 00:39.200 I did in the front end. 00:39.440 --> 00:44.860 I created this invoice type which describes the adjacent payload that will be sending to the micro service. 00:45.650 --> 00:50.690 Then a little bit further down, we have this call right here. 00:52.010 --> 00:53.480 It's in the if statement. 00:54.200 --> 00:56.380 So we try to get our subscription. 00:56.540 --> 01:02.210 Then if everything is OK, then we get our product and we got our customer and we save our customer 01:02.660 --> 01:03.970 all the way down here. 01:04.760 --> 01:11.840 I create an invoice and like last time I needed the order ID, so I got it from right here where I called 01:11.840 --> 01:12.650 Save Order. 01:12.660 --> 01:14.150 So that gives me the info that I need. 01:14.570 --> 01:20.840 I just hard coded two zero zero zero for twenty dollars a month and I also hardcoded bronze plan, monthly 01:20.840 --> 01:22.810 subscription, everything else. 01:23.060 --> 01:25.220 I got pretty much the same way I did last time. 01:25.220 --> 01:29.690 But instead of being on data where I get first, first name, last name and email, I happened to call 01:29.690 --> 01:31.250 the variable date of this time around. 01:31.670 --> 01:38.270 And then I call Invoice Micro and then I define that function, which is pretty much exactly the same 01:38.270 --> 01:38.780 as it is. 01:38.780 --> 01:43.160 And the other one, the only difference is that I didn't bother printing out the response body because 01:43.160 --> 01:43.880 I didn't need to. 01:43.910 --> 01:47.770 I know that it works and I tested it and everything works as expected. 01:48.470 --> 01:53.600 So there you have a fully functional micro service and it's a working example that you can use to create 01:53.600 --> 01:55.310 as many micro services as you want. 01:55.730 --> 01:59.600 And as you probably know, sometimes micro services have a database. 01:59.600 --> 02:01.490 Sometimes they don't, as in our case. 02:01.760 --> 02:04.190 And in some cases they'll have their own database. 02:04.190 --> 02:06.840 They won't share the one with other applications that are calling them. 02:07.490 --> 02:13.100 So in this example where we're creating an invoice and sending it in production, I would almost certainly 02:13.100 --> 02:14.750 have this with its own database. 02:14.750 --> 02:19.490 And then I'd create additional routes to this micro service that allows me to do more than just send 02:19.490 --> 02:20.090 an invoice. 02:20.420 --> 02:26.660 I maybe I could retrieve an existing invoice and that would be a pretty straightforward exercise. 02:26.690 --> 02:30.440 You create a new route, you create a new handler and you're off to the races. 02:30.890 --> 02:32.620 So this has been fun. 02:32.720 --> 02:33.440 Let's move on.