#115 More on Stripe and Subscriptions

Summary

In our previous episode, we looked at setting up our application to create Stripe Subscriptions. In this episode, we will look at managing the Subscriptions and working with cancelling and resubscribing to a subscription.
payments rails 11:50
  • Student & Teacher
  • $9.00 / month
  • Valid School Email Required
  • Same Access as Pro
  • Subscribe Now
  • Pro Monthly
  • $15.00 / month
  • Access to Pro Episodes
  • Invite to Slack Channel
  • Priority Episode Suggestions
  • Ad Free
  • Subscribe Now
  • Pro Annual
  • $150.00 / year
  • Access to Pro Episodes
  • Invite to Slack Channel
  • Priority Episode Suggestions
  • Ad Free
  • Subscribe Now
  • Teams
  • starts at $75.00 / month
  • 5 Users Minimum
  • $15.00 / user / month
  • Same Access as Pro
  • Subscribe to Teams
there are turning to ah to add a turn around and learned learned a thing is that certain to look at adding teams right elements to take any credit card to their describing he is certainly service or application and in this episode with no luck yet cancelling is is gretchen and also being able to greece's cried but then also displaying the charges so we're getting from strike when a subscription is cancelled will look at adding a expiration date where the user so has access to these is quite content until their suspension ends with a ex aly cancel there's a scratch and with an enema get adding anybody says cried so that they can breeze ascribed to the service without any in a rush into the service or any additional charges until the next billing date and to accomplish as we will be using the web looks on strike they were also when they need to create some can import so that the application to be read or to use a service called in crop so to start off in the can fake routes daughter be fall well what did create two different important and ours is scripture these stories are kinda balances scribe and bacon grease is right so within visas which is what does create a block we get is something like a ged and says scribe been a breeze ascribe but this is a following the wrestle styles so sad when it created resource and i'm gonna call the first one and b and subscribe they know the resource and i'm going to call this one says what and for the ads ascribe only one to create the end point for the destroyer action and for the breezes right i'll create the year point four only be an election if we run the rails routes we can see are two new path there's something so we wanna clean up in europe but if you look under the your ide pattern this isn't a very pretty you ride and this is gretchen id we really don't need because only the current user is going to be able to describe and we should be able to get their suspension i'd be so we are to modify the us to where the subscription id is not needed clever if you do have a situation where a user does have multiple subscriptions then you may need to leave the cinema and alert appropriate week when we're in our case we just won't be employed to be something like subscriptions unsubscribed or subscriptions jesus christ entity that is fairly simple or will just create a collection amanda block they will move both of these into that block so that inner turmoil will call rails routes again in a big easy we do have a description to describe the case of scripture described in this points to the un says gripes controller and to be destroyed action and the breeze ascribe points to the breezes right into the new action said this isn't too big of a deal but one thing that would annoy me if we strictly follow the russell reynolds then we're already have a bullet to these different hundred controllers and if you get really confusing love with their exact purpose and what they are relating to it's all about like to do is to take each one of these controllers and put them under a suspensions controller so whenever you look in these within the files you didn't know that they relate to these discussions and relatively what they're going to do it's a back in the routes we can create a scalp reddit has any module that we're going to reference is gretchen so they were going to read this collection within the scope so know each one of these controllers should fall under these descriptions module it's a free one rare rails routes now you can now see that for odds ascribed in our reese's cried we're under these inscriptions on describes in the suspensions races scribes and so in our own says once controller what does but it's a boilerplate where we have our mortal suspension sets because we're under the modules suspensions here which is basically just named spacing are for hierarchy the way creator class and describes controller and we will inherit from the application to troll or so within our destroy method we need to get our customer is cause for work which is said to work for user you're going to get the strike cause more this is a method that the strike gym will give us so we don't have to do anything fancy with it as is going to work we even better subscriptions and would then again nurses questions from our customer that we can call the subscriptions in and retrieve and to retrieve the suspension we do have to pass and any subscription i'd be there we did store them from our previous episode under these francisco to ninety we get bassett are crying user to get this information that we can simply called the weed and this will delete the subscription and to just clean this up a bit so it's easier to see so we have our cars were suspensions for retrieving the subscription and there were debating it and the problem with this is that if we just simply delete the subscription and then it's basically gone the users get a beep bananas situation where they want to be subscribed then they're going ahead to pay again in order to prescribe so all we do is add a bad period then sent this to true and this will keep the description but then it'll make a call within strike so whenever the suspension is about to expire at all cancel it at that point so the users should be able to prescribe without ever having to provide a credit card again or without having to pay again it'll just becomes is to switch and at its current plan as for 'em were ever left off celebrity is alexis labs that they would have to be says granted so as far as strident we have cancelled the suspension and it's going to expire whenever they're period ends however we saw the lead our application know that this user of is ended their suspension and that they're now in this period where they're suspicious cancelled but they sell it paid for access for the duration of theirs is gretchen the first one center current user will update some variables the personnel will do is update the strike suspension i'd be more gazette this to know because we don't want this information anymore with their database because they are no longer quotes is cried we also want to be able to capture when this is switching is going to and support inadequate in other attributes or their user model with something like expires that expires them were just what is said to jesus scratch and that the changes from april to singular because we are taught about what's is gretchen work in the set this is the current period and then so be air date time stamp that's gonna be returned from ours is gretchen what's it's been deleted so that weekend and reference it here we update our user we even read the record these are the sages back to the good path and wishes give the menendez said you can soldiers is gretchen it would also be nice to tell the users that they have access and tell some date and time to measure be when their crime period and it's so we can just reference secret user expires at and work then it just changes to ebay there were a bit as good in some international unsafe to the format this state a bit nicer in the current period and it is going to be returned as a pep talk number so we'll need to call time and to come for this from a laptop number which is jessica i'm gonna from january first nineteen seventy at midnight the dc until mel so-called time and will cover those from any app october into a date and time and so within our welcome and x h t m l if you're a member from our previous episode if the user is ascribed all had this is prime essence began to spread out their suspension id so now we want to create the link so they are currently says pride that we want to welcome to cancel this is gretchen we get as in the us is sweatpants there were also then it just make sure that taking government said this will make a java script all are and then just give it some styling the week you had to call it a method to leave because our action that we're posting to do is destroy and with this consoles is gretchen link we would want to show this all the time we are within the current users described it was occurring user has the expires at set and so within our terminal now we cannot create a migration to look to scott wells did great migration expires ed to users or to create the edge of the expires at this going to be the time the chevron rails to be my credit and so within our resists wives controller what has been our boilerplate code year in there with their class we says scribes controller inheriting from the applicator controller and the breezes pride is a new action so we can create ours is gretchen because we no longer had these description i'd be making get our current user and the strike customer get in the pond they you could run into heavy user does have multiples of scripture and is a you'll need to find out which is gretchen that they have i had kids and is that read the first one because the user within this application can only have one description to resist crime is really just a simple as calling pieces with shouldn't say so say it's a switch and that's a the order book form some action that will update their suspension otherwise we'll just notified the user of an error so if it does successfully save the wheel corcoran user then update the listeners french suspension id look to the subscription ninety the wheels one a makeshift so ease said or expires at the mill if anything was successful that will just give them a flash know this and maybe we get savings for reasons were living or if there was a problem goes a problem this is frightening may we can read write them back to the group that it's a better view we invaded know the link to an assemblage is one employee called to prescribe them that this going to be the new pieces cried path in the way he does sets of silent we only want to display this that the current user does have it expires at that said they do have a expires at the we know that there's this question has been cancelled and then they had the option to be subscribed so that's before we passes out in the mind that these roaring going to look for if the current user is long dead and if they are says cried so within our user model this is why bad that we created our previous episode we may need to create a or conditions were they had the stretch description i'd be more the expires outset and so it it says is out now we're currently lol didn't know we're currently says cried you click on it cancels is gretchen no ask us up for sure it's a no way of cancel their subscription will have access until february twenty first we couldn't resist pride they were given our suspension i'd be in our next episode we're gonna look im listening in for the strike boy books and and interacting with the subscription successful charges in the field charges that's all for this episode they keep watch it