Avoid Braintree recurring-billing for a single subscription - braintree

I need to let users choose to block a monthly recurring-bill.
Default subscription options are:
never_expires: true,
number_of_billing_cycles: nil
Is
never_expires: false,
number_of_billing_cycles: 0
the proper update to a subscription to accomplish that? Is 0 allowed as value for number of billing cycles? I want to update the subscription for a single user so that is not paying on the following month

Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
You should be able to accomplish your goal through creating a discount. You'll need to create a discount associated with a plan via the Control Panel. However, via the API you'll be able to add a discount to the subscription. Specifically, you should create a discount on the subscription that equals the amount of the subscription in order to bypass a month.

Braintree doesn't really do this (at least, that I can tell...)
The way I would approach a 'free month' sort of thing is to simply do a refund for that month https://developers.braintreepayments.com/guides/recurring-billing/manage/php#refunding-a-subscription

Related

Laravel Cashier incrementQuantity() tidy invoicing

Has anybody here dealt with incrementing subscriptions for "admin" users? Also, how do you handle invoicing and first/second-month charges in a neat manner?
I have a use case where users can sign up other subscribers and pay for these subscriptions from their card on file. The "admin" user signs up for the first subscription, and I keep incrementing the original sub every time a new sub is added.
When I send these through Cashier, the user only seems to get charged once, and then the second, third, etc., the first-month cost gets added onto the next month's invoice, and a new line item of unused time every time the admin user adds a new sub. So I first do:
$request->user()->newSubscription()->create();
Then I do:
$request->user()->subscription()->incrementQuantity();
The user only gets charged one monthly charge at newSubscription()->create(), And the next month's invoice has the following math.
(# of Subscriptions x Monthly Charge) - (Monthly Charge)
And the invoice has a ton of line items saying "Unused Time ..." which looks OK if that admin user only has one or two additions to their subscription but gets messy real quick beyond that. This seems super unprofessional and annoying to explain to the admin users. How do you/would you guys go about making this smoother? I understand that the invoicing for the incrementQuantity() method is enforced by the Stripe API, but it doesn't make sense to have so many prorating adjustments in a first invoice.
What is your goal/desired behavior here? Laravel cashier does allow you to change how you want the prorations to behave. By default prorations will be created and pulled into the next invoice, but you can also choose to disable prorations entirely or create prorations and have them immediately invoiced so that the difference is price is paid for immediately.
If you don't want any prorations generated at all when you update the quantity of a Subscription you can use noProrate() (see laravel's docs). Disabling prorations entirely may not be what you want though, since it won't allow you to charge a customer for the difference in price when they update mid-cycle. As an example, if you start off with a quantity: 1 Subscription they'll be charge for just 1 unit at the start of the month. If prorations are turned off and you update to quantity: 5, the customer won't have to pay for the new price until the subscription is renewed. If this is still what you want to do, you'd use it like this: $request->user()->subscription()->noProrate()-> incrementQuantity().
Another option would be to keep generating prorations, but have them immediately invoiced so that they aren't reflected in the renewal invoice at the end of the month. This will result in the customer being invoiced more often, but would solve your issue where the renewal invoice looks cluttered because of all the prorations. You would get this behavior by using alwaysInvoice() like this: $request->user()->subscription()->alwaysInvoice()-> incrementQuantity().

Laravel payment multi subscriptions

I am working on a SAAS project where users can create various projects. With each project, they can choose from 5 different plans. Each plan has its own costs per month. Hotjar is a kind of equal concept.
Now I want to arrange the subscription with Stripe. The problem with that was that a user can have a maximum x subscription, which of course was a shame. Then I decided to take 1 subscription that has several plans. But now I have a dilemma, to update the subscription you have to change the number via SubscriptionItem. Then you have to save yourself which plan has which SubscriptionItem_id for which user. That is quite a detour and can cause many problems.
Someone is a better way with Stripe or another payment software.
You don't necessarily need to store the subscritpion_item IDs, you can look it up via the subscription_item list API. All you need to do is store the subscription_id for your customers, and based on that ID you can retrieve the list of subscription_items:
\Stripe\Stripe::setApiKey("sk_test_9GavlLpfiKewqeCBXvRvmVgd");
\Stripe\SubscriptionItem::all(["subscription" => "sub_EQlPGjVj4o5luH"]);
Then you can handle the data part of the returned JSON object and update / delete / etc these subscription items.
If you only have the customer_id handy, then you can use the subscription list API (with status as well on the GET params) to retrieve the list of active subscriptions.

