Some Code from Fundraiser isnt working

Hi,

While going through the fundraising code we came across this line in ipn_handle function in gateway/paypal.php

$full_name = (isset($details['addressList_address(0)_addresseeName']) ? explode(' ',$details['addressList_address(0)_addresseeName'],2) : false);

if($full_name != false) {
        $transaction['first_name'] = $full_name[0];
	$transaction['last_name'] = $full_name[1];
}

But first_name and last_name is never displayed at the back end of the campaign so upon debugging the $details variable which is

$nvp = 'preapprovalKey='.$_POST['preapproval_key'];
$nvp .= '&getBillingAddress=1';
$details = $this->adaptive_api_call( 'PreapprovalDetails', $nvp );

Below is the response from printing detail variable

Array
(
    [responseEnvelope_timestamp] => 2015-06-15T13:50:53.121-07:00
    [responseEnvelope_ack] => Failure
    [responseEnvelope_correlationId] => eb80bbb87f0f0
    [responseEnvelope_build] => 15743565
    [error(0)_errorId] => 550001
    [error(0)_domain] => PLATFORM
    [error(0)_subdomain] => Application
    [error(0)_severity] => Error
    [error(0)_category] => Application
    [error(0)_message] => User is not allowed to perform this action
    [error(0)_parameter(0)] => Billing Address
)

If you notice there is no such thing like firstname or last name there so make the long story short this call is always getting fail (due to which first_name and last_name are not being displayed). Though other API calls like (PAY, PAYMENTDETAILS etc ) are working fine.

