This repository provides a lightweight outbound integration from Salesforce to PayPal using Scheduled and Queueable Apex. It asynchronously retrieves transactions from PayPal's Transactions REST API endpoint here and pushes them into a Salesforce custom object called 'PayPal_Transaction__c' as records.
In addition, implementing record-based flow or trigger on 'PayPal_Transaction__c' will enable you to seamlessly transform the incoming data into your standard/custom object records, allowing you to tailor the integration to meet your specific business requirements.
-
Update Named Credential: Update the named credential 'PayPal_Named_Credential' with your PayPal account client ID and client secret from your PayPal sandbox.
-
Production Environment: After successful testing in the sandbox, update the endpoint URL to the production PayPal URL ('https://api-m.paypal.com') on the 'PayPal_Named_Credential' and provide your PayPal production client ID and client secret.
-
Account Deduplication: Account records are matched and deduplicated based on the address in the PayPal transaction.
-
Contact Deduplication: Contacts are matched and deduplicated based on the first name, last name, and email.
-
Data Retrieval: The
PayPalDataSchedulershould be scheduled to retrieve records from the previous day, starting at 12 AM and ending at 11:59 PM. -
Customization: The logic is implemented in the following Apex classes:
PayPalDataExportQueueable,PayPalDataProcessorQueueable, andPayPalDataScheduler. You can modify these classes to meet your specific requirements.
- Clone this project and open the project directory in Visual Studio Code (VSCODE).
git clone https://github.com/SalesforceLabs/Salesforce-PayPal-Transaction-Connector.gitcd <project-directory>Before deploying the integration, ensure you have enabled the custom address field in your Salesforce org.
- Navigate to
Setup > User Interface. - Check the checkbox next to "Use custom address fields."
Deploy the PayPal Transaction Integration using the provided package.xml file in the manifest folder of this project. Run the test classes to ensure everything works correctly before deploying it to your production environment.
sf project deploy start --manifest manifest/package.xml -l RunSpecifiedTests -t PayPalDataExportQueueableTest PayPalDataProcessorQueueableTest PayPalDataSchedulerTest PayPalTransactionDataTest PostInstallClassTestAfter deploying the integration, run the post-deployment script to schedule the PayPalDataScheduler Apex Class to run automatically every day at 3 AM. Also, add the 'PayPal_Data_Permissions' Permission Set to all system administrator users. Customize the PostDeploymentScript Apex script as needed.
sfdx force:apex:execute -f scripts/apex/PostDeploymentScript.apexStep 5: Follow through the rest of the few steps on Setup, Customize and Data Export Page internally on your salesforce org
- Setup Section (Required): PayPal Connection Configuration, NamedCredential and Send Error Emails Configuration Setup.
- Customize Section (Optional): Learn the available customize options and possibly customize according to you need.
- Data Export Section (Optional): If you have existing transactions in your PayPal account that you want to export to Salesforce then follow those steps.