One-time Charges
If you would like to make a one-time charge against a customer, you may use the charge method on a billable model
instance.
Leveraging Mollie’s recurring features, Cashier’s one-time charge features work similar to the subscription features:
- Build the charge by adding some items.
- The customer either gets billed using an existing mandate, or gets redirected to Mollie’s checkout to perform a first payment. This will result in a new mandate.
- Once the payment has been received in your Mollie account, Cashier Mollie will generate an Order.
use App\Models\User;
$user = App\User::find(1);
$item = new \Laravel\Cashier\Charge\ChargeItemBuilder($user);$item->unitPrice(money(100,'EUR')); //1 EUR$item->description('Test Item 1');$chargeItem = $item->make();
$item2 = new \Laravel\Cashier\Charge\ChargeItemBuilder($user);$item2->unitPrice(money(200,'EUR'));$item2->description('Test Item 2');$chargeItem2 = $item2->make();
$result = $user->newCharge() ->addItem($chargeItem) ->addItem($chargeItem2) ->setRedirectUrl('https://www.example.com') ->create();
if(is_a($result, \Laravel\Cashier\Http\RedirectToCheckoutResponse::class)) { return $result;}
return back()->with('status', 'Thank you.');