I have a PayPal account and I want to implement PayPal transactions in my site. For test payment, I use Sandbox Environment.
I can redirect the user to sandbox PayPal page, I can pay with the default sandbox buyer account and after all, I'm also redirected back to my site. Which is great.
The problem is the ipn.php
(notify URL) isn't called by PayPal Sandbox. I would know if is called 'cause the file sends me an email at the beginning. I did everything I knew.
Strange is that from IPN Simulator, ipn.php is called.
I also created new Sandbox accounts from developer.paypal.com/developer/accounts/create
, but I didn't even receive a confirmation email to can confirm them. And still, ipn.php wasn't called by Sandbox PayPal when using the new sandbox accounts.
I tried several days, but there's nothing more I can try. Internet and PayPal Sandbox Documentation says that default sandbox accounts are already confirmed. So It had to, theoretical, call the ipn.php file
.
You don't have to worry about ipn.php path. I checked many times. It's the good one.
This is the code:
$exCheckout = new \PaypalExpressCheckout\Request\SetExpressCheckout();
$exCheckout->setUsername($_config['apikeys']['paypal_username'])
->setPassword($_config['apikeys']['paypal_password'])
->setSignature($_config['apikeys']['paypal_signature'])
->setSandbox()
->setQueryParameter('NOTIFYURL', $_base . 'models/paypal/ipn.php')
->setQueryParameter('RETURNURL', route('hotel-thank-you', $_id_booking))
->setQueryParameter('CANCELURL', (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http" . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"))
->setQueryParameter('PAYMENTREQUEST_0_PAYMENTACTION', 'Sale')
->setQueryParameter('PAYMENTREQUEST_0_AMT', $_card_price)
->setQueryParameter('PAYMENTREQUEST_0_CURRENCYCODE', 'EUR')
->setQueryParameter('NOSHIPPING', '1')
->setQueryParameter('LOGOIMG', $_base.'static/img/logo.png');
if (!$exCheckout->isValid()) {
throw new Exception('Missing Parameters: ' . implode(', ', $exCheckout->determineMissingFields()));
}
$paypalResponse = $exCheckout->send();
if ($paypalResponse->isSuccess()) {
db_query('UPDATE booking SET paypal_token = ? WHERE id_booking = ?',
$paypalResponse->getParameter('TOKEN'),
$_id_booking
);
$paypalResponse->setSandbox();
$paypalResponse->authorize();
}
else {
die('No Success PayPal checkout');
}
Can you please help me?
Fist make sure that you have business account either on Sandbox or production.
Then follow next steps and paypal will hit your notify URL.
Click My selling tools.
Note: If you do not see the profile icon on the top right, navigate to My Account > Profile > My Selling Tools.
You have to put same notify URL in request as well as settings.