Back

Paypal Integration in Laravel with verify email address


B L Praveen posted 3 weeks ago

I am getting following error message when creating user in Registration Controller

Argument 1 passed to Illuminate\Auth\SessionGuard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, null given

I have two type of user paid and free .Where do I need to redirect to PaypalAgreemnt while user is trying to register. If I return User it is verfiying the user email

class RegisterController extends Controller
{

   protected function create(array $data)
{   
     if(isset($data['type'])  && $data['type'] == 'paid' ) {
        Session::put('type', $data['type']);
        Session::put('email', $data['email']);
        Session::put('password', $data['password']);
        $plan_id = 'P-4C095357DP980872FT2QOCTA';
        $agreement = new PaypalAgreement();
        $agreement->create($plan_id);

    } else {
        return User::create([
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }
  }
class PaypalAgreement extends Paypal
{
public function create($id) {

    return redirect($this->Agreement($id));
}

protected function Agreement($id): string
{
    $agreement = new Agreement();
    $agreement->setName('Base Agreement')
        ->setDescription('Basic Agreement')
        ->setStartDate('2019-06-17T9:45:04Z');
    $plan = $this->Plan($id);
    $agreement->setPlan($plan);
    $payer = $this->Payer();
    $agreement->setPayer($payer);
    $ShippingAddress = $this->ShippingAddress();
    $agreement->setShippingAddress($ShippingAddress);
    $agreement = $agreement->create($this->apiContext);

    return $agreement->getApprovalLink();
}
Pardeeptech replied 2 weeks ago

I think , this error is because your are returning a string and the class is expecting an instance of Authenticatable.

Create a middleware that checks if the username is a 'Slug' Create () method when validation passes
clean up the AuthController by removing the slugCheck method

I suggest you , to follow this article for more information let me know if you face any problem again

https://www.cloudways.com/blog/laravel-paypal-payment-gateway/

Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us