function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Manpreet Singh 207Manpreet Singh 207 

PayPal integration with Salesforce (NPSP)

Hello All  - We are planning to integrate PayPal with Salesforce. We basically want to integrate Salesforce NPSP solution with PayPal. This integration will enable us to capture donations made by donors in PayPal mobile/desktop application as Opportunity/Gift in Salesforce. What options do we have here?
VinayVinay (Salesforce Developers) 
Hi Manpreet,

Kindly review below options.

http://techsahre.blogspot.com/2011/01/simple-paypal-integration-with.html
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016cbMEAQ
https://help.formassembly.com/help/make-salesforce-and-paypal-work-together
https://zapier.com/apps/paypal/integrations/salesforce
https://developer.salesforce.com/forums/?id=906F00000008pPRIAY
https://www.forcetalks.com/salesforce-topic/how-to-integrate-paypal-with-salesforce/
https://www.appfrontier.com/paypal-salesforce-integration.html

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
porter.mikeporter.mike
To ensure your are PCI compliant, I recommend you get an app off app exchange. I've used Chargent, Linvio, and Blackthorn, but there are others.

PayPal has three flavours: Payments Pro, PayPal Flow, and PayPal Flow Pro maybe? I can never remember. Different app exchange apps work with the different flavours so be sure to do your homework and explain exactly what you need.

Also, think about the requirements and process. You can send payments out from Salesforce, but as a white-label gateway you cannot directly charge a credit card... you have to email the customer asking them to pay. Some fo the apps above (or maybe all of them by now) incorporate nice emailing and web-form user experiences to get that first customer interaction. After that you can charge the customer from within Salesforce without the email. It sounds like you don't need this functionality.

Do you need payments from other systems that happen to also go through your PayPal account to end up in Salesforce? Some of the apps have webhooks that will capture all payments in your PayPal account from any system and expose them in Salesforce as a record. Some of those apps will then let you issues e.g. refunds on those pyaments, even though they originated in an external system.

Or you can custom build the webhook from PayPal to Salesforce. https://developer.paypal.com/docs/integration/direct/webhooks/rest-webhooks/
Manpreet Singh 207Manpreet Singh 207
Vinay - Thank you for the links. I will go through them and see if I can use them to build my integration.

Mike - Thank you for the detailed answer. I am not very keen on leveraging App Exchange application for my integration. What I am really looking for is that if any donor donate money from their PayPal Mobile application or Desktop site then that donation should get converted into an opportunity/Gift in Salesforce. This donor can be any individual person who is keen on contriburing. 
porter.mikeporter.mike
You'll want to code a webservice to receive the webhooks then. Start by reading up on PayPal webhooks here https://developer.paypal.com/docs/integration/direct/webhooks/

Next, go here and get a new random toilet: http://ptsv2.com/
That gives you a POST URL.

(There are several other websites that give you URLs to POST to, for example https://requestbin.com/, but the one above is my favourite.)


The remaining steps are outlined in the documentation above, but you want to:
  • PayPal dev account. and use that for development/testing
  • Configure it to send webhooks to that ptsv2 POST URL
  • Use https://developer.paypal.com/docs/api/webhooks/v1/#simulate-event to tell PayPal to send pretend webhook events. You should see them coming on the ptsv2 POST URL
See how they call the command
curl -v -X POST https://api.sandbox.paypal.com/v1/notifications/simulate-event \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token" \
-d '{
  "url": "https://example.com/example_webhook",
  "event_type": "PAYMENT.AUTHORIZATION.CREATED",
  "resource_version": "1.0"
}'
And they get back the response
{
  "id": "8PT597110X687430LKGECATA",
  "create_time": "2013-06-25T21:41:28Z",
  "resource_type": "authorization",
  "event_version": "1.0",
  "event_type": "PAYMENT.AUTHORIZATION.CREATED",
  "summary": "A payment authorization was created",
  "resource_version": "1.0",
  "resource": {
    "id": "2DC87612EK520411B",
    "create_time": "2013-06-25T21:39:15Z",
    "update_time": "2013-06-25T21:39:17Z",
    "state": "authorized",
    "amount": {
      "total": "7.47",
      "currency": "USD",
      "details": {
        "subtotal": "7.47"
      }
    },
    "parent_payment": "PAY-36246664YD343335CKHFA4AY",
    "valid_until": "2013-07-24T21:39:15Z",
    "links": [
      {
        "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B",
        "rel": "self",
        "method": "GET"
      },
      {
        "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
        "rel": "capture",
        "method": "POST"
      },
      {
        "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
        "rel": "void",
        "method": "POST"
      },
      {
        "href": "https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
        "rel": "parent_payment",
        "method": "GET"
      }
    ]
  },
  "links": [
    {
      "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA",
      "rel": "self",
      "method": "GET"
    },
    {
      "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend",
      "rel": "resend",
      "method": "POST"
    }
  ]
}
Make sure you can do that with ptsv2 and you get expected output. Remember to test successful payments and failed payments of various types (expired card, insufficient funds, etc)

Next you need to write apex to parse that POSTed payload. See the docs here https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest.htm

That leaves security... no idea what options we have with PayPal for e.g. OAuth. If there's nothing you might need to expose a Site with an empty page to get a public-facing URL to POST to that apex.
Manpreet Singh 207Manpreet Singh 207
Mike - Exactly, I will have to custom code to accomplish this task. I will share end to end code once it will be completed. Thank you!
harsh vikramharsh vikram
Hi Manpreet,

I am working on exactly the same requirement. Were you able to achieve this functionality. If yes, can you please share the code .
 
amutha samutha s
Hi Manpreet, 
I am working on the same requirement as yours. Please share if you have done to work on either with Webhook or any other technique.   
Fetuti QueirozFetuti Queiroz
Hi Guys,
I am also working on the integration between Salesforce and Paypal. Did you guys have any updates on this? Thanks in advance. 
deepika mishra 10deepika mishra 10
Hi guyz
i also tried this method is working perfectly, Even if you need a free paypal accounts (https://www.freetricksworld.com/free-paypal-accounts-with-money/) you can always read this so that you have an idea like what to do and how to using the free account.
Vidhya Ramaswamy 17Vidhya Ramaswamy 17

I'm also having a similar requirement to be able to accept Paypal/Credit card details from Experience cloud site. I will check out the links shared by Vinay.

Has anyone used 'PayPal Payment Processing' app?