amsgames / laravel-shop

Laravel shop package
MIT License
483 stars 166 forks source link

Where to call Shop::setGateway('paypal') #48

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi I'm new to Laravel, I'm able to create a site just add product to cart, remove product from cart. Now I want to make it can purchase, and I have no idea where to call Shop::setGateway('paypal'). Anyone can explain it to me or give me an example, thanks for help. p/s: sorry for my bad english.

ghost commented 8 years ago

ok, I found a way :D

ChadTaljaardt commented 8 years ago

Can you post it here, i'm stuck on the same thing ?

ghost commented 8 years ago

just wait, I'm too busy these days. I just thinking about it, now I'm coding it, I'll give my code to you later.

ghost commented 8 years ago

I think we have to so something like this :))

routes.php:

Route::post('/checkout', 'CheckoutController@checkout')->middleware('auth');

CheckoutController.php:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

use Amsgames\LaravelShop\LaravelShop as Shop; use App\Cart as Cart;

class CheckoutController extends Controller { public function __construct(){ Shop::setGateway('paypal'); }

public function checkout(Request $request){
    $cart = Cart::current();
    $success = Shop::checkout($cart);
    //some code
}

}