Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Jonathon

  1. user table ID, f_name, l_name, date_joined, user_type, date_exp 1 - Larry - Ullman - 11-07-2014, 2, 11-08-2014 user_type ID, type 1 - Free 2 - Paid 1) So you have joined my website. Registration is $1 per month if you want to be a paid member. Upon registration, I send your payemnt info to Stripe. They send me back the info confirming that you paid and it all went through. I look for a "period_end": 1405129609, in the response and I use that to create your date_exp When I am doing usages for the current billing period, I use the date_exp to find out when your paid account finishes and back track 1 month. so 2) COUNT(id) FROM posts, user ON user.id = posts.user_id WHERE posts.date_added BETWEEN DATE_SUB(user.date_exp, INTERVAL 1 MONTH) AND user.date_exp That will give me the number of posts in this case any user has made in their particular billing period. 3) I have a webhook script and it looks for payment_success webhooks. This is how my system sees Larry has paid his new subscription fee. What this does now is take the new period end "period_end": 195246879609 and say Larry's subscription actually runs out now on 11-09-2014 and it takes that date and update your user record's date_exp Usage is just like stats, oh he'd used 10 posts of his available 15 for this month or whatever. Those kind of things. But this means I can get an accurate count on stats for that billing month. Side Note - Although this isn't that related it is worth mentioning, a paid user account has more benefits and permissions that a free account. I have a RBAC set of tables to control this. Say you ended your subscription there would be a time when the current day is greater than your expiry date. I run a cron every day that checks for this occurence, you have a paid user_type and your date_exp is less than today's date. That means you've expired, this cron then resets your user_type to 1 and updates the RBAC tables so you get a free members permissions. Hopefully I haven't lost you with these steps, apologies if I have. Now is the bit that throws a spanner in the works. If I sign you up for a monthly subscription but give you a 6 month free trial through Stripe. Stripe will send me back a "period_end" of 11-01-2015. Which is great in that you won't have expired and have all the permissions for 6 months. But When I run my usage stats using the same kinds of queries as above it will look for posts.date_added BETWEEN DATE_SUB(11-01-2015, INTERVAL 1 MONTH) which would be 11th December 2014 and the 11 January 2015. So any usage style stats I have won't work as you can't post into the future (technically) So I guess my point was, what from a stripe perspective / or code perspective could I do here, I wondered if I didn't know of any cool events. I don't have to use Stripe's period_end to populate the date_exp on creation, I could just do it within the DB or Yii with DATE_ADD(NOW(), INTERVAL 1 MONTH). Which is how I started doing it. But with a 6 month free trial, no payment_succeeded events are sent so my script wouldn't update the user's date_exp and they would through no fault of their own become expired. The only other I thing I've thought of is just charging $0.50 a month for 6 months. So I get the payment_succeeded event, so their account keeps ticking over and I can set their expiry a month in advance, keeping their usage stats from not breaking. Does that make any sense? Thanks Jonathon
  2. Additionally each month you stay on the plan I get a notification from stripe and continue to keep updating your end date. When you have expired and stopped your plan the cron will eventually rest your user type back to 1 and the end date will stay as it was and is unneeded. This process allows me to make sure a user has a paid account and their account hasn't expired. It also means that they get I can accurately count how many posts they have made for their colander month subscription. As not everyone will sign up on the same day. So any trial period with stripe over a month throws my logic out so my counts are wrong and additionally I can't set the expiry of a 6 month trial to 1 month in the future as I would need webhooks each month to keep updating their user end date.
  3. Well I use the end date to determine whether someone has expired. When you sign up for free your user type is 1 and your end dre doesn't really matter as you can't post. When you join a monthly subscription I change your use type to 2 and use the date you've paid up until with stripe as your end date. Each day I run a cron and if you have decided to leave the paid plan and are now past your expired date I reset your user type back to 1. So in short stripe tells me when a paid user has expired effectively because I use the end of a users paid up to point according to stripe. Apologies for not explaining this tht well.
  4. Hi Larry, Let me try and explain better. 1. Larry registers with my site and pays his money 2. Stripe send me back webhooks including the date the payment_period_end (not sure if that's the actual correct webhook name, but you get the idea) 3. I use this date and update the Larry user record to show that Larry's user_plan expires on such a date. Because anyone could register at any time, you could have a user, who's plan runs from the 1st of each month and another user could have the same plan but started on the 15th of each month I use the user_expiry date in the user record to calculate the correct time period. So you sign up on the 1st of July and stripe tells me that your monthly plan expires on the 1st of August so that is your expiry date. So when I want to know how many posts (posting is a perk of having a paid plan) you have used for this current month I use BETWEEN the date_expiry of the user record that comes from stripe and is stored in my DB. so that will give me 1st August and I use DATE_SUB(date_expiry, INTERVAL 1 MONTH); to take me back to the 1st of July. So my count now only looks for posts that were made between 1st July and the 1st August. Does that make sense? So if I have a 6 month free trial on my plan, Stripe's payment_period_end webhook will return 1st January 2015. Which now means all the logic in my models for counts is wrong - So I'm trying to work out a work around for this. Ideally I need payment_succeeded webhooks even if they are for 0.00 to come in each month but I don't believe they do? Jonathon
  5. Hi Larry I'm wondering if you can help me with this problem. I have a site that is on a monthly subscription, it allows a certain numbers of postings per paid user account and I want to give people a really decent trial of it like 6 months free. If I give them a 6 month free trial when they sign up via Stripe it will send back a webhook saying the period expires 6 months into the future. Which is great, the only problem is that I use the expiry end date of a user to calculate how many posts the user has made in the last month. So If a user has a free 6 month trial from today, Stripe sends me back period_end of 29th December 2014, which I update the user expiry to. I then use the end date 29th December 2014 with a DATE_SUB( 29th December 2014, INTERVAL 1 month) to determine how many posts have been made. So my counts are always thrown out by this. Stripe emailed me a few months ago and said that they will only send a payment_succeeded webhook if there is an actual charge on the card. So i'm not really sure what the best way to proceed here is. I want users to have 6 months free, but I always want a webhook each monthly period to update their expiry date. Or some process which allows the end date to be no further than 1 month into the future? Thanks Jonathon
  6. Jonathon

    Digital Ocean

    Started using Mandrill for outgoing mail too. So far it's been very quick and easy to set up for emails being sent out from my scripts.
  7. Jonathon

    Digital Ocean

    Really very quick in terms of just getting emails. Took 10 minutes at most. Name, chosen email to receive from, add a meta tag for site verification, then they just re route the email. Said it can take up to 1 hour though. I just looked at the sending limits https://support.google.com/a/answer/166852?hl=en It's actually 2000 per day too. You can have alias email addresses too
  8. Jonathon

    Digital Ocean

    Went with Gmail to receive. I think for automated emails I may try and use MailGun where I might after a period be sending out too many for Gmails liking.
  9. Jonathon

    Digital Ocean

    Yes I agree, my main concern is security, with serverpilot that seems to be looked after to a good degree. I'd like your thoughts on what you think of the service (when you get a spare minute or two) they offer. I may be missing some huge things they don't cover for instance. https://serverpilot.io/
  10. Jonathon

    Digital Ocean

    I use FZ because it allowed me to use SSH and there were tutorials for it. I find Dreamweaver finicky, it wants definite folder relations that don't change. It varies, on my motivation and what i'm doing. I am currently more focussed on server config currently.
  11. Thanks Larry I "think" mine was a problem with using my .htaccess file when accessing through the server IP. Although I definately did need to change some permissions and I did end up setting most of my folders like protected and public to 777. I read your point to Edward too about it only being people on that server. It;s only me with access to my own VPS. So I feel like I should still be secure. I hope at least.
  12. Jonathon

    Digital Ocean

    Hi Just to give you an idea on Digital Ocean. I've only ever used shared hosting so it was a little daunting but here is a quick overview of what I've done and how easy it was to do. There are promo codes on twitter for it, I got myself a $10 one, which is two months, in terms of setting it up, it really was very quick. I've been using it in conjunction with serverpilot.io. They basically set your apps up, they load, MySQL, PHP-FPM, Apache, Nginx, you can choose what version on PHP to use within your app, configure SSL etc (I'm in the process of doing that now). They basically make sure the website is secure and maintained with updates. I used their guide on installing phpmyadmin and Memcache, so far it's been pretty good, the main issue Im having is moving my SSL because its on my old host and set up to be there, So, I haven't done a lot with digital ocean, but so far their customer service is quick and very helpful. I've set up SSH keys to my droplet and used them to help create new SSL keys. The biggest thing for me was using and getting FileZilla to work, I really feel like I need that GUI interface to upload and adjust files/ permissions/ the file itself etc. I have yet to install elasticsearch or JDK on the server. I've spent a long time making various mistakes, to the point where I even deleted my droplet and just recreated a new one. I think i've got 90% of my Yii site to work., part of the reason I think i'm having trouble is i'm accessing it through the ip address and not the domain as that is all waiting for SSL certs to be reissued and the other half is .htaccess/ yii id to be using just https. It's been interesting, a little overwhelming at times. But I think it's very fair to say that with server pilot that you can have a good base setup for PHP website very very quickly and your sever will be looked after security wise. Installing PHPmyAdmin is a 5 minute job, memcache a 1 minute job. ServerPilot is $0 a month for it's base plan too.Works on a few different cloud BPS providers too. My site does also appear to be really pretty quick, not sure if that's due to using the ip address or not. I'm not even using memcache currently.
  13. I just got set up with DigitalOcean and am going through this now, I'm working on my server ip and my css folders + assets don't want to display, that being said, I did alter their permissions to 777 and they still won't come through. I'm working to try fix that though.
  14. Just seen that Git know which files i've altered. That's handy.
  15. I'm the same, I started using it for my passwords that really matter and got it to generate complex passwords for me.I didn't bother with minor sites, by minor I mean ones that don't have financial stuff in
  16. Yeah, I'm enjoying BitBucket. I was very surprised how fast it was to upload my entire local version of website too. I wanted somewhere to store a back up just in case there was an EMP go off my house or other extreme circumstance that I'd lose my files. So having had a little play with it, and since done some changes with elastic search on my local server, I should add and commit those files to the repo? That's how it should? My main concern is forgetting to add one file out of the dozens I may have changed. I suppose it is bad practice to just keep uploading the whole folder each time? And thank you Larry for all your help more so!
  17. I saw your tweet about changing passwords. I just a couple of hours ago started using password box for my more important passwords, things like Stripe etc and got it to generate strong passwords. It seems a once strong password a few years ago just doesn't cut it. You get 25 free passwords with passwordBox too.
  18. Ok, I see now, I wasn't sure. I'm seriously considering getting a cloud VPS and I saw someone was asking about installing on Git and since my Mac i've been thinking more and more about how to work between two devices. So I learned Git (Not all of it, but enough to get you on your way) last night. BTW BitBucket gives out free private repositories to teams of less than 5 devs. So as it's just me that's fine for me. Oh yeah, I saw it was at 996 the other day. I'm not as active/helpful as I once was. But 1000 is nice.
  19. The first one is useful, but how do you actually push to a live server?
  20. Hi Larry Would you be able to give a little guidance in the process of using Git to maintain a live server. I had git on my computer a while ago, but never really got round to using it. Although it seems fairly easy to use. How or should you use it in general terms to maintain a live server? So far, I have made a private repo from my local version and I have made another private repo of my live code as they differ a few ways, mainly due to config for DB etc and for web hooks. What would I need to do to be able to use GIT to update a live server? Do a git init command on my live sever and then clone + push + add files through the command line on my server? I saw this answer and felt like I was on the right kind line http://stackoverflow.com/a/12517125/895169
  21. I feel like it would bea decent option if it isn't too hard to configure. I'm thinking mainly of cron jobs you may for people who have signed up for the newsletter I have for instance. I could still use Google Apps email for general email enquiries and be inside their limits. I'm trying to get an idea of exactly what I'll need to do with regards to using a cloud VPS. Mailgun have a high volume 10,000 emails per month for free too which is nice.
  22. That's just adding the MX records isn't and that's it? I can send and receive emails no problem. There's nothing else to it. My only concern is the limits Google apply to your account. I think it's 99 per day. Would MailGun be a useful tool if you needed to send automated emails from Crons that may span more than 99 emails?
  23. Serverpilot.io recommended rackspace and Google apps. Rackspace said you have to buy 5 mailboxes. so it would be $10 per month. I saw Google Apps was $5 too. Would it be hard to set up Google Apps on a cloud VPS?
  • Create New...