mardi 31 juillet 2018

difficulty on the integration of paypal on laravel

This is my first time to implement paypal on my project. I'm using srmklive/laravel-paypal and on the documentation i tested the following code

this is my controller

class CheckoutController extends Controller
{
    protected $provider;
    public function __construct(){
        $this->provider = new ExpressCheckout();
    }

    public function getExpressCheckout(Request $request){
        $data = [];
        $data['items'] = [
          [
            'name' => 'Product 1',
            'price' => 9.99,
            'qty' => 1
          ],
          [
            'name' => 'Product 2',
            'price' => 4.99,
            'qty' => 2
          ]
        ];

        $data['invoice_id'] = 2;
        $data['invoice_description'] = "test";
        $data['return_url'] = url('/');
        $data['cancel_url'] = url('/cart');

        $total = 0;
        foreach($data['items'] as $item) {
            $total += $item['price']*$item['qty'];
        }

        $data['total'] = $total;

        //give a discount of 10% of the order amount
        $data['shipping_discount'] = round((10 / 100) * $total, 2);
        $response = $this->provider->setExpressCheckout($data);
        return redirect($response['paypal_link']);
    }
 }

this is my route

Route::get('/paypal/ec-checkout', 'CheckoutController@getExpressCheckout')->name('checkout');

this is my link

 <a href="" class="btn btn-primary pull-right" style="margin-bottom:20px;">Checkout</a>

My problem is when i clicked the link it just load forever and no errors are shown. I'm using laravel 5.6



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2AtdlfF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire