WEBVTT 00:01.660 --> 00:06.490 So we managed to get refunds working the way that we want, and now we have to account for the situation 00:06.490 --> 00:11.230 where if I go to all subscriptions, someone wants to cancel a subscription. 00:11.230 --> 00:17.260 So we go to the amental, we click on the appropriate order in this case for Diana Prince and we try 00:17.260 --> 00:18.100 to refund it. 00:18.250 --> 00:21.100 And it shouldn't say refund, it should say cancel subscription. 00:21.100 --> 00:22.210 But that's neither here nor there. 00:23.020 --> 00:30.220 So I click refund order, try to refund it and I get this long error message back and that's a really 00:30.220 --> 00:31.450 simple one to understand. 00:31.450 --> 00:35.580 It says parameter invalid or empty, and then it gives you a link to the documentation. 00:36.220 --> 00:40.340 But if we look in the database, let's go to our database and we look at the orders. 00:40.390 --> 00:43.120 This is the order in question or four. 00:43.600 --> 00:48.040 So if we go to the transaction ID and click on, that should take us to the transaction. 00:48.490 --> 00:49.480 And it's very end. 00:49.480 --> 00:55.180 We have nothing, underpayment intent and nothing under payment method, then unfortunately that's pretty 00:55.180 --> 00:56.250 easy to fix. 00:56.620 --> 01:02.470 The one thing to bear in mind is that what we're going to get is not actually a payment intent, it's 01:02.470 --> 01:03.130 a subscription. 01:04.000 --> 01:06.380 So let's go back to our code and find out where that's supposed to be. 01:07.420 --> 01:08.530 So back to our editor. 01:08.890 --> 01:15.730 I'm looking at Handler's Dash API, and this is the method that is called Create Customer and subscribe 01:15.730 --> 01:19.800 to plan when someone wants to buy a subscription to our bronze plan. 01:20.440 --> 01:26.830 So if we scroll down a little bit here online, one hundred and forty five in my code, I'm getting 01:26.830 --> 01:33.880 this value subscription back from KO'd Dot subscribed to plan and that subscription actually has the 01:33.880 --> 01:35.010 information that I need. 01:35.470 --> 01:40.930 So if I go down here where I'm building the transaction, I just need to add a feel and it's pretty 01:40.930 --> 01:41.860 simple now. 01:41.860 --> 01:45.160 It's called payment content in our model and our database. 01:45.760 --> 01:51.370 And since it's actually not a payment intent, we really should rename that column in the database and 01:51.370 --> 01:53.680 update the models and so on and so forth. 01:54.340 --> 01:57.370 But I'm actually not going to bother doing that in this situation. 01:57.490 --> 02:01.860 I'm just going to store subscription indeed. 02:02.320 --> 02:04.060 And that gives me a value back. 02:04.060 --> 02:08.310 And it starts with, as you might expect, as you be underscored. 02:09.040 --> 02:13.630 And the other thing I may as well put in here, since I'm here anyway, is the payment method, because 02:13.630 --> 02:14.830 we can get that as well. 02:15.010 --> 02:21.310 We already have a payment method and we got that from our data, the payment method. 02:22.930 --> 02:29.320 And we of course, we have to put a comma here and I'll save this to format it and I'll give it a D 02:29.320 --> 02:30.900 because I don't need those anymore right now. 02:34.210 --> 02:40.390 Now, data, if you recall, we get way up here, it's our straight payload, so we have the payment 02:40.390 --> 02:40.960 method in there. 02:40.990 --> 02:42.000 We might as well put it in. 02:42.370 --> 02:44.680 So let's stop our application and see if this worked. 02:45.820 --> 02:48.220 Make it stop, make a start. 02:49.960 --> 02:53.920 And for now, I'll leave transaction for in there or order for. 02:54.670 --> 02:56.660 It'll create a new subscription and see what happens. 02:57.130 --> 03:07.180 So we'll go to products subscription and I'll make this one say Clark Kent Clark at the Daily Planet 03:07.240 --> 03:08.080 dot com. 03:08.830 --> 03:13.240 Clark Kent with our standard credit card number that always works. 03:14.590 --> 03:19.110 And expiry of zero for twenty nine and five five five. 03:19.360 --> 03:21.040 So we subscribe to this plan. 03:26.540 --> 03:33.860 And that worked, so let's go look in our database, go back to orders, and six will be the most recent 03:33.860 --> 03:35.530 one because it has the highest ID. 03:35.840 --> 03:37.400 So let's look at its transaction. 03:39.410 --> 03:45.470 And if I go over here, you'll see now I have some underscore and then a bunch of characters and payment 03:45.470 --> 03:47.490 method underscore and a bunch of characters. 03:47.870 --> 03:52.250 So now we actually have the information we need to cancel a subscription. 03:52.640 --> 03:54.980 Now, there's quite a bit of work left to do to make this work. 03:55.460 --> 03:56.950 But let's move on.