riclep / spark-single-payment
Take single payments in Laravel Spark such as 'pay-as-you-go' payments
Installs: 3 069
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 5
Forks: 1
Open Issues: 1
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.