• Daniel Dennis
  • 0 Points
  • Member since 2014

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 2
I'm trying to setup a simple bit of code that recieves a PayPal Instant Payment Notification (IPN) finds the created Opportunity and checks a box called "paid".

The key field in Salesforce is "FormAssemblyID" 
The IPN sends a block of text that includes this parameter: &custom=https://ncoa.tfaforms.net/responses/view/52932682&

My class is supposed to extract this and use it to lookup the right opportunity and a check a box. It's either not finding the right opportunity or its not checking the Paid box when it does and can't figure out which it is.

Here is the opportunity field that it should be finding:   User-added image

And here is my code:

public class IPNHandlerController {

    public PageReference myIPNupdate() {
        PageReference pageRef = ApexPages.currentPage();
        //Get the value of the 'custom' parameter from current page
        String paramCustom = pageRef.getParameters().get('custom');
        opportunity = [select Id,paid__c from Opportunity where FormAssemblyID__c = :paramCustom ];

        String content = '';
        for(String key : pageRef.getParameters().keySet()){
            //Note that there is no guarantee of order in the parameter key map.
            content += key + ' : ' + pageRef.getParameters().get(key) + '\n';
        opportunity.PayPalInfo__c = content;
        opportunity.paid__c = True;
        update opportunity;

        PageReference newPage = new ApexPages.StandardController(opportunity).view();

        return newPage;
     } catch (System.Exception e){
         //A failure occurred
         return null;

    public Opportunity opportunity {get; set;}

    public IPNHandlerController() {
We have API connection with external system. They cannot use same session and hence will be requesting new session (previous session will still be active) each time they connect with Salesforce.

Can someone please explain:
- What happens to previous sessions?
- Do they expire automatically after 120 minutes?
- At a given time, how many active session there can be?
- What are the implications of multiple open sessions at given point in time?