Collect recipient information - integrate AAC
You can use Assisted Account Creation (AAC) to allow your customers to use their PayPal account to log in or sign up on your site. AAC simplifies onboarding, increases customer account creation, and helps your customers receive payouts quickly and securely.
When a customer completes the onboarding flow, you receive their payer ID and email address. Payer IDs are typically the most reliable way to ensure accurate and secure payouts.
AAC can:
- Identify customers with PayPal accounts and display a Log in with PayPal button.
- Enable merchants to customize rewards for PayPal users.
- Allow customers to connect their PayPal account at your site's payment settings screen.
Before you integrate
- Complete all mandatory steps to get started. Use the retrieved sandbox app credentials (client ID and secret) in your code to generate an access token. The access token is a server-side token that authenticates your application when accessing PayPal API resources.
- Ensure your PayPal business account is verified and enabled for Payouts. For more information, see Set up your PayPal production business account.
- Contact PayPal or work with your account manager to enable identity services and configure the following return URLs for your application:
- Enable Log in with PayPal in your app settings:
- Go to your PayPal developer account and toggle to Sandbox.
- Go to Apps & Credentials and select your app.
- Go to Features and select Log in with PayPal.
- Select Advanced settings. The Log in with PayPal page is displayed.
- Enter the Return URL to redirect your customers after they complete the Log in with PayPal flow.
- Go to Information requested from customers and select the following options:
- Account verification status
- PayPal account ID (payer ID)
- Enable customers who have not yet confirmed their email with PayPal to log in to your app: Select this option based on your business requirement. For details, see Enable Log in with PayPal.
- Save your app settings.
- Get your merchant account ID from the Settings page of your PayPal business account. Use this account ID to uniquely identify your PayPal business account in your integration setup and API requests.
Integrate assisted account creation
Integrating AAC enables your application to access customers’ email addresses and payer IDs (encrypted PayPal account numbers) during sign up, log in, or payment setup on your website or partner platform.
Integrate client side
In your client-side code, integrate the AAC SDK to render the AAC component. The AAC SDK uses Zoid, PayPal’s open-source cross-domain component library. Use the following samples to integrate AAC based on your client-side framework.
- HTML
- React
- Angular
<script src="https://www.paypalobjects.com/payouts/js/payouts_aac.js"></script>
<!-- Set up a container for AAC to be rendered into -->
<div id="container"></div>
<script>
// Render the AAC component
paypal.PayoutsAAC.render({
// Use sandbox for testing
env: "<sandbox/production>",
clientId: {
production: "<production clientId>",
sandbox: "<sandbox clientId>"
},
merchantId: "<Merchant Account ID>",
pageType: "<signup/login>",
onLogin: function(response) {
if (response.err) {
console.log(response.err)
} else {
console.log(response.body.code);
}
}
}, '#container');
</script>
import React from 'react';
import ReactDOM from 'react-dom';
const AACComponent = paypal.PayoutsAAC.driver('react', {
React,
ReactDOM
});
class OtherReactComponent extends React.Component {
render() {
return (
<AACComponent
clientId="<clientId>"
merchantId="<Merchant Account ID>"
env="<sandbox/production>"
pageType="<signup/login>"
onLogin={onLogin} />
);
}
}
// Specify the component name as a dependency to your angular app:
angular.module('myapp', ['payouts-aac']);
// Include the tag in one of your templates (use kebab case for prop names)
<payouts-aac
client-id="<clientId>"
merchant-id="<Merchant Account ID>"
env="<sandbox/production>"
page-type="<signup/login>"
on-login="onLogin">
</payouts-aac>
Integrate server side
After the user completes the PayPal log in or sign-up flow, PayPal redirects to your redirect_uri
with a code
parameter.
- Use the authorization code retrieved by the client-side code to obtain an access token.
curl -X POST https://api-m.paypal.com/v1/identity/openidconnect/tokenservice \
-H 'Authorization: Basic <Base64 Encoded client_id:secret>' \
-d 'grant_type=authorization_code&code=<code>'
- Use the access token to get the customer's email address and payer ID.
curl -v -X GET https://api-m.paypal.com/v1/oauth2/token/userinfo?schema=openid \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <ACCESS-TOKEN>'
Integrate with Node or Python
In your server-side code, use the following samples to integrate AAC.
- Node
- Python
var paypal = require('paypal-rest-sdk');
paypal.configure({
'mode': 'sandbox', //sandbox or live
'client_id': '',
'client_secret': ''
});
// Get tokeninfo with Authorization code
paypal.openIdConnect.tokeninfo.create("Replace with authorization code", function(error, tokeninfo){
console.log(tokeninfo);
});
// Get userinfo with Access code
paypal.openIdConnect.userinfo.get("Replace with access_code", function(error, userinfo){
console.log(userinfo);
});
import paypalrestsdk
from paypalrestsdk.openid_connect import Tokeninfo, Userinfo
paypalrestsdk.configure({
"mode": "sandbox", # sandbox or live
"client_id": "",
"client_secret": "" })
tokeninfo = Tokeninfo.create("Replace with authorization code")
userinfo = tokeninfo.userinfo()
Test end-to-end flow
To test the AAC integration in sandbox:
- Run your application.
- Verify if your application renders the Log in with PayPal button.
- Select Log in with PayPal on your application.
- Log in with your sandbox personal account credentials or complete the sign up process.
- Approve the consent to share the customer details.
- Use your sandbox business account to:
- Verify that your application receives the authorization code.
- Exchange the authorization code for an access token.
- Use the access token to retrieve the customer details.
- Check if the customer account exists. If not, use the retrieved customer details to create a new account in your application.
- Use the access token to make a payout request.
- Verify the payout:
- Confirm if the payout status is
SUCCESS
in your sandbox business account. - Confirm the movement of money into your sandbox personal account.
- Confirm if the payout status is