CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Injecting address info into Paypal Standard
Pages: [1]

Author Topic: Injecting address info into Paypal Standard  (Read 3418 times)

Thinkling

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
Injecting address info into Paypal Standard
May 18, 2008, 04:29:23 pm
I wanted to prevent requiring users to enter their address info twice, once on our Contribution form, and then again once we send them off to Paypal Standard.

To achieve this, I made the modification included below to CRM/Core/Payment/PayPalImpl.php starting with the version from 2.0.1.

If you feel this is worth submitting in JIRA, please let me know if there's a standard on what diffs should look like--I didn't see one offhand.

Maarten.


Code: [Select]
Index: PayPalImpl.php
===================================================================
--- PayPalImpl.php (revision 189)
+++ PayPalImpl.php (working copy)
@@ -299,7 +299,33 @@
                    'return'             => $returnURL,
                    'rm'                 => 2,
                    'currency_code'      => $params['currencyID'],
-                   'invoice'            => $params['invoiceID'] );
+                   'invoice'            => $params['invoiceID'],
+            //!mvd mod to propagate contact info to Paypal starts here
+                   'first_name'         => $params['first_name'],
+                   'last_name'         => $params['last_name'] );
+
+        // CiviCRM can store multiple addresses, so we need to be agnostic as to what address
+        // for the contact was entered on the form. (field names are of the form street_address-Primary,
+        // street_address-Billing)
+        $field_names = array( 'street_address' => 'address1',
+        'city' => 'city',
+        'state_province' => 'state',
+        'postal_code' => 'zip',
+                                'email' => 'email' );
+       
+        foreach ( array_keys( $params ) as $p ) {
+          $parts = split( '-', $p );
+          if ( count( $parts ) > 1 && in_array( $parts[0], array_keys( $field_names ) ) ) {
+            // there was a hyphen, and the bit before it is one of the vars we're looking for
+           
+            if ( 'state_province' == $parts[0] ) {
+              $paypalParams[$field_names[$parts[0]]] =
+                CRM_Core_PseudoConstant::stateProvinceAbbreviation( $params[$p] );
+            } else {
+              $paypalParams[$field_names[$parts[0]]] = $params[$p];
+            }
+          }
+        }
 
         // if recurring donations, add a few more items
         if ( ! empty( $params['is_recur'] ) ) {

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Injecting address info into Paypal Standard
May 18, 2008, 05:54:47 pm

yes, can you please file an issue in JIRA and attach the patch

thanx for taking the initiative to address and fix the issue. much appreciated

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Thinkling

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
Re: Injecting address info into Paypal Standard
May 18, 2008, 06:15:34 pm
CRM-3130

I filed against 2.0 since that's what the patch applies to.

This is my first JIRA entry--let me know if I should have done things differently.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Injecting address info into Paypal Standard

This forum was archived on 2017-11-26.