Transcript
Hello friends. In this episode, they're going to set up, uh, mono Gun, the Rails eight software as a service power plate application to run locally. So here is the public GitHub repository. I'm going to clone it locally. I already have it running in my local GitHub. I'm going to open it in, uh, my code editor. I will run, uh, bundle. It's going to bundle all the gems. Now I can say Rails to be, uh, crate. I have already created the database. So I'll run Rails to be migrate and I can run Rails to be seed. Or if I have already privileged run seed, I've already run them with the same seed replant. And if I look at my seeds, I already have an example user that belongs to a few different organizations. So let's run the server bin slash dev and let's log in as this user here, I have a basic homepage. Let's go to log in, uh, signing in. And you see I'm part of a few different organizations. I can open one of the organizations. It has an empty dashboard. It has, uh, empty projects. I can switch within the organizations. I can add the users to an organization, or I can change the organization settings And see, I don't have billing set up yet, so I don't have like possibility to subscribe an organization to pay the plan because I don't not yet set up Stripe. So let's set up Stripe to work with these organizations with this, uh, application. So here I have a new Stripe account and I'm going to set it up. I will go to developers here. I have API Keys and I will need to add them to my application. So let's open the credentials. Now. Uh, I will, uh, open the credentials. Let's, let's say in, uh, VIM editor, um, editor Vim Rails credentials edit. Uh, you see it, uh, tried to open the credentials, but we didn't have Master key present because they just blown the repository. So it generated a new master key, but it, uh, the new master key doesn't match the existing credentials, so it cannot decrypt. So I will need to delete the existing master key, delete the existing credentials. And again, I will open the rails credentials. You see it opened. So I have the default credentials with some empty stripe key data generated from credentials by mail. From this template file, I have, uh, an example credential. Now, um, if you are not a fan of Vim, maybe you would want to add the credentials in this code or cursor. I will with the credentials here, and I can, uh, export, uh, cursor and open the credentials in Cursor. So you see now it's going to be a bit, uh, easier for me to add the, the credentials. I will go copy with the publishable key, uh, copy with the secret key, uh, save and exit. And now let's try, uh, seeing if, uh, they can deliver web hooks. So I will go to add an endpoint test locally. Uh, log into Stripe. I have already previously installed the Stripe CLI. Okay, open allow access to the, uh, workspace. Okay, uh, I have, uh, connected my Stripe, CLI. Now let's start delivering in sound up hooks, as it says here. And to add the Stripe listener. So they're not going to listen to this endpoint, but they're going to listen to the one from, uh, profile dev, local host 3000 slash pay webhooks Stripe. It is where we deliver our webhooks. So I'm going to listen to this in another terminal. I will run the rail server and in another one I will, uh, try to deliver a hook. So I'm going to cope with this trigger a payment then succeeded. And let's see. So in our Ruby process, we get some kind of, uh, uh, error, uh, No signatures found mentioned the expected signature for payload. And in Stripe we get four, four or 400 errors. So the web hook was not delivered. Why it? So, because when the setting up the credentials, we did not add add a, a correct web hook key. So let's, uh, go back and add a web hook key. Again, I will, um, export cursor. I will run rails credentials. And here I need to add the sign-in secret. So here from the example, I need to add this, uh, specific sign-in secret. Let's add it. And uh, now save exit. I will, uh, restart the rails server. 'cause I've updated the credentials. I don't need to restart the stripe process. I think let's, uh, try triggering an event again. Okay, so you see something that's happening in the successful in the Ruby process and in Stripe, you see there was a successful, uh, response. So we have set up, uh, web hooks and stripe to work well locally. Now let's, uh, go and have a look at the application. I will, uh, refresh it. Okay, I need to sign in once again. Okay. And you see now I have the billing module set up and I have some kind of, uh, default prices. Now, where does this come from? 99 per month. 999 per year. If in Stripe we did not set up neither any customers, nor did they set up any products, they'll need to set them up. And the default, uh, values come from our settings, v ml file settings, v ml. It is where we have the stripe prices and the, the display values defined. So let's create some stripe prices. I will create a product, let's say Mangan Pull Pro. And we are going to add a couple of products. So, uh, prices. So there'll be a month plan and a yellow plan. And the price will be in Euros, for example. So let's make it 50 euros, uh, per month. And we'll add one more price within this product. That will be, uh, Euro 500 per year. So kind of two months free, uh, billing period is going to be yearly. Okay? So we have a product and it has, uh, two prices. And now I will go to one, to the smaller price of this. And, uh, I will set upsells. So upsells to the yellow plan. And now I need to add this, uh, updated price data to our prices in our settings. So first of all, we are going to have, uh, the price be not 99, uh, a hundred, so not $99 per uh, month, but 50 euros per month. So 50 euros, zero 0 cents. And here 500 euros, zero 0 cents. And the same here and here. And we need to set up the newly credit price IDs. So, uh, we are looking at the 50 per month price. I will copy it here. And, uh, for now, we can just top the same price ideas for production and development. So, um, investing up the idea of the monthly price. And now let's have a look at the yearly price. We'll go the, ID paste it here and here. Now if, go back here and refresh. You see we already have 50 euros per month and 500 euros per year. Let's try, uh, subscribing this organization. I'm going to subscribe the bus sprout organization to a monthly plan. Okay? I will, uh, pay with card, uh, pay and subscribe. And, uh, I expect, uh, you see web hooks are coming in. I expect us to redirect back to the organization and have it subscribed. So that subscription status should be green. And here we are. You see it says subscription active Next, pulling data. So it, uh, works. I can have a look at all my organizations and you see that the status of the bus product organization is, uh, green. So it works. Okay. So I've set up, uh, Stripe to work, uh, locally. Now, to make it work in production, you would want to have, uh, different stripe, uh, API keys for development mode and production. And you would maybe want to have, uh, uh, AWS uh, three storage for images like, uh, uh, editors of organizations here. See, you can change the logo of an organization. So, yes, that's it. See in the next one. And they're going to talk about how to deploy mon gun to production with post posts scale, and with the solid trifecta.
0