AsadMalik
AsadMalik

Reputation: 29

PayPal Laravel 6 integration using srmklive error

I am facing an issue in srmklive/paypal integration in Laravel 6.I have published all services also cleared cache and config but still error is coming.

Class 'Srmklive\PayPal\Services\ExpressCheckout' not found

The code of my paypal payment controller is below

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Srmklive\PayPal\Facades\Paypal;
use Srmklive\PayPal\Services\ExpressCheckout;

class PayPalController extends Controller
{
    /**
     * Responds with a welcome message with instructions
     *
     * @return \Illuminate\Http\Response
     */
    public function payment()
    {
        $data = [];
        $data['items'] = [
            [
                'name' => 'ItSolutionStuff.com',
                'price' => 100,
                'desc'  => 'Description for ItSolutionStuff.com',
                'qty' => 1
            ]
        ];
  
        $data['invoice_id'] = 1;
        $data['invoice_description'] = "Order #{$data['invoice_id']} Invoice";
        $data['return_url'] = route('payment.success');
        $data['cancel_url'] = route('payment.cancel');
        $data['total'] = 100;
  
        $provider = new ExpressCheckout;
  
        $response = $provider->setExpressCheckout($data);
  
        $response = $provider->setExpressCheckout($data, true);
  
        return redirect($response['paypal_link']);
    }
   
    /**
     * Responds with a welcome message with instructions
     *
     * @return \Illuminate\Http\Response
     */
    
}

Upvotes: 1

Views: 3110

Answers (1)

NikuNj Rathod
NikuNj Rathod

Reputation: 1658

You can check following steps in your application and apply it.

1 . Please Install Laravel Package for PayPal Library.

composer require srmklive/paypal

2.You can update your app.php file for provider. Look Like

   'providers' => [
      Srmklive\PayPal\Providers\PayPalServiceProvider::class
    ]

3.Now you an run following command in terminal.

`php artisan vendor:publish --provider "Srmklive\PayPal\Providers\PayPalServiceProvider"`

4.You can update your paypal.php file inside config folder.

5.You can run following command then it will be work perfectly.

php artisan config:clear && php artisan cache:clear && php artisan config:cache

I hope It will be helpful.

Upvotes: 2

Related Questions