Can you please ask the fundraiser developers to look into this and correct us if we are not looking/testing it correctly. Thanks

  • Waqas

    Another code related query we need developers output...

    While debugging the fundraising plugin we came across some anomalies in the code due to which, we think. data is getting lost during pledge creation process in certain cases. @Mainu can you please look into this regard and reply back.

    In gateway/paypal.php process_advanced function

    this part of code is getting the $_POST values after the form submission

    $custom = array();
    $custom['reward'] = (isset($_SESSION['wdf_reward'])) ? $_SESSION['wdf_reward'] : 0);
    $custom['country'] = (isset($_POST['country']) ? $_POST['country'] : 0 );
    $custom['address1'] = (isset($_POST['address1']) ? $_POST['address1'] : 0 );
    $custom['address2'] = (isset($_POST['address2']) ? $_POST['address2'] : 0 );
    $custom['city'] = (isset($_POST['city']) ? $_POST['city'] : 0 );
    $custom['state'] = (isset($_POST['state']) ? $_POST['state'] : 0 );
    $custom['zip'] = (isset($_POST['zip']) ? $_POST['zip'] : 0 );

    the weird thing is that the isset statement is not working if a record is not present we didnt get a zero but a blank is generated and this upsets the piping structure for the ipn url

    for example consider this case in which address 2 is not entered so the query string will not have zero appended in it.

    1||America||542 lighthouse ave||||Monterey||California||93940

    ..................................

    this code chunk is making query string with piping structure

    $custom_ready = array();
    foreach ($custom as $key => $value)
          $custom_ready[$key] = str_replace('||', '', $value);
    $custom = implode('||', $custom_ready);

    but this code is not considering spaces and these spaces mess up the data in the ipn_handle function. like this is the final piping structure formed

    1||United States of America||167 Romaine Dr||address 2||Santa Barbara||CA||93175

    so the response we get in ipn_handle function is something like this

    Array
    (
        [action] => wdf-ipn-return-paypal
        [fundraiser] => 24962
        [pledge_id] => 7f391f078a04
        [custom] => 1||United
        [max_number_of_payments] => null
        [starting_date] => 2015-06-17T00:00:48.000Z
        [pin_type] => NOT_REQUIRED
        [max_amount_per_payment] => 87.21
        [currency_code] => USD
        [sender_email] =>
        [verify_sign] => AiPC9BjkCyDFQXbSkoZcgqH3hhjbhjbjhbjbsT3SOoiB8q5LIxLE0UafKF
        [date_of_month] => 0
        [current_number_of_payments] => 0
        [preapproval_key] => PA-2ND67893SF841481D
        [ending_date] => 2015-06-30T23:59:48.000Z
        [approved] => false
        [transaction_type] => Adaptive Payment PREAPPROVAL
        [day_of_week] => NO_DAY_SPECIFIED
        [status] => Active
        [current_total_amount_of_all_payments] => 0.00
        [current_period_attempts] => 0
        [charset] => UTF-8
        [payment_period] => 0
        [notify_version] => UNVERSIONED
        [max_total_amount_of_all_payments] => 87.21
    )

    see the custom values from the paypal breaks with a space we only get 1||United not all the information and because of this, this code chunk doesnt work in ipn_handle function

    $custom = explode('||',$_REQUEST['custom']);
    $possible_custom_fields = array('reward', 'country', 'address1', 'address2', 'city', 'state', 'zip');
    foreach ($possible_custom_fields as $key => $possible_custom_field)
              if(isset($custom[$key]) && $custom[$key])
                       $transaction[$possible_custom_field] = $custom[$key];

    and the record is lost, so we are not able to understand why these bugs are there in the code. Especially if its working in few cases while not in others.

    Looking forward for a prompt reply on this. Thanks

    • Waqas

      @Maniu

      Hi,

      We test run the updated copy of the Fundraising Plugin and came across the same errors as before

      $_REQUEST variable data

      Array
      (
          [fundraiser] => 5
          [pledge_id] => d5b74b9faf08
          [custom] => 1||United
          [max_number_of_payments] => null
          [starting_date] => 2015-07-03T00:00:34.000Z
          [pin_type] => NOT_REQUIRED
          [max_amount_per_payment] => 1.00
          [currency_code] => USD
          [sender_email] => test@gmail.com
          [verify_sign] => AiPC9BjkCnKoGnJySkoZcgqH3hpacABVtBj0FM-pwSdeRX4dmIxSOE0gd
          [date_of_month] => 0
          [current_number_of_payments] => 0
          [preapproval_key] => PA-6K40488359786560J
          [ending_date] => 2015-08-29T23:59:34.000Z
          [approved] => true
          [transaction_type] => Adaptive Payment PREAPPROVAL
          [day_of_week] => NO_DAY_SPECIFIED
          [status] => ACTIVE
          [current_total_amount_of_all_payments] => 0.00
          [current_period_attempts] => 0
          [charset] => UTF-8
          [payment_period] => 0
          [notify_version] => UNVERSIONED
          [max_total_amount_of_all_payments] => 1.00
      )

      the custom variable still didnt have all the entered information in the form (this is due to spacing present while filling the form like in United States of America the space is breaking the logic for custom fields || structure we pin point this problem before also)

      and this code is still not working

      $nvp = 'preapprovalKey='.$_POST['preapproval_key'];
      $nvp .= '&getBillingAddress=1';
      $details = $this->adaptive_api_call( 'PreapprovalDetails', $nvp );

      $details contains this response

      Array
      (
          [responseEnvelope_timestamp] => 2015-07-03T03:44:05.089-07:00
          [responseEnvelope_ack] => Failure
          [responseEnvelope_correlationId] => 6b550cca0eada
          [responseEnvelope_build] => 15743565
          [error(0)_errorId] => 550001
          [error(0)_domain] => PLATFORM
          [error(0)_subdomain] => Application
          [error(0)_severity] => Error
          [error(0)_category] => Application
          [error(0)_message] => User is not allowed to perform this action
          [error(0)_parameter(0)] => Billing Address
      )
    • Waqas

      Testing website link : http://test.webevangelist.biz/fundraiserupdated/

      Fundraising Version: Version 2.6.1.7

      Recent test results are the following.

      Values Entered in the form:

      Array
      (
          [reward] => 1
          [country] => United States of America
          [address1] => Dummy Address one
          [address2] => Dummy Address one
          [city] => California
          [state] => California America
          [zip] => 25000
      )

      Values Piping Structure

      1||United States of America||Dummy Address one||Dummy Address one||California||California America||25000

      Request Data in handle_ipn

      Array
      (
          [fundraiser] => 7
          [pledge_id] => f3c5f476452d
          [custom] => 1||United
          [max_number_of_payments] => null
          [starting_date] => 2015-07-04T00:00:31.000Z
          [pin_type] => NOT_REQUIRED
          [max_amount_per_payment] => 1.00
          [currency_code] => USD
          [sender_email] => test@gmail.com
          [verify_sign] => An5ns1Kso7MWUdW4ErLHNJJ4qi4-A7BHZ44n7YqWKG3pMttt.f1NxRs5
          [date_of_month] => 0
          [current_number_of_payments] => 0
          [preapproval_key] => PA-85016412CM192840N
          [ending_date] => 2015-08-29T23:59:31.000Z
          [approved] => true
          [transaction_type] => Adaptive Payment PREAPPROVAL
          [day_of_week] => NO_DAY_SPECIFIED
          [status] => ACTIVE
          [current_total_amount_of_all_payments] => 0.00
          [current_period_attempts] => 0
          [charset] => UTF-8
          [payment_period] => 0
          [notify_version] => UNVERSIONED
          [max_total_amount_of_all_payments] => 1.00
      )

      PreapprovalDetails response in handle_ipn

      Array
      (
          [responseEnvelope_timestamp] => 2015-07-04T04:08:48.141-07:00
          [responseEnvelope_ack] => Failure
          [responseEnvelope_correlationId] => ed6373a3343ec
          [responseEnvelope_build] => 15743565
          [error(0)_errorId] => 550001
          [error(0)_domain] => PLATFORM
          [error(0)_subdomain] => Application
          [error(0)_severity] => Error
          [error(0)_category] => Application
          [error(0)_message] => User is not allowed to perform this action
          [error(0)_parameter(0)] => Billing Address
      )

      ###############################################################

  • Maniu

    Hey @Waqas

    Fundraising code is ready for this to fail. Please take a look here:
    https://developer.paypal.com/docs/classic/api/adaptive-payments/PreapprovalDetails_API_Operation/
    "This field is available only to API callers with advanced permission levels. For information, refer to the section Adaptive Payments Permission Levels."
    That's why response have error.

    Do you have any other issue with the plugin?

    Thanks,
    Maniu

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.