Forums

Capture IP address when you can't use an action

desertdiana 28 Jul, 2014
Hi,

On my payment form submitted to my payment gateway (First Data), I don't get the ip address. How do I capture this on the form side instead of using an action?

Diana
desertdiana 28 Jul, 2014
Nope won't work..........I can't use any actions in the On Submit because all on submit actions there are stripped out. Has to be in the view side (on load) of form.
GreyHead 28 Jul, 2014
Hi Diana,

You can capture the IP Address in the On Load event and add it to a hidden input in the form if you need to.

Bob

PS I generally don't recommend submitting directly from a form to a payment gateway. It's safer to submit to ChronoForms, check and save a copy of the data there as an audit trail, then pass it to the gateway.
desertdiana 28 Jul, 2014
So do I use a custom code in the on Load?
I found this in the forum, will this work:

<?php
$form->data['ip_address'] = $_SERVER['REMOTE_ADDR'];
?>


I added a hidden field with the field name of ip_address, is that all I need to do?

I agree but First data won't submit using anything in the onload. We have a special php thank you page that first data redirected to so that may be the issue.
GreyHead 28 Jul, 2014
Hi Diana,

That IP Address code looks OK to me.

I'd be very surprised if First Data can't be accesses from the On Submit event. I took a quick look at their Web API docs and they describe a PHP cURL API there (page 56 on).

Bob
desertdiana 28 Jul, 2014
You are probably right Bob. I would need to hire a programer to do this for me. Way over my head.

I have more trouble with the php thank you page that the first web guy set up for my client that all our donation and event payment forms use. It would be so nice to get away from that.

What do you charge for programmer services?
GreyHead 29 Jul, 2014
Hi Diana,

I'm off to London for a couple of days, drop me a PM if you want to look at using the API and we can work out of it is practical.

Bob
cappleby 17 Jun, 2015
Hi Bob,

I've put a custom code element in the on load section of setup with this code:
<?php
    $form->data['ip_address'] = $_SERVER['REMOTE_ADDR'];
    ?>

and put a hidden element in my form called ip address with field id and field value both set to ip_address but the data that gets stored is simply ip_address. I've attached a screen shot of my setup so far. Can you tell me what I'm doing wrong please.
Chris A
GreyHead 17 Jun, 2015
Hi cappleby,

Two options:

+ leave the value of your hidden input empty and move the custom code up before the HTML (Render Form) action

+ Put the Custom Code in the On Submit event before the DB Save as you don't need it until then.

Bob
This topic is locked and no more replies can be posted.