@andy cashier supports both subscriptions and one time payments, here's the documentation: http://laravel.com/docs/5.0/billing#single-charges
Stripe : single payment (not subscriptions)
Has anybody seen a package that will allow you to take advantage of Stripe's single payment option? Cashier seems to do only subscriptions ...
@MartelliEnrico Thanks!
Totally missed that in the documentation ...
hmmm ... "If you would like to make a "one off" charge against a subscribed customer's credit card, you may use the charge method:"
Maybe this not the solution I was looking for. I need to be able to just charge a customer like you would if using Paypal. I don't want to have it as a subscription.
They don't have to be subscribed user, just be a stripe customer.
$customer = Auth::user()->subscription()->createStripeCustomer($request->stripe_token, [
'email' => Auth::user()->email
]);
Auth::user()->setStripeId($customer->id);
Auth::user()->save();
Auth::user()->charge(5000, ['currency' => 'cad', 'description' => 'A charge for something']);
I've tested this and it works. Hope that helps.
I think this misses OP's point though: Stripe can and does handle simple one off payments without the customer needing a subscription, and without requiring them to be logged in to any site. But there don't seem to be many tutorials on how to do this in Laravel 5.
According to the doc "If you're only performing "one-off" charges and do not offer subscriptions. You should not use Cashier. You should use the Stripe and Braintree SDKs directly."
"If you would like to make a "one off" charge AGAINST a SUBSCRIBED customer's credit card, you may use the charge method on a billable model instance."
check this series out it covers one time payment without cashier https://laracasts.com/series/billing-with-stripe
Modified @StormShadow's code, this is working for me:
$customer = $user->createAsStripeCustomer($stripeToken, [
'email' => $user->email
]);
$update = $user->subscriptions()->create([
'user_id' => $user->id,
'name' => $plan->title,
'stripe_id' => $customer->id,
'stripe_plan' => $plan->id,
'quantity' => 1,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
]);
$user->charge($total_price, ['currency' => 'usd', 'description' => 'Charge for Extended (3 yr.) plan.']);
https://stripe.com/docs/stripe.js#createToken seems to only need creditcard details to create a stripe token
https://stripe.com/docs/api/php#create_charge https://stripe.com/docs/charges no stripe customers?
not tested yet, no stripe experience either, but going to try and implement this soon
I know its an old post. i'm posting just for future visitors:
I was able to charge the user without subscription using the following code.
$amount = some amount;
Stripe::setApiKey(Config::get('stripe.secret_key'));
$token = $input['stripeToken'];
$user = Auth::user();
return $user->charge($amount * 100, ['source' => $token]);
I wonder why they suggested to not use cashier. Is it gonna cause problems?
I’ve just come across your answer and I’m thinking about taking this route. I already have subscriptions on my website but I’m wanting to add donations on there too which will be a one time payment.
Is it possible to do this without the user been registered? I need guests to be able to donate without signing up.
@firouziam have you used the new checkout https://stripe.com/docs/payments/checkout/server ?
if so, does this still require the php sdk https://github.com/stripe/stripe-php ?
Please or to participate in this conversation.