Changing subscription plans and billing the difference - paypal

I am trying to implement seat based pricing but the documentation doesn't cover scenarios for changing plan mid subscription.
For reference these are the docs I am following: https://developer.paypal.com/docs/api/subscriptions/v1/
Let me give you an example. Lets say I have this pricing:
1-10 seats $5 each per month
11+ seats $3 each per month
To mimic this in PayPal I create 2 quantity based subscription plans. One with a quantity price of $5, the other for $3. Both plans are on the same product and have term set to monthly.
There are a few situations I am unsure how to handle and cannot find this information in the docs. They are as follows:
1) User signs up for 1 seat on the 1st June. On the 15th June they decide to change to 5 seats. The docs say this will be adjusted in the "next billing cycle" but I am unclear what that means. Their next billing cycle is in 15 days so does that mean they get access to 4 seats for free that month? What I would want to happen is the difference is calculated. The user has paid $5 so far and is halfway through the month so half a month cost is $2.50. The new subscription price is $25. So the remainder of the month would cost $12.50. So the difference to pay is $10 to cover them to the end of the month with the additional seats until they will then be billed $25 for a full month. Is this in anyway possible?
2) User signs ups for 5 seats. They then upgrade to 20 seats halfway through the month which moves them onto a different plan to get discounted pricing. How does situation 1 play out again in this regard when changing plans? How are the differences calculated and billed?
It seems in the old billings API you could override the setup cost when creating the subscription but that no longer seems possible. It is not possible to add the setup cost to a plan because this needs to be added dynamically based on the elapsed time in billing cycle, change in seat quantity and change in plan cost.
Have PayPal really removed all possible ways of dealing with package upgrades?

To have new arbitrary costs, setup or otherwise, you would need to dynamically create a bespoke package/plan for that particular checkout.

Related

Paypal Subscription : Adjustment of the amount on revised plan

In the paypal subscription, we have integrated the revised subscription feature for our system.
Subscription flow working fine, but when the user upgrade or downgrade their plans in mid of the subscription cycle, do we have any option to adjust their subscription amount?
Example :
Customer has purchased the Plan A with price $100 for 1 month recurring plan.
After 15 days, customer is upgrading to the Plan B with price $500
In that case currently no extra charge is executed by the Paypal for that 15 days, From the next payment cycle paypal will charge $500, So how can we manage that 15 days extra charge for that upgraded plan?
For the upgrade we want to manage refund for the adjustment amount and for the upgrade we want to charge extra adjustment amount.
Thank you in advance.
We did solution as below, if anyone need help for the case.
If customer purchase Plan A with price $100 and upgrade subscription to Plan B After 15 days.
So, customer used plan for 15 days and remaining 15 days amount will be return
Before moved to next plan. Previous plan's subscription will be cancel and calculated amount will be refund.
Calculation:
Charged amount = (price * plan used days) / duration (In Days)
Charged amount = ($100 * 15) / 30
Charged amount = $50
Refundable amount = Price - Charged amount
Refundable amount = $100 - $10
Refundable amount = $50
Simply we are giving refund before starting new plan and generating new subscription with new amount.
Create a new plan with a 1 month trial period for the prorated/adjusted amount you want to bill next, and a regular period for the amount you want to bill ongoing. Use this plan to revise the subscription.

Creating ERD and Relational Schema

I wanna know how to make an ERD OR Relationship Scheme out of this. I've been practicing ERD's but this one is really confusing the hell out of me.
This is what I could make out of the narrative currently but not exactly sure how correct I am.
The owner/manager of SCBD, gives you the following information: SCBD conduct a number of
different tours to known microbrewery regions around Victoria. Each Daytrip has an ID, and a
description, and may run many times in a year (such as the West Daytrip). Frequency depends
on the season and the specific daytrip.. Each time it is run it is called an ‘Event’. Each event has
a fee. Fees have usually increased by around 10% each year. SCBD have a number of
customers. Each customer has a name, ID and gender. SCBD customers make bookings for
daytrip events. Payment is made by credit card. (you do not have to worry about recording
credit card details etc.). The date that a booking is made is also recorded.

Reactive systems - Reacting to time passing

