I am testing IPN In sandbox. At my website I log this communication between Paypal and my site
Start validations:_notify-validate,16.94,Eligible,confirmed,SVWAAUVZX2S4Y,0.00,1 Main St,13:57:50 May 07, 2012 PDT,Completed,windows-1252,95131,Test,0.84,US,Test User,3.4,,verified,demarc_1336421374_biz#gmail.com,United States,San Jose,1,As4zhnwQeMSnsOdh0NBxc2GkfRrEAd8OPZnnd3EWRDz38L81PzX-6vI- ,demarc_1321350258_per#gmail.com,6FT25620DT6366410,instant,User,CA,demarc_1336421374_biz#gmail .com,,6SHJZ2PT5YMLS,web_accept,test item,EUR,,US,1,0.00,test item,,0.00,de0561482901
2012-05-07 22:52:47 Paypal: ResponseVERIFIED
2012-05-07 22:52:47 Paypal: 1
2012-05-07 22:52:47 Paypal: Processing Trasaction: 4fa8361f-7574-444f-b821-5e660a00000f
2012-05-07 22:52:47 Paypal: 4fa8361f-7574-444f-b821-5e660a00000f
It seems ok, uh? But if I login into Sandbox with the business account, in IPN History I see that Paypal is keeping trying to send IPN. At my website, where I log transaction into database, I see a lot of records (which I store if the response is verified).
How is it possible?
I do a post back to Paypal with cakephp
function isValid($data ){
$data['cmd'] = '_notify-validate';
$newData['cmd'] = '_notify-validate';
foreach ($data AS $key => $val) {
$newData[$key] = $val;
}
$this->log("Start validations:".join(",",$newData), 'paypal');
$data = array_map(array('PaypalIpnSource', 'clearSlash'), $newData);
if (isset($data['test_ipn'])) {
$server = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
} else {
$server = 'https://www.paypal.com/cgi-bin/webscr';
}
$response = $this->Http->post($server, $newData);
$this->log("Response".$response, 'paypal');
if ($response == "VERIFIED") {
return true;
}
if (!$response) {
$this->log('HTTP Error in PaypalIpnSource::isValid while posting back to PayPal', 'paypal');
}
return false;
}
}
I do not think it is a problem of cakephp or whatever.
I set in the sandbox business account EUR as currency. And also the currency value in the paypal submission form is in EUR.
Any help appreciated after days of googling.
Your IPN endpoint must reply with HTTP status code 200 to the PayPal's notification. Otherwise the status will stay "Retrying".
Related
I need some help with my App Engine apps. I have two aplications, one of them in php and the other in python (both do the same thing). These applications show a list of matters and exports with google vault api, but after two or three calls to the api these apps stay in a state of loading and i get a 500 error, returned by App Engine, but I have a feeling that it is a Google Vault Api problem. Sometimes these work well, but if I reload the pages I get the same error. Do you know if there is a problem with App Engine and Google Vault Api?
Some times a get the error calling listMatters method:
try{
$client = getClient();
$service = new Google_Service_Vault($client);
$optParams = array(
'pageSize' => 100
);
$results = $service->matters->listMatters($optParams);
$matters = $results->getMatters();
} catch (Exception $e) {
die(var_dump($e->getMessage()));
}
Other times calling listMattersExports method:
try {
$client = getClient();
$service = new Google_Service_Vault($client);
$resultsExports = $service->matters_exports->listMattersExports($matterId,$optParams);
$exports = $resultsExports->getExports();
}catch (Exception $e){
die(var_dump($e->getMessage()));
}
The problem is I get 500 error, but no an Api error.
I'm building an SPA that a user can upload some files. The front-end is written in AngularJS while the back-end is using an API in Laravel 5.7. The authentication is implemented using the jwt-auth library.
So far I have implemented this for registered users where each user has a personal directory on the server where he/she uploads the files. The difference between the registered and the anonymous users is that the files of the anonymous will be deleted after a while.
Now, I want to do the same for anonymous/guest users (if the press the button continue as a guest). So what I tried first in the authContrroller.php side is to use something like this:
public function authentication(Request $rrequest) {
$credentials = $request->only('email', 'password');
// Guest authentication
if( $credentials['email'] === 'guest' && $credentials['password'] === 'guest' )
{
$payload = auth()->factory()->claims(['sub' => $this->createRandomDir()])->make();
$token = auth()->manager()->encode($payload);
// OR
$factory = JWTFactory::customClaims([
'sub' => $this->createRandomDir(),
]);
$payload = $factory->make();
$token = JWTAuth::encode($payload);
}
// Registered user authentication authentication
else
{
if (! $token = auth()->setTTL(60)->attempt($credentials))
return response()->json(['error' => 'invalid_credentials'], 400);
}
return response()->json(compact('token'));
}
The idea was to create a random directory and enclose it inside the payload and use it on the next requests.
But in the case of the guest, the server returns as a token an empty object. Possibly because there wasn't a user in the DB.
Another idea that I'm thinking of is to create a random user (add it to the DB) and assign to it a random directory each time a user needs to use the app as guest/anonymous. The only thing that I'm afraid on that approach is that if there are thousands of guests then thousands random users should be created on the DB.
So what do you think? Is there any other and more efficient way to handle this?
Any idea is welcomed.
I am writing a android and windows native app. The native app stores the login details as reated for mulitple other web apps, and logs them into this when browsing to them from the native app.
one of the buttons in my app open a prestashop site for a authenticated user. How can i set the username and password and log that user in to the site programmitcally, giving the illusion and user experience that he has been seemlessly authenticated and accessed to his shop.
I know this is an old question, but theres another way which i find better for the purpose.
You include the AuthController from the controllers folder, set your post-parameters and execute the postProcess() method. After this, you can check the "$authController->errors" array for errors. If it's empty - the login was successful.
Example:
public function hookDisplayHeader()
{
if ($this->context->cookie->isLogged())
{
return;
} else {
$acceptLogin = false;
if( isset( $_POST["email"] ) && isset( $_POST["passwd"] ) )
{
$acceptLogin = $this->attemptLogin($_POST["email"],$_POST["passwd"]);
}
if( $acceptLogin )
return;
die( $this->display(__FILE__, 'logintemplate.tpl') );
}
}
protected function attemptLogin($email, $password)
{
include _PS_FRONT_CONTROLLER_DIR_ . "AuthController.php";
$auth = new AuthController();
$auth->isAjax = true;
$_POST["email"] = $email;
$_POST["passwd"] = $password;
$_POST["SubmitLogin"] = true;
$auth->postProcess();
if( count($auth->errors) > 0 )
{
$this->context->smarty->assign( "errors", $auth->errors );
return false;
} else {
return true;
}
}
Edit: This no longer works with Prestashop 1.6. As of PS 1.6 $auth->postProcess() either redirects or sends the ajaxs response immediately. There is no way to circumvent this. If you want to do something after login, you have to make two ajax calls.
Basically do the same as the PrestaShop login form does, which is (for v1.5 at least):
Sending a POST request to http(s)://yourshop.com/index.php?controller=authentication with the following parameters:
email: your customer's email address
passwd: your customer's password
back: name of the controller you want to be redirected to after success (ex: my-account)
SubmitLogin: put anything there, it just needs to be true, so that the controller knows it's a login action
If it doesn't work, your version may work differently and you will have to check the network tab of your favourite developer tool, to see what kind of request is sent with which parameters.
I am using CakePHP 1.3.10 version and want to integrate PayPal IPN for Payment Process.
I have found some ready made plug-ins though not working properly and returning bunch of errors.
I would like your suggestions, Any body in community using the same with success and any tutorial to integrate in easy steps.
Your response would be appreciated.
Thanks !
I just discovered a nice PHP class, that runs all the PayPal IPN.
https://github.com/Quixotix/PHP-PayPal-IPN/
I turned it into a Component for my CakePhp project.
For this just create a new Component in you app/Controller/Components/ folder and paste the code from that project.
Then Change:
class IpnListener {
...
to
class IpnListener extends Component {
...
Then go back to the controller you want to you PayPal Ipn with and add:
public $components = array('IpnListener');
You can than access the class using:
$this->IpnListener->foo
within your controller functions
Hope this helps
I used Paypal IPN with cake before, and it's simple enough to not have to reply on a plugin. Are you using that to track getting payment in a cake app? You can create the paypal form/button in your paypal account, set the url callback so paypal can notify you. Create a table in DB if you want to record the info paypal sends you. Have a method in the controller to handle the POST data from paypal. Here's my code example:
function blah() {
$this->autoRender = false;
// post back to PayPal system to validate
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {// HTTP ERROR, we should record the data still..?
} else {
fputs($fp, $header . $req);
while (!feof($fp)) {
$res = fgets($fp, 1024);
if (strcmp($res, "VERIFIED") == 0) {// verified from paypal, processing...
} else if (strcmp($res, "INVALID") == 0) {
// oh no, someone is hijacking us...
}
}
fclose($fp);
}
}
What fields to have in the table depends on what you want to keep. Look up the IPN API, and you can setup sandbox testing with paypal.
I'm developing application with CakePHP 1.3 and using its Auth component. Is it possible to count login fails in order to deactivate users account after a few unsuccessfull attempts? Is there anything like loginErrorRedirect?
How are you intending to deactivate a user if they can't login? If they login as
test#test.com FAIL
tester#test.com FAIL
test123#test.com FAIL
are you going to invalidate all these users?
To record login failures, your could add the following to your login() action in whatever controller
if(empty($this->Session->Auth) && isset($this->data))
{
if($this->Session->read('login.fail'))
{
$login_fail = $this->Session->read('login.fail') + 1;
}else{
$login_fail = 1;
}
$this->Session->write("login.fail",$login_fail);
}