コード例 #1
0
ファイル: User.php プロジェクト: Fash1/Fash1
 public function getBagPrice()
 {
     $bag = Bag::with('product')->where('user_id', '=', Auth::user()->id)->get();
     $price = 0;
     if (!$bag->isEmpty()) {
         foreach ($bag as $key => $bag_item) {
             $price = $price + $bag_item->product->price;
         }
     }
     return $price;
 }
コード例 #2
0
ファイル: MyController.php プロジェクト: Fash1/Fash1
 public function getCheckout()
 {
     // Get the bag items.
     $bag = Bag::with('product.product_media.media')->where('user_id', '=', Auth::user()->id)->get();
     // Get the cards.
     $cards = Stripe::getCards();
     // Get the addresses.
     $addresses = Address::where('user_id', '=', Auth::user()->id)->get();
     // Render the view.
     return View::make('brochure.my.checkout', ['bag' => $bag, 'cards' => $cards->data, 'addresses' => $addresses]);
 }
コード例 #3
0
ファイル: Stripe.php プロジェクト: Fash1/Fash1
 public static function charge($data)
 {
     self::init();
     // Calculate the total price.
     $bag = Bag::with('product')->where('user_id', '=', Auth::user()->id)->get();
     $total = 0;
     foreach ($bag as $key => $bag_item) {
         $total = $total + $bag_item->product->price;
     }
     // Create the charge.
     $charge = \Stripe\Charge::create(array("amount" => $total, "currency" => "gbp", "customer" => Auth::user()->stripe_key, "description" => "Payment for Fash1 cart items, user_id: " . Auth::user()->id));
     if ($charge->paid == 1) {
         return true;
     }
     return false;
 }