dotnetrocks
dotnetrocks

Reputation: 2727

paypal - on success - redirect is not working

I created a sandbox paypal account and used IPNListener from tutorial http://www.micahcarrick.com/paypal-ipn-with-php.html . In my code, after the verifying paypal response, trying to redirect to a dynamic url. After successful payment in paypal, it is not redirecting to the dynamic url

    include('ipnlistener.php');
    $listener = new IpnListener();
    $listener->use_sandbox = true;
    $listener->use_ssl = false;

    try {
        $listener->requirePostMethod();
        $verified = $listener->processIpn();
     } catch (Exception $e) {
     error_log($e->getMessage());
     exit(0);
     }
    $url1="http://www.google.com";
    $url2="http://www.ayond.se";
     if ($verified) {
      header('Location: '.$url1);
     }
     else
     {
           header('Location: '.$url2);
      }

Upvotes: 0

Views: 389

Answers (3)

Drew Angell
Drew Angell

Reputation: 26036

It sounds like you're confusing IPN and PDT.

IPN happens completely separate from your checkout pages and it is server to server communication. PayPal simply POSTs data to this URL and you can process that data accordingly. This allows you to automate tasks like database updates, email notifications, etc.

It's not something that happens within the browser session, though, so redirects aren't going to work here.

In order to set where the user will go after they've completed payment you'll need to set ReturnURL in your API calls, or the return field in standard button form code.

Upvotes: 1

Louis Loudog Trottier
Louis Loudog Trottier

Reputation: 487

make sure you don't have any content before your header('Location: '.$url2); call. (aka sould be only php code before you redirect)

Upvotes: 0

Varun Sheth
Varun Sheth

Reputation: 156

check your code properly, you are redirecting to $url on success, you don't have $url you have $url1

Ok so no that you edited your code, did it work ?

Upvotes: 0

Related Questions