So we managed to get refunds working the way that we want, and now we have to account for the situation
where if I go to all subscriptions, someone wants to cancel a subscription.
So we go to the amental, we click on the appropriate order in this case for Diana Prince and we try
to refund it.
And it shouldn't say refund, it should say cancel subscription.
But that's neither here nor there.
So I click refund order, try to refund it and I get this long error message back and that's a really
simple one to understand.
It says parameter invalid or empty, and then it gives you a link to the documentation.
But if we look in the database, let's go to our database and we look at the orders.
This is the order in question or four.
So if we go to the transaction ID and click on, that should take us to the transaction.
And it's very end.
We have nothing, underpayment intent and nothing under payment method, then unfortunately that's pretty
easy to fix.
The one thing to bear in mind is that what we're going to get is not actually a payment intent, it's
a subscription.
So let's go back to our code and find out where that's supposed to be.
So back to our editor.
I'm looking at Handler's Dash API, and this is the method that is called Create Customer and subscribe
to plan when someone wants to buy a subscription to our bronze plan.
So if we scroll down a little bit here online, one hundred and forty five in my code, I'm getting
this value subscription back from KO'd Dot subscribed to plan and that subscription actually has the
information that I need.
So if I go down here where I'm building the transaction, I just need to add a feel and it's pretty
simple now.
It's called payment content in our model and our database.
And since it's actually not a payment intent, we really should rename that column in the database and
update the models and so on and so forth.
But I'm actually not going to bother doing that in this situation.
I'm just going to store subscription indeed.
And that gives me a value back.
And it starts with, as you might expect, as you be underscored.
And the other thing I may as well put in here, since I'm here anyway, is the payment method, because
we can get that as well.
We already have a payment method and we got that from our data, the payment method.
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
because I don't need those anymore right now.
Now, data, if you recall, we get way up here, it's our straight payload, so we have the payment
method in there.
We might as well put it in.
So let's stop our application and see if this worked.
Make it stop, make a start.
And for now, I'll leave transaction for in there or order for.
It'll create a new subscription and see what happens.
So we'll go to products subscription and I'll make this one say Clark Kent Clark at the Daily Planet
dot com.
Clark Kent with our standard credit card number that always works.
And expiry of zero for twenty nine and five five five.
So we subscribe to this plan.
And that worked, so let's go look in our database, go back to orders, and six will be the most recent
one because it has the highest ID.
So let's look at its transaction.
And if I go over here, you'll see now I have some underscore and then a bunch of characters and payment
method underscore and a bunch of characters.
So now we actually have the information we need to cancel a subscription.
Now, there's quite a bit of work left to do to make this work.
But let's move on.