Pass a variable (affiliate ID) via custom field to Paypal IPN handling script?

Is there an option whereby I can pass a variable (affiliate ID) via the custom field to the IPN handling script??

I am trying to integrate an affiliate plugin that allows me to pay the affiliate recurring payments since the membership pays recurring payments (the WPMU plugin does not allow this), so I am wondering if the above is possible.

Thanks!

  • rlthorman

    Thanks, Barry. How would I add something to the end of the field? Here is what I would need to add:

    <input type="hidden" name="custom" value="<?php echo $_COOKIE['ap_id']; ?>">

    I don't have that level of coding to change the WPMU affiliate plugin so it is easier for me to just integrate the other affiliate plugin. Unless it is indeed easier to do change your affiliate to add recurring payments - any suggestions?

  • Barry

    I don't have that level of coding to change the WPMU affiliate plugin so it is easier for me to just integrate the other affiliate plugin.

    It can quite complex to edit the IPN - you need to find the function in there that builds the custom field and then append your bit of data to that - I believe the function is called something like "build_custom_field". Then you'll need to edit the IPN response handling function to pull out the bit you added to the end of the custom field and pass it to your affiliate system when the correct response is returned (Completed or Purchased I think are the ones to look for).

  • rlthorman

    Are you talking about in the Paypal payment gateway in the membership plugin? Here it is --

    function build_custom($user_id, $sub_id, $amount) {
    
    		$custom = '';
    
    		//fake:user:sub:key
    
    		$custom = time() . ':' . $user_id . ':' . $sub_id . ':';
    		$key = md5('MEMBERSHIP' . $amount);
    
    		$custom .= $key;
    
    		return $custom;
    
    	}

    And then I could just add $_COOKIE['ap_id'] in there somehow?

    If I could add that into the custom field (I just don't know how to appropriately do it), it seems to me that would work, since the IPN handling script in the affiliate plugin as I understand it is already set to look for the affiliate ID in the custom field. That's why they told me to put the affiliate ID variable in the custom field.

    So then I could just place the URL of the ipn handling script in the paypal button's code in the notify_url part. Here is what is currently in the membership plugin in the notify_url section:

    $form .= '<input type="hidden" name="notify_url" value="' . trailingslashit(get_option('home')) . 'paymentreturn/' . esc_attr($this->gateway) . '">';

    I'm not sure what http://mysite.com/paymentreturn does - can I just replace that URL with the URL of the IPN handling script?

    Am I thinking about this right? So I guess I'm wondering :

    1) Could you tell me how to add the variable $_COOKIE['ap_id'] to the build_custom function? and
    2) Can I replace what is currently in the notify_url to the URL of my IPN handling script?

    Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.