0

I have a form that has information that the user fills out about a class and includes payment information that is redirected to PayPal's payflowlink. Before I added the payflowlink I was posting the the form information to the same page and emailing the class information to an email address. Now with the action of the form set to the payflowlink the class information does not get emailed to me, but the payment information does get passed to the payflowlink.

I thought maybe a redirect page would work using <meta http-equiv="refresh" content="0; url=https://payflowlink.paypal.com">, but the $_POST does not get passed to the payflowlink. How can I get the $_POST information passed from the redirect page to the payflowlink page?

Right now I have the form page posting the information to the redirect page, the redirect page emails the the information, but the $POST is not passed to the payflowlink. The payflowlink page is hosted by PayPal.

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Registration</title>
  <meta http-equiv="refresh" content="0; url=https://payflowlink.paypal.com">

</head>

<body>
  <?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);

if ($_SERVER["REQUEST_METHOD"] == "POST") {

  if (isset($_POST["name"])) {
    $name = $_POST['name'];
    $EmailBody = "Parent's Name: ".$_POST["name"]."<br>";
  }

    $subject = "Registration";
    SendMail($email, $EmailBody, $subject);
    echo ($EmailBody);
}

?>

    <main id="main">
      <h1>Registration Form</h1>

      <p><a href="https://payflowlink.paypal.com">Click this link if you are not redirected</a></p>

    </main>

  </body>

</html>
BrianC987
  • 167
  • 1
  • 14

2 Answers2

0

You should be careful with Payment gateways. You are not supposed to let users post sensitive data like credit card numbers directly through your server. You need to pass the info directly to the gateway which would do the processing then redirect back to your site and pass over a secure token.

https://developer.paypal.com/docs/classic/payflow/integration-guide

You can however send an email when you first request the secure token from gateway. You can also attach a button onclick event to a button which the user would click to be redirected with Ajax request to the server to send email, then on getting back response from server, redirect the user.

TurtleTread
  • 1,297
  • 2
  • 12
  • 23
-1
  <?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);

if ($_SERVER["REQUEST_METHOD"] == "POST") {

  if (isset($_POST["name"])) {
    $name = $_POST['name'];
    $EmailBody = "Parent's Name: ".$_POST["name"]."<br>";

    $subject = "Registration";
    SendMail($email, $EmailBody, $subject);
    //echo ($EmailBody);

    /* PAYPAL implementation here, instead header(); */
    header('Location: https://payflowlink.paypal.com');
  }


}

?>


<!DOCTYPE html>
<html lang="en">

<head>
  <title>Registration</title>

</head>

<body>

<main id="main">
  <h1>Registration Form</h1>

  <p><a href="https://payflowlink.paypal.com">Click this link if you are not redirected</a></p>

</main>

  </body>

</html>

One thing is, You can not echo, before redirect. But you already get $Emailbody as an e-mail.

UPDATE

to pass $_POST information to the payflowlink page, you should follow related API document.

Example above is only for basic redirect.

Оzgur
  • 432
  • 2
  • 10
  • I get the same result. I get an email but the payflowlink errors out. I see your commented out the echo and added the header. I also tried commenting out the meta refresh tag in the header. – BrianC987 Apr 16 '17 at 19:43
  • @BrianC987 I thought you need basic redirect at first, but you need to pass parameters. So you must follow Paypal PHP API docs and probably implement CURL in your code. – Оzgur Apr 16 '17 at 19:46
  • @Ozgur I have never used CURL can you explain how I would do that. – BrianC987 Apr 16 '17 at 20:27
  • @BrianC987 I did some search. You won't need to use curl directly. paypal has it's own SDK, which must be downloaded and integrated into your code. And then you can use code examples for which solution you need. Everything you need is here http://paypal.github.io/PayPal-PHP-SDK/ – Оzgur Apr 16 '17 at 20:37