Stripe: Expire/Cancel subscription after n payments

In our app, we create subscriptions for users which is working good, subscription can vary on type of plan. But I am not able to figure out how to cancel subscription after user has fully paid.
Is there any parameter we can tell stripe at the time of creation of subscription that tells it when subscription should cancel OR tell it to cancel it after n number of payments?
So essentially if customer bought a product which costs 1000, we would charge him 100 a month but then automatically cancel subscription once he has fully paid.
Thanks for the help
I answered this here: Stripe cancel subscription at specific date
Stripe just added this to their API and I happened to stumble upon it. They have a field called "cancel_at" that can be set to a date in the future. They don't have this attribute listed in their documentation since it is so new. You can see the value in the response object here:
https://stripe.com/docs/api/subscriptions/create?lang=php
I've tested this using .NET and can confirm it sets the subscription to expire at value you provide.
When you create a subscription in Stripe, there is no way to tell Stripe to stop the subscription after N months or when a given amount in reached.
From the documentation:
By default, a subscription continues, and the customer continues to be
billed, until it’s canceled
So what you could do is to cancel the subscription once a given condition is met.
You could use webhooks to get notified every time the customer is billed, at the end of every billing cycle, using the invoice.payment_succeeded event (documentation here).
Somehow you could keep track of the total amount paid by the customer in your database and the amount that is left before the item you sell is "fully paid".
Everytime you get the webhook, you increment the total and, if the required amount in reached, you cancel the subscription so that the customer will not be billed the next month.

Stripe Custom Recurring Donations

Let me tell you first that Stripe is working perfectly for me with Sinatra.
The thing is, for recurring payments, i have to create plans on Stripe. I have this requirement on my donations page. It works well for fixed amounts for which i created plans.
My question is what should i do when a user enters an amount like $54 for which i don't have plans in stripe? Do i create plans on the fly for each new donation amount? That seems a little too stretched for me. Is there any other way around this?
The recommended way to do this by the stripe people is to have a subscription for a base amount, and then listen via webhooks for an "invoice created" event. You can then create an invoice item to adjust the amount depending on the user's preferred cost.
The invoice itself is send to the customer an hour after creation so you have that window in which you can add invoice items to adjust the total.
It's explained here...
https://support.stripe.com/questions/metered-subscription-billing
This is not ideal as it would be nicer to have a "set and forget" solution, and it almost seems like the "creating plans on the fly" would be the easier way to go.

how can i decrease the product price on cart page?

If the user has an existing account balance, I'd like to give him the option to specify how much of his previous balance to apply to the item and sync this info with the cart and order. I have already implemented the user's account balance, both on the front and back end.
Would a coupon-like system work best, or should I try something else?
Thanks in advance.
I would let the customer decrease its cart total with the balance would be more simple / logic for the customer also (?)
What E-commerce solution do you use? Magento(?) If so there are coupon extensions that can handle this.
You could also build a simple balance system where users would see there balance in there account ( if such feature is implemented) or just mail them a message with a unique code that you save in DB + the value of balance then use this code as a coupon on checkout.
We have created quite a few e-commerce solutions up to date. Usually, when user balance is involved, then what you do is create two transactions referred to one invoice. In the first transaction specify the amount taken from balance, where as leave the other transaction for whatever checkout method you use. Upon callback from the checkout, see if the balance paid matches the invoice to mark it as paid respectfully.
Alternatively, you can use discount - decrease user balance and add "discount" to the order. It all depends on your accounting needs and preferences.
On Amazon they allow you to apply any unused balance to the existing order. Its when you checkout that they say you have $150 credit on your account, would you like to apply this to your order, it defaults to yes in a tick box.
Its quite neat and simple, it doesn't allow you to apply a part amount from what I've seen.
Then when you go to payment you pay $total - balance.
So if you have $200 total, the payment via credit card would be for the $50.

Resources