03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

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

E-Commerce 280<br />

30 "amount" => round($amount * 100),<br />

31 "currency" => $currency<br />

32 ]);<br />

33<br />

34 return true;<br />

35 }<br />

36 catch (Exception $e)<br />

37 {<br />

38 return false;<br />

39 }<br />

40 }<br />

41 }<br />

This file should be saved as workbench/formativ/billing/src/Formativ/Billing/StripeGateway.php.<br />

.<br />

Using the document (found at: https://github.com/stripe/stripe-php); we’re able to create a test<br />

charge which goes through the Stripe payment gateway. You should be able to submit orders through<br />

the the interface we’ve created and actually see them on your Stripe dashboard.<br />

.<br />

You can learn more about Stripe at: https://stripe.com/docs.<br />

Generating PDF Documents<br />

The last thing left to do is generate and email the invoice. We’ll begin with the PDF generation,<br />

using DOMPDF and ordinary views:<br />

1 public function getTotalAttribute()<br />

2 {<br />

3 return $this->quantity * $this->price;<br />

4 }<br />

.<br />

This was extracted from app/models/OrderItem.php.

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

Saved successfully!

Ooh no, something went wrong!