abingpj's avatar

Laravel paypal multi user account setup

Hello.

I am planning to build an ecommerce application on Laravel where

  • Each User can able to set up their own paypal account for their store.

As of my understanding, I checked in the laravel app, I have to set client_id and secret to the .env file.

Confusing part.

My confusion is that, how can I manage paypal id and secrect for each user and how to handle in the .env application side?

Any tips?

0 likes
9 replies
Snapey's avatar

only someone with paypal experience will know what you are on about.

I assume you are using sone (unmentioned) package?

Don't call people out to answer as then everyone else ignores your question

1 like
rezuankassim's avatar

As you say each user can have their own PayPal account right? Then you put the client_id and secret in the users table.

Then just use the client_id and secret for the users when using PayPal.

You may want to read the documentation for your PayPal package.

kbuczynski's avatar

From what I understand a secret and id value is a part of API keys needed to make a connection to PayPal API.

If use would want to add such keys to your application it should be stored in the database and fetch when needed to make a connection to the service.

If you want you application to connect only to one PayPal account then you should specify them in the .env file and fetch them from there when needed.

abingpj's avatar

@rezuankassim @kbuczynski

Currently I am storing paypal id and secret into table for each user.

But problematic part is when I try to implement papal package, it take a id and secret only for entire application.

Imagine that, once user A logged in and change the .env value for paypal based on user A, then other user's account will be following the user A id and secret, right?

You get what I mean?

newbie360's avatar

for security reasons, without store any user sensitive info

create a 'credit' column in user table

create a form let the user fill the paypal info to get credit

so if the user need more credit, just need to fill the form again

otherwise, you need make sure protect the user sensitive info

becareful the law 'General Data Protection Regulation (GDPR)'

kbuczynski's avatar

Ah I see @abingpj that should not be a problem if you would look at the https://github.com/srmklive/laravel-paypal and read the code for the PayPal service the constructor for it does accept config string|array which are used as the config. This is all from what I manage to read in last 5min.

I recommend reading the code it self not just the documentation to understand how it all works :)

kbuczynski's avatar

Following my comment There is a override method $provider->setApiCredentials($config); which u can pass your own $config

Please or to participate in this conversation.