Welcome Guest, Not a member yet? Register   Sign In
Help w/ form_open and PayPal IPN
#1

[eluser]Unknown[/eluser]
Hello,

Editing an existing site built with CodeIgniter, so I'm not super familiar with this. Hoping someone can shed some light on this for me.

I have a site that is laid out thusly: Main Page Entry > Amount Slider > PayPal > Guest List > Confirmation. When I send the users to PayPal and it returns to my site, it provides me a URL that looks like so:

Code:
http://example.com/page3.php?payer_id=8675309&amount=300&payment_type=instant&payment_status=complete&custom=182&...

I need to figure out a way to have that information passed into my database. Functions existed for this previously, but they never worked properly.

The Guest List page is running a echo form_open(), and the database entry stuff is in there. However, I feel like the relevant code isn't being executed, since the URL is generated on page load instead of afterwards. (Please let me know if this doesn't make any sense.)

Could I use a $_GET or something of the sort to pull those PayPal variables down to hidden fields or something, or is there an easy way to do this that I'm just missing?

Thanks.
#2

[eluser]robert.fulcher[/eluser]
I would start by looking at the URI helper

https://ellislab.com/codeigniter/user-gu...elper.html

I think everything you need to do can be done from this helper.

#3

[eluser]CroNiX[/eluser]
I'm not sure this has anything to do with form_open. So once the info is submitted to paypal, paypal redirects to your site with a url containing a query string? And you want to get the values from that query string?

Code:
$this->load->helper('url');
$parsed = parse_url(current_url(), PHP_URL_QUERY); //get just query string from current url

if ( ! empty($parsed))
{
  //parse the query string into an array and store in $parts
  parse_str($parsed, $parts);
  print_r($parts);
}

//With your example URL it should return
array(
  payer_id       => 8675309,
  amount         => 300,
  payment_type   => instant,
  payment_status => complete,
  custom         => 182
)
#4

[eluser]Unknown[/eluser]
Do I dump this in a PHP block at the start of this particular page that's loading w/ that URL?

Also, PayPal is returning 39 pieces of info, and I only need those 5. Any clue how to snatch those?

Thanks for your help!
[quote author="CroNiX" date="1406829653"]I'm not sure this has anything to do with form_open. So once the info is submitted to paypal, paypal redirects to your site with a url containing a query string? And you want to get the values from that query string?

Code:
$this->load->helper('url');
$parsed = parse_url(current_url(), PHP_URL_QUERY); //get just query string from current url

if ( ! empty($parsed))
{
  //parse the query string into an array and store in $parts
  parse_str($parsed, $parts);
  print_r($parts);
}

//With your example URL it should return
array(
  payer_id       => 8675309,
  amount         => 300,
  payment_type   => instant,
  payment_status => complete,
  custom         => 182
)
[/quote]
#5

[eluser]CroNiX[/eluser]
[quote author="niclake" date="1406830671"]Do I dump this in a PHP block at the start of this particular page that's loading w/ that URL?

Also, PayPal is returning 39 pieces of info, and I only need those 5. Any clue how to snatch those?

Thanks for your help!
[/quote]
Yes, just put it on the page that has the url...but if you only need 5 pieces, it might be better doing:

Code:
$paypal_data = array(
    'payer_id'       => $this->input->get('payer_id', TRUE),
    'amount'         => $this->input->get('amount', TRUE),
    'payment_type'   => $this->input->get('payment_type', TRUE),
    'payment_status' => $this->input->get('payment_status', TRUE),
    'custom'         => $this->input->get('custom', TRUE)
);

Then you can just insert it into the database.
Code:
$this->db->insert('table', $paypal_data);




Theme © iAndrew 2016 - Forum software by © MyBB