0

At the moment on successful paypal payment I pass a url with a paramater such as:

 mysite.com/membership.php?c=h7Y6734da

I have some code that searches for code then updates a membership field in the database.

    if($_GET['c'] == 'h7Y6734da')
{
    $sqlInsert = ("UPDATE Customer SET Membership_Status = 1 WHERE Id = :user");
    $preparedStatement = $db->prepare($sqlInsert);
    $preparedStatement->execute(array(':user' => $userid));
}

The customer would have been at the page mysite.com/membership.php (where their Id is stored in the session) before clicking the payment button.

My database is not updating and I am not sure why, I believe when being send back to the page from paypal the session is being lost but I am not sure what else I can do.

Dppal
  • 43
  • 1
  • 6

1 Answers1

0

You should paste all your code information, but I will try to help.

I understand that you send to Paypal the 'returning url' as mysite.com/membership.php?c=h7Y6734da . I don't think that your Session isn't valid when returning from Paypal (how you get the Session user info? in the example code I can't see it).

You can take a look at official documentation of Paypal on how interact with Payment Data Transfer: https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/paymentdatatransfer/

Maybe you have to enable auto return in your PayPal account, otherwise it will ignore the return field. And then you don't get any GET (and your code will never updates). More info here.

This could explain why you don't get your user info updated.

If you are using the notify_url like:

<input type="hidden" name="notify_url" value="mysite.com/membership.php?c=h7Y6734da">

IPN will be triggered every time a transaction occurs regardless of whether or not the user makes it back to your site after completing payment.

The notify URL is used for IPN only, and it would override any setting you have in your PayPal profile for IPN. PDT needs to be configured in your PayPal account profile in order to get data returned to your return URL.

Hope it helps! If no, try to update your question with full code example and specific problem!

JP. Aulet
  • 4,375
  • 4
  • 26
  • 39