Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-9994

Incorrect City/State/Zip when sending data to Paypal Standard (PayPalImpl.php) when using multiple profiles

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Incomplete
    • Affects Version/s: 4.1.1
    • Fix Version/s: Unscheduled
    • Component/s: CiviContribute, CiviEvent
    • Labels:
      None
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      I occasionally use CiviContribute to collect political contributions on behalf of my clients. State and Federal law require that you collect employer Name and Address information for contribution above a certain amount.

      For these, I create a new profile called "Employment Data". In it I have the following fields:

      Occupation (Individual-Job Title)
      Employer Name (Individual-Current Employer)
      Address (Contacts-Street Address-Work)
      City (Contacts-City-Work)
      State (Contacts-State-Work)
      Postal Code (Contacts-Postal Code-Work)

      I also use the default Name and Address profile which include (among others) the following fields:

      Address (Contacts-Street Address-Home)
      City (Contacts-City-Home)
      State (Contacts-State-Home)
      Postal Code (Contacts-Postal Code-Home)

      Problem:

      When the data is passed to Paypal, the Paypal Credit Card contact information field includes the address / city / state / zip data from the employer data, and not the individual contributor.

      The section of code in question is as follows: /civicrm/CRM/Core/Payment/PayPalImpl.php starting round line 475:

      foreach ( array_keys( $params ) as $p ) {
      // get the base name without the location type suffixed to it
      $parts = explode( '-', $p );
      $name = count( $parts ) > 1 ? $parts[0] : $p;
      if ( isset( $otherVars[$name] ) ) {
      if ( isset( $paypalParams[$otherVars[$name]] ) ) continue; //ADDED BY WMENA
      $value = $params[$p];
      if ( $value ) {
      if ( $name == 'state_province' )

      { $stateName = CRM_Core_PseudoConstant::stateProvinceAbbreviation( $value ); $value = $stateName; }

      if ( $name == 'country' )

      { $countryName = CRM_Core_PseudoConstant::countryIsoCode( $value ); $value = $countryName; }

      // ensure value is not an array
      // CRM-4174
      if ( ! is_array( $value ) )

      { $paypalParams[$otherVars[$name]] = $value; }

      }
      }
      }

      The cause of the problem is the use of the "explode" statement in order to "get the base name without the location type suffixed to it". If you are using 2 address fields in your form, the first one comes in as street_address-1 and the second as street_address-2. The purpose of the "explode" line is to remove the suffix (in this case, the -1 and -2). That leaves you with 2 fields with identical names. The data for the second one will overwrite the first.

      Since my "Employment Data" is the second of the 2 profiles used, it's data comes through after the Name and Address data.

      To resolve this for my needs, I added the line above (marked //ADDED BY WMENA). It checks to see if the Paypal parameter was already set. If so, it will skip the rest of the code and grab the next field.

      Again, this works for my needs, but is not foolproof.

      Thoughts?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              wmena wjm
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: