29.07.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Laravel Cashier 183<br />

.<br />

1 $user->charge(100);<br />

The charge method accepts an array as its second argument, allowing you to pass any options you<br />

wish to the underlying Stripe charge creation:<br />

.<br />

1 $user->charge(100, [<br />

2 'source' => $token,<br />

3 'receipt_email' => $user->email,<br />

4 ]);<br />

The charge method will return false if the charge fails. This typically indicates the charge was<br />

denied:<br />

.<br />

1 if ( ! $user->charge(100)) {<br />

2 // The charge was denied...<br />

3 }<br />

If the charge is successful, the full Stripe response will be returned from the method.<br />

Invoices<br />

You may easily retrieve an array of a billable model’s invoices using the invoices method:<br />

.<br />

1 $invoices = $user->invoices();<br />

When listing the invoices for the customer, you may use the invoice’s helper methods to display the<br />

relevant invoice information. For example, you may wish to list every invoice in a table, allowing<br />

the user to easily download any of them:<br />

.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!