I am new to PHP. I am creating a system which shows customers, subscription package, and balance amount.
I have created user CRUD system and Packages CRUD System. What I want to have is to increase balance amount every 30 days, basically like recurring subscription. What I need is basic guideline.
This works like this -
Created a customer
Assigned him a Package
Balance amount increases every 30 days
(I'm Stuck on 3rd Point)
Well, the basic approach would be to:
Do NOT keep track of a "balance", but register the "end date" of the subscription. You can both keep track of the last month paid as the end date of the contract. Actually you can register more dates and make this as complicated as you want.
The "basic guideline" is that in the database you store dates and not balances. This allows you to only make changes as part of a transaction (like paying changing/adding a contract).
Hope this different approach helps you.
Related
So I was wondering if this is possible on stripe starting a trial period for two months after a paid month for $xx and when the trial ends It will unsubscribe them automatically to the plan.
I don't know if this is the method I'm looking for, I'm open for suggestions like after the first invoice of the subscription I will add Discount Coupon for 100% for the next 2 month then unsubscribe right after the third invoice.created.
It would probably be simpler to set the recurrence to 3 months. Then you could add a webhook subscriber to invoice.created events, which occur about an hour before payment is taken, and cancel the subscription when an event (with maybe some logic if this only applies to certain plans) is received. Your logic is significantly reduced in this way.
As you mentioned, you could apply a 100% discount, with a repeating duration with max_redemptions set to 2. I have a feeling that this will be more complex to manage - though possible.
I'm not sure about retrospectively adding trial to an existing subscription - I think it's only available on creation.
So I am using stripe to allow my customers to do recurring billing (on-demand cleaners), the problem I have that at the moment there are 30+ plans a user could be assigned to depending on their inputs. For example:
User 1:
Cleaning interval = every 4 weeks
House size - 4 bed
plan = A
User 2
Cleaning interval = every 6 weeks
House size - 2 bed
plan = B
The above example has loads of permutations, so obviously as we get bigger and we move countries the permutations become greater.
Now my solution to scalability was to create a plan per user (would this scale to 100k plans in stripe)?
The second solution was to do token based payments and setup a cron or something similar to process it (how easy would it be)
I am using PHP, so any solution would more than likely be done in this
I would love some feedback or even case studies on how to solve this
Oliver
Stripe does not restrict the number of plans you can create, so you could potentially have tens of thousands of different plans.
However, that doesn't seem like a very good solution. What you could do instead is use the "metered billing" payment flow:
Create a plan for $0 / month (or whatever interval you want to use)
Create subscriptions to bind customers to this plan
At the end of each billing period, a new invoice will be automatically created and an invoice.created event will be sent. Using webhooks, you could catch this event on your server and create invoice items for the actual amount you want to bill.
Approximately one hour later, the invoice will be closed and payment will be attempted. Depending on the result, either an invoice.payment_succeeded or invoice.payment_failed event will be sent.
If the payment fails, it will be retried according to your subscription settings.
Since it seems you have different billing intervals, you might need to create a few different plans (all for $0, but with different intervals), but the general idea still applies.
Requirement:
We want to have a base subscription which is X/month, done via recurring payments, and give clients the ability to choose extra "add-ons" as they please. An "add-on" will be Y/Month and should last the remainder of the base subscription. For example, the base subscription is 10/month and feature X is extra 5/month and feature Y is an extra 7/month. I choose to have the base subscription with feature X and Y so my total monthly payment for a year will be 22/month. Now, if I chose only the base subscription for the first 6 months and want to start using feature X for the final 6 months of my subscription, the final 6 months should be 15/month opposed to the previous 10/month. In further terms, add-on features subscription should last the duration of the base subscription.
Is there a simple way to do this via the PayPal API?
Actual recurring payments profiles (setup with Standard or Express Checkout) have a limit on how much you can raise the amount of a profile. You can only raise it by 20% every 180 days. If you create a recurring payments profile with Payments Pro, though, then there is no such limit and you can change the amount at any time to whatever you need. I wouldn't recommend going without EC, though, as lots of people prefer to pay with PayPal.
What you could do, though, instead of using the recurring payments APIs would be to use billing agreements / reference transactions. This way you'd save the billing agreement / auth ID in your database and then you can use the DoReferenceTransaction API to process any variable amount you need to at any time.
So in that case you would basically be building your own recurring payments system where you'll save the "next payment date" in your database, and then you'll have an automated script run each day to process all of the payments that are due that day via a reference transaction.
Reference transactions work with Payments Pro, too, so if you're using that everything would still work the same.
Since you're working with PHP I'd recommend taking a look at my class library for PayPal. It will make all of these API calls very simple for you.
So I am dealing with Authorize.net's ARB, and I have a situation where the user is applying for usage of our service for eg. 3 months. We charge the user for this period - 3 months, but we don't make a subscription immediately. The thing is, we don't want to automatically charge them again once the membership expires after 3 months, but only if they go to account settings and set that option (extend membership automatically). So if they don't select it, there is no need to establish a subscription, so that's why we aren't doing it in starting point, once the user applies for this service.
So the question is, should I create a new subscription once user selects "Yes" for that option, and delete the subscription when he selects "No" ?
Is there another way to do it?
It's really hard to find some answers by Google, and I was hoping someone with more experience will have an answer here.
Thanks in advance.
When the user selects "Yes" for the new subscription just create a new ARB subscription with a start date of three months past their three month trial period. The three month subscription will run its normal course and terminate after three months. Then the new subscription will start at that point.
But here's the catch with that solution: you need the customer's credit card information in order to recreate another subscription. Unless you store it somewhere (bad idea) you can do that. So you would need to ask for it again. That's a large hurdle to overcome and will negatively affect conversion rates.
Alternatively you can automatically create the three month subscription at the point where the user starts their three month trial. As they approach the end of the three month trial you should make them aware there subscription will automatically start unless they cancel it. This solves the creation of the subscription problem but isn't very popular with users as nobody likes being automatically enrolled in a subscription.
Third option is to use Authorize.Net's CIM API to create a payment account for that user. Then you can charge against their card whenever you want. The problem with that is CIM does not support subscriptions. So you'd have to write your own subscription engine to make this work.
So there is no ideal solution for this. You just need to pick the one that you think works best for you.
I am working on an application that provides a 30 day trial, then the option to have a monthly or yearly subscription (at two different prices).
I've used a lot of the info provided by John Conde on his site (thanks John), but want to be sure I've got the right idea about how all this works - my first time doing anything with Authorize.net or subscriptions...
So if I have a 30 day trial, and someone decides they want to pay today, they should not be billed for 60 days. I set the start date ahead 60 days, but should I see any kind of charge in Authorize.net showing it's pending?
Next, is part of the ARB service that it "watches" for the renewal, or am I supposed to do something to trigger the check on a regular basis. I'm pretty sure that's what ARB is, and I don't need cron to check each day, but I'd rather ask a dumb question now rather than have a bunch of missing charges later.
Finally, what information would you recommend I store in my local DB and what should I let the ARB service capture. Currently, I'm storing what the subscription item is, who the person who is making payment is (by id), the name on the card, the last four digits of the card in case they want to reference what was used, the expiration date of the card, so I can look for pending expirations (unless this is part of ARB as well) and the date the subscription starts, ends.
Any additional info is appreciated.
So if I have a 30 day trial, and
someone decides they want to pay
today, they should not be billed for
60 days. I set the start date ahead 60
days, but should I see any kind of
charge in Authorize.net showing it's
pending?
Use the AIM API to charge their initial payment and then set the start date in ARB to be in 60 days (when their first payment is). You won't get any notice that the subscription is "pending" but if a subscription ID is returned to you by the ARB API then it's safe to assume that first payment will be attempted in 60 days.
Next, is part of the ARB service that
it "watches" for the renewal, or am I
supposed to do something to trigger
the check on a regular basis. I'm
pretty sure that's what ARB is, and I
don't need cron to check each day, but
I'd rather ask a dumb question now
rather than have a bunch of missing
charges later.
You don't have to do anything. The "A" in ARB stands for Automated and it is completely automated. Once a payment is scheduled it will run automatically until the subscription ends, you cancel the subscription, or their card expires and you don't update it before the next scheduled bill date.
Finally, what information would you
recommend I store in my local DB and
what should I let the ARB service
capture. Currently, I'm storing what
the subscription item is, who the
person who is making payment is (by
id), the name on the card, the last
four digits of the card in case they
want to reference what was used, the
expiration date of the card, so I can
look for pending expirations (unless
this is part of ARB as well) and the
date the subscription starts, ends.
Send as much information to the ARB API as you can. It makes researching transactions in the Authnet control panel much easier as you can compare what you have captured to what they show in their transaction history.
It sounds like you're storing information that will be useful to you. I'd encrypt anything credit card related as to make it less useful if your DB gets hacked. You store enough information that a hacker could use it to convince your customers that they have their credit card number and then things get really ugly.
Well, in general you should avoid storing CC info (for security reason), so keeping everything at ARB would be better.
You should schedule the payments right when the user registers and set the startDate in the SOAP-call to 60 days later. Store the transaction key or however they call, so you can cancel the subscription at ARB anytime. If you do it that way, you can avoid handling payments at all and you just need to handle subscription and unsubscription.