Log in with PayPal for Payouts

DocsCurrentLast updated: July 15th 2022, @ 2:46:39 pm


To simplify payouts, Assisted Account Creation (AAC) enables customers to use their PayPal account to log in or sign up to a merchant site. This can accelerate and increase creation of customer accounts on the merchant site.

The merchant receives the payer ID and email address of each customer who completes the onboarding flow. Barring compliance or fraud issues, payer IDs are the most reliable way to send payouts.

AAC can also:

  • Identify users with PayPal accounts and display a Log in with PayPal button.
  • Enable merchants to customize rewards for PayPal users.
  • Enable customers to connect their PayPal account at the merchant site's payment settings screen.

Use AAC with these payouts integration methods:

Prerequisites

Before you integrate AAC, you'll need to:

  1. Be sure you get your OAuth and secret credentials. If not, get started.

  2. Contact your PayPal account manager to enable identity services. Your PayPal account manager adds:

    App settingsReturn URL
    Sandboxhttps://www.sandbox.paypal.com/conex/ac/add-offer-recipient
    Livehttps://www.paypal.com/conex/ac/add-offer-recipient
  3. In your sandbox app settings, select Log in with PayPal.

  4. Click Advanced Options and select Email address, Account status (verified), and PayPal account ID (payer ID). Based on your company’s requirements, you can Enable customers who have not yet confirmed their email address with PayPal to log in to your app. For details, see Enable Log in with PayPal.

  5. Get your merchant account ID from the Settings page of your PayPal business account.

Integrate Assisted Account Creation

You can use AAC to acquire customers’ email addresses and Payer IDs, which are encrypted PayPal account numbers, at sign up, log in, or payment set up on a merchant or partner website.

AAC requires client-side and server-side integration. For client-side integration, AAC uses Zoid, PayPal’s open-source cross-domain-component library. Server-side integration includes two PayPal API calls.

To integrate AAC:

  1. Integrate the AAC SDK on your client-side application.
  2. Add PayPal’s server-side API calls to your server-side application.

Integrate client side

Drop the AAC SDK onto your applicable pages as follows:

Note: In the client side scripts, information you need to fill in (for example, container, client_id, or signup/login) has quotation marks and angled brackets around it.

1<script src="https://www.paypalobjects.com/payouts/js/payouts_aac.js"></script>
2<!-- Set up a container for ACC to be rendered into -->
3<div id="container"></div>
4<script>
5 // Render the AAC component
6 paypal.PayoutsAAC.render({
7 // Use sandbox for testing
8 env: "<sandbox/production>",
9 clientId: {
10 production: "<production clientId>",
11 sandbox: "<sandbox clientId>"
12 },
13 merchantId: "<Merchant Account ID>",
14 pageType: "<signup/login>",
15 onLogin: function(response) {
16 if (response.err) {
17 console.log(response.err)
18 } else {
19 console.log(response.body.code);
20 }
21 }
22 }, '#container');
23</script>

Integrate with React or Angular

Use this code to integrate AAC if your client-side application runs on React or Angular.

  1. React
  2. Angular
1import React from 'react';
2import ReactDOM from 'react-dom';
3const AACComponent = paypal.PayoutsAAC.driver('react', {
4 React,
5 ReactDOM
6});
7class OtherReactComponent extends React.Component {
8render() {
9 return (
10 <AACComponent
11clientId="<client_id>"
12merchantId="<Merchant Account ID>"
13env="<sandbox/production>"
14pageType="<signup/login>"
15onLogin={onLogin} />
16 );
17 }
18}

Integrate server side

Server side integration includes two PayPal API calls.

  1. Use the authorization code returned in the client side integration to obtain an access token.
1curl -X POST https://api-m.paypal.com/v1/identity/openidconnect/tokenservice
2 -H 'Authorization: Basic <Base64 Encoded client_id:secret>'
3 -d 'grant_type=authorization_code&code=<code>'
  1. Use the access token to get the customer's email address and Payer ID.
1curl -v -X GET https://api-m.paypal.com/v1/oauth2/token/userinfo?schema=openid \
2 -H "Content-Type: application/json" \
3 -H "Authorization: Bearer <access_token>"

Integrate on Node or Python

Use this code to install AAC if your server runs on Node or Python.

  1. Node
  2. Python
1npm install paypal-rest-sdk
2var paypal = require('paypal-rest-sdk');
3paypal.configure({
4 'mode': 'sandbox', //sandbox or live
5 'client_id': '',
6 'client_secret': ''
7});
8// Get tokeninfo with Authorize code
9paypal.openIdConnect.tokeninfo.create("Replace with authorize code", function(error, tokeninfo){
10 console.log(tokeninfo);
11});
12// Get userinfo with Access code
13paypal.openIdConnect.userinfo.get("Replace with access_code", function(error, userinfo){
14 console.log(userinfo);
15});