Let's say we have a reactive sales forecasting system.
Every time we make a sale we re-calculate our Forecast for future sales.
This works beautifully if there are lots of sales triggering our re-forecasting.
What happens however if sales go from 100 events per second, to 0. And stay 0 for a long time?
The forecast we published back when sales were good stays being the most up to date forecast.
How would you model in this situation an event that represents 'No sales happening' without falling back to some batch hourly/minutely/arbitrary time segment event that says 'X time has passed'.
This is a specific case of a generic question - How do you model time passing with nothing happening in an event based system - without using a ticking clock style event which would wake everyone up to reconsider their current values [an implementation which would not scale].
The only option I have considered that makes sense:
Every time we take a sale, we also schedule a deferred event 2 hours in the future that asks us to reconsider our assessment of that sale.
In handling that deferred event we may then choose to schedule further deferred events for re-considering.
Considering this is a very generic scenario, you've made a rather large assumption that it's not possible to come up with a design for re-evaluating past sales in a scalable way unless it's done one sale at a time.
There are many different scale related numbers in the scenario, and you're only looking at the one whereby a single scheduled forecast updater may attempt to process a very large number of past sales at the same time.
Other scalability issues I can think of:
Reevaluating the forecast for every single new sale doesn't sound great if you're expecting 100s of sales per second. If you're talking about a financial forecasting model for accounting, it's unlikely it needs to be updated every single time the organisation makes a sale, if the organisation is making hundreds of sales a second.
If you're talking about a short term predictive engine to be used for financial markets (ie predicting how much cash you'll need in the next 10 seconds, or energy, or other resources), then it sounds like you have constant volatility and you're not really likely to have a situation where nothing happens for hours. And if you do need forecasts updated very frequently, waiting a couple of hours before triggering a re-update is not likely to get you the kind of information you need in the way you need it.
With your approach, you will end up with one future scheduled event per product (which could be large), and every time you make a sale, you'll be dropping the old scheduled event and scheduling a new one. So for frequently selling products, you'll be doing repetitive work to constantly kick the can down the road a bit further, when you're not likely to ever get there.
What constitutes a good design is going to be based on the real scenario. The generic case is interesting to think about, but good designs need to be shaped to their circumstances.
Here are a few ideas I have that might be appropriate:
If you want an updated forecast per product when that product has a sale, but some products can sell very frequently, then a good approach may be to throttle or buffer the sales on a per product basis. If a product is selling 50 times a second, you can probably afford to wait 1 second, 10 seconds, 2 hours, whatever and evaluate all those sales at once, rather than re-forecasting 50 times a second. Especially if your forecasting process is heavy, doing it for every sale is likely to cause high load for low value, as the information will be outdated almost straight away by the next sale.
You could also have a generic timer that updates forecasts for all products that haven't sold in the last window, but handle the products in buffers. For example, every hour you could pick the 10 products with the oldest forecasts and update them. This prevents the single timer from taking on re-forecasting the entire product set in one hit.
You could use only the single timer approach above and forget the forecast updates on every sale if you want something dead simple.
If you're worried about load from batch forecasting, this kind of work should be done on different hardware from the ones handling sales.

Facebook ads API daily_budget update limitations

I'm trying to update ads with daily budgets. From FB API we learn that:
When updating a set's lifetime or daily budget to a lower value, the new value must be at least 10% greater than the current amount spent already. For example: if an ad set has a $1000 lifetime budget and has spend $300 so far, the lowest new lifetime budget would be $330.
Does this rule mean that if we want to update the daily budget of an Adset, the new daily value must be at least 10% greater than the current amount already spent in the SAME day and the next day we can set any budget as long as it is > $1 and is at least twice our bid?
For example: if an ad set has a $10 daily budget and has spent $5 since the beginning of the day, the lowest new daily budget would be $5.5. The next day budget doesn’t depend on previous days budgets. Right?
Thanks for your help!
Facebook has updated the logic for lifetime_budget. It now sates:
An updated budget begins spending from zero (if there's a switch in budget types, the entire set spend to date is set to zero for the purposes of calculating the remaining budget).
Accordingly, if you update the daily budget to $20, it will spend 20 dollars for that day in addition to what it has already spent for the given day. From next day onwards it should work as $20 daily budget.

paypal button for buy 1 year, get 6 months free

I want to make a Paypal button for buy 1 year, get 6 months free
It's rather easy to setup a free trial period, but in that case the first billing doesn't hit until the trial period is finished. That sucks.
We want to run a promotion where the free trial period comes at the END. So they pay for a full year today, and aren't billed again for another 18 months, at which point they are billed for another year of service, and the yearly billing cycle continues from there.
Billing for the trial period of 18 months won't solve my problem because there are 3 different checkout options and the trial period applies to all of them as a whole (they are different prices).
We have 3 subscription types, and 3 promotions. So it seems like I have to make 9 different buttons to solve my problem?? How can it be done a better way?
Solved this. I just had to make a separate buttons for each. For example:
I wanted the first subscription type to pay 1 year, get 6 months free.... In Paypal I selected yearly billing for X dollars, then chose an 18 months promotion (and the cost of the promotion was set to the same cost as the regular yearly billing).
This way, we get paid from the first second, the customer still gets their "free trial" which I guess isn't technically a free trial. It's more like a 50% discount for the first 1.5 years.