PDA

View Full Version : How to retrieve IP address from IPN


vb_mp
09-03-2008, 06:36 AM
Hi,

I am in the process of integrating the IDevAffiliate affiliate management system with my paid subscription ( getting some help from the owner of IDevAffiliate).

In order for it to work, I need to retrieve the customer IP address once payment has been safely processed.

Can someone please tell me how I can get the IP address?

Thanks,

John

Marco van Herwaarden
09-03-2008, 01:27 PM
You can use the constant IPADDRESS.

vb_mp
09-03-2008, 01:44 PM
Hi Marco,

The constant IPADDRESS is set when payment is completed?

Thanks,

John

Dismounted
09-04-2008, 07:39 AM
IPADDRESS is set in init.php - which all vBulletin files run before anything else.

vb_mp
09-04-2008, 08:08 AM
Thanks Dismounted.

What happens in a scenario where a user pays for monthly subscription and it gets processed via IPN. One month later, PayPal triggers subscription payment again and it goes to vbulletin IPN. Does the IPADDRESS constant get initialized to the IP address that was initially used for this payment ( perhaps retrieved from database or passed from PayPal)?

John

Marco van Herwaarden
09-04-2008, 09:02 AM
No, that would probably give the IP of PayPal. I don't think the IP that initiated the recurring payment is stored. Also the user could be on a different IP a month later. For what reason you need this original IP?

vb_mp
09-04-2008, 09:11 AM
Apparently idevaffiliate requires IP address for recurring payments - to assign the commission to the correct affiliate when the recurring payment occurs (kind of stupid). It is what their tech has told me.

I have sent them an inquiry... to check this.

But, on another note... a month later the user won't be there right? The recurring payment will be done automatically and does not need the user's approval.

John

Marco van Herwaarden
09-04-2008, 10:03 AM
That is the whole problem it seems. The user doesn't initiate the recurring payment, so there is no current IP for that user. I don't see how you can ever solve that.

vb_mp
09-04-2008, 10:43 AM
Hm, I was hoping the first time the payment happens, the IP address gets saved in the vbulletin db somewhere.

On recurring payment ( the automatic one ), I could perhaps pull the IP address from the db based on transactionId perhaps.

Marco van Herwaarden
09-04-2008, 11:17 AM
You could probably create a small plugin that will store the ip-address in the subscriptionlog table when the subscription is created. You could then use this stored IP on the recurring payment. It would not really be usefull though, as the user mightbe using a different ip by this time.

vb_mp
09-04-2008, 11:40 AM
Yep, but second time around I would not care.

IDevAffiliate, how I understand it works as follows for recurring payments:

1. User pays the amount. vbulletin IPN script with curl sends amount, transactionId, IP address, affiliateId to idevaffiliate. Idev affiliate records IP address and affiliateId to record commissions.

2. On next recurring payment, IPN script with curl sends amount, transactionId, IP address retrieved from db to match last one, affiliateId to idevaffiliate. Idev affiliate again records commission for same affiliate.

So I suppose the IP address is used by idev affiliate to hack the subscription recurring commission.

I hope that explains it.

So. The plugin you mention would work as follows:

Use some field which is common between recurring payments ( i dont know if this is transactionId or something else ).

Query database to see whether transaction already exists (with IP address). if exists, pull out IP address. If does not exists, store IP address in vbulletin database against transactionId.

John