Search code examples
paypalpaypal-rest-sdk

Connect PayPal user to custom shop system


I would like to develop a web application (shop plugin) in PHP where site visitors can pay for orders using PayPal. We have been using the PayPal REST-API itself for about 2 years, and have created a client ID and secret key for doing so.

Now I would like to enable our customers to receive PayPal payments themselves. I've read the documentation for the "Login with PayPal" function, but still don't understand how to extract the data needed for a payment via the REST API (client ID and secret key) from the output. What we would like to achieve is for our customers to connect the application to their PayPal account only once (as is usual with webshop systems), without having to generate the API access themselves.

Any hints on how to get the data required for implementation are greatly appreciated!


Solution

    1. Log in with PayPal (can be) used in conjunction with the Partner Referrals API for a third party integration. Here is the documentation. Using this in the live environment requires approval from PayPal.

    2. An alternative to the third party integration method discussed above is to use the client-id and secret of the receiving account, aka first party credentials. Your customer must have a PayPal business account and obtain a live client id and secret by logging in with it and creating a REST App in the developer dashboard.

    3. An alternative to using third party credentials or first party credentials is to use only your own, and specify a payee to identify the receiving account when setting up the payment. See the documentation at Pay another account or within the create order API reference.


    You mentioned using the PayPal REST API, and that is how to do the order creation and capture. You should have two backend routes that do these API operations and return/output a JSON result. For payer (buyer) approval, pair those two routes with the JS SDK. Do not redirect away from your site -- if that is what you mean by "using the PayPal REST-API itself", stop doing that redirection and add the JS SDK for approval within your site.