Does Laravel Spark Support Stripe Quantities? - php

In Laravel Spark, (it's my understanding) you can tie your billing plan to a billing plan already setup in Stripe with code that looks something like this
Spark::plan('Basic', 'provider-id-1')
->price(10)
->features([
'First', 'Second', 'Third'
]);
where provider-id-1 is the Stripe ID of you billing plan. The 10 listed as price is used for local display -- the actual price is setup in Stripe. (if this is incorrect, please let me know)
Does Laravel Spark support Stripe's concept of quantities? I don't see anything about this in the docs, but I'm sometimes bad at reading docs.
If not -- has anyone extended Laravel Spark to use quantities. If so, what was involved? I assume you'd need to
Change the Strip API behavior to send along quantities when subscribing a user
Change Laravel display code to display a quantity based pricing
More things that didn't occur to me?
If Laravel spark doesn't support quantities, does anyone know which classes/files are responsible for the two items above? (particularly the Stripe API classes)

Out of the box, Spark does not let you set a quantity while subscribing.
However, because Spark uses Cashier under the hood, and because Cashier has the concept of quantity, you should be able to either swap in your own Subscribe class, or you can possibly do something like this (untested):
$subscription = $user->billable->subscription();
$subscription->quantity(5);
$subscription->save();
As for the UI, that will have to be custom built.

Related

Stripe take payment using saved card laravel php

How can i use saved card in stripe for next payment in future using stripe in Laravel framework?
I have tried to find out in Stripe official documentation but i could not find the best solution.
You may want to ask the Laravel/Cashier community for more advice, but it looks like you can retrieve a customer's payment methods like this (docs):
$paymentMethods = $user->paymentMethods();
If you're referring to use with future invoices (eg for subscriptions) you may want to set a default (docs):
$user->updateDefaultPaymentMethod($paymentMethod);
I have found the solution with the help of stripe document.
Here is the reference link https://stripe.com/docs/payments/save-and-reuse?platform=web
With the use of demo i got success. And its working properly.
Thanks for another answers.
One way to do it is using Stripe's future payments. On that documentation one can find PHP examples that can be translated into Laravel.
Depending on the use case, Laravel Cashier might also be of relevance.
A Stripe account will be required (here's the Sign Up page).
Here one can find how to get up and running with a Stripe integration in PHP.
Even though related with Django, my answer here on a similar issue might be of relevance.

Laravel 5.4 Cashier - bridging the gap in documentation

I've been working my way through the documentation on Laravels website regarding Cashier. From the sounds of it, it seems like it is exactly what I need. A basic subscription configuration that integrates with Stripe. I am able to follow along fairly easily through the configuration section. Then it switches gears and talks about BrainTree integration for a bit. And then it hops right into creating subscriptions, citing the following code:
$user = User::find(1);
$user->newSubscription('main', 'monthly')->create($stripeToken);
So my first question is - where is "$stripeToken" coming from? I feel like there's a fairly large gap in explanations here. Even when I run the code, it errors out saying $stripeToken could not be found.
Where am I setting/getting the $stripeToken from?
I have attempted to follow other video tutorials on setting up Cashier with Laravel, but these all seem to be outdated, as many of the steps to set it up are no longer relevant in Laravel 5.4. For example:
In the one tutorial, it says that you can check to see if a user is already subscribed to a plan in Stripe via the following:
$user->subscribed('main')
And in the video series, it shows him changing a database field (stripe_active) from 0 to 1, to show a different message in the view. With the new process however, there is no "stripe_active" field even created anymore.
So - at the risk of this being an open-ended vague question, I pose 3 questions to kick things off.
a.) Can anybody tell me how/where I set $stripeToken for the code in the documentation to work?
b.) Can anybody tell me how I can check to see if a subscription exists within Stripe using Cashier 7.0 & Laravel 5.4?
c.) Does anybody know of any good tutorials/videos that walk through this process using the latest versions of each?
You're right-- there's a huge gap in the docs.
A) you need to create a form on the front end view, and generate the token yourself, which you capture via javascript and then submit via POST. It's easiest to do this with Stripe Checkout, but it's more customizable with Stripe Elements.
B) you can see if a User has a subscription in Laravel using the built in methods described here: https://laravel.com/docs/5.4/billing#checking-subscription-status. If you're asking about how to grab Stripe subscriptions by calling Stripe from Laravel, it appears you can do this using $plans = Plan::getStripePlans(); from the stripe/stripe-php library which is a dependency of Laravel Cashier.
C) I found this tutorial to be very helpful, and at the moment it's up to date, though that may change: http://www.qcode.in/subscription-with-coupon-using-laravel-cashier-stripe/

Stripe multi vendor payment gateway in Laravel

I'm building website that is able to sell and buy product inside the website.
Users can post product and buy product from others.
Only remain thing is to integrate with payment gateway.
I'm going to use stripe for payment gateway.
Is it possible to do that with stripe?
Which is the best way to implement this?
The website was built in Laravel 5.4.
Yes, you can use Stripe for that. Taking advantage of Laravel Cashier. They've already implemented some logic that you can reuse.
Second, you want to pay 'sellers', yes, Stripe does that. Please check Stripe COnnect, which is great for exactly what you are trying to do.
Link: https://stripe.com/connect
This link shows specifically how to charge the user and keep some fees: https://stripe.com/docs/recipes/store-builder
If you follow all the documentation from Cashier, you are good to go.
Link: https://laravel.com/docs/5.4/billing

Integrate Paypal checkout laravel php

I'm currently developing a little shop system. Now I want to integrate a simple PayPal checkout. Just want to press checkout, log in to PayPal (as a customer), click pay and that's it, I get the money and he gets a confirmation.
Now, for Laravel I found 2 plugins, both relying on this. But somehow I don't come clear with those. Also, I found this, but its too old and different now, using Laravel 5.3. I also found this tutorial, but it also doesn't seem to be what I need (at least I guess so). I already created two sandbox accounts, a personal and a business acount, and I also have a user key and secret key.... But now, how can I use them?
What's the easiest way to just implement a quick way to checkout, entering some product data, the complete price and just be able (as a customer) to log in and click okay? I don't want more basically.
I'm using netshell/paypal for my current POS App. It's pretty good and not complex. Check their documentation from here.
If you are using 5.3 why not go with the new cool Cashier? https://laravel.com/docs/5.3/billing

Updating Stripe plan customer number in PHP / CodeIgniter

This is my first time interacting with Stripe and trying to tie it into CodeIgniter.
Currently, when you create an account on my application it adds you to the correct Stripe plan and increases the total amount to be billed on that account.
I'm having a problem trying to work with this subscription plan #. I found in their documentation that this deals with the Subscription plans quantity.
What I need to happen is when you deactivate a user, it needs to update the quantity to 1 less. I can't figure this out.
Playing around with their API I was able to completely delete a subscribed customer by doing:
$this->load->library( 'stripe' );
$this->stripe->customer_delete('cus_1WS0pth6srNf7H');
Now I'm working with:
$this->load->library( 'stripe' );
$customer_id = $company->stripe_id;
$this->stripe->customer_update($customer_id, **WHAT GOES HERE?**);
Any help would be greatly appreciated. To sum this up, I need to update the quantity of my plan to -1 when a user is deactivated. The user is being deactivated fine in my application, but now I need to send a request to Stripe to update my plan to 1 less user.
Perhaps the customer_update function isn't the right one to use for this? There are a lot in the Stripe.php file.
Once I have this solved I can handle applying it to reactivating a user.
Here is the documentation where I think I need to be
I've been using Jason Horwitz's fork of bcessa's php-stripe library. It appears to be kept up to date with Stripe API changes.
https://github.com/sekati/php-stripe
Anyways, this is what I did for applying a plan to a customer
$request = $this->stripe->customer_subscribe( $stripe_id, $plan );
According to Stripe's API Docs, this will prorate the difference (if changing from one plan to another) by default so if that's what you want, you're good. If not, you can add it to the options array like so:
$request = $this->stripe->customer_subscribe( $stripe_id, $plan, array('prorate' => false) );
Not clear if you are using this library or not, but you should check:
https://github.com/bcessa/php-stripe
Written for CI & very simple. I'm going to assume you are.
According to Stripe support (I did this exact same thing recently), you need to actually make a unsubscribe & resubscribe to a new plan.
The steps I want through, roughly, were:
1) Get next invoice - so I could capture the next billing date for the new subscription (we used a trial period, so I needed this. you might be able to skip)
2) Unsubscribe the customer
3) Get my new total user count
4) Create a plan id (can be the same as you had before, I believe)
5) Subscribe with the new count to the new plan
6) Update anything on your own db

Categories