riclep/spark-single-payment

This package is abandoned and no longer maintained. No replacement package was suggested.

Take single payments in Laravel Spark such as 'pay-as-you-go' payments

1.2.3 2018-07-09 11:12 UTC

This package is auto-updated.

Last update: 2022-02-09 12:04:58 UTC


README

Sometimes you want to be able to create single payments in Laravel Spark rather than subscription based ones such as a pay-as-you-go service or one off fee for a product.

If the user in a member of a team it will automatically charge the current team not the user.

The package implements Spark’s SendsInvoiceNotifications trait to handle sending invoices in the same manner as subscription payments. Single payments are not currently added the the KPI figures that Spark can generate.

To create a single payment simply new up a SparkSinglePayment object passing in the user then call charge passing then description and value. As it uses Laravel Cashier under-the-hood payment to Stripe should be in pence (cents) and Braintree in pounds (dollars), see: https://laravel.com/docs/5.6/billing#single-charges

$payment = new SparkSinglePayment(Auth::user());

// Stripe Accepts Charges In Cents...
$payment->charge('A test', 100);

// Braintree Accepts Charges In Dollars...
$payment->charge('A test', 1);

Successful charges return the Stripe/Braintree response, failed charges throw an exception.