why Call to undefined method Srmklive\PayPal\Services\PayPal::setExpressCheckout() - laravel

i try implement the paypal pay on my project, i using the srmklive/paypal v3 and and stamen giving this error
Call to undefined method Srmklive\PayPal\Services\PayPal::setExpressCheckout()
use Srmklive\PayPal\Services\PayPal as PayPalClient;
$provider = new PayPalClient;
$response = $provider->setExpressCheckout($data);
$response = $provider->setExpressCheckout($data, true);
return redirect($response['paypal_link']);
tried to look for ams solutions so far nothing if someone can help me thank you

may be due to mismatch of version.
try using this in composer.json
srmklive/paypal: "~1.0"

Related

Phalcon 4.0 setting up Session

I am trying to make an session in my phalcon project, version 4.0 but I am getting this error while creating an session.
Class 'Phalcon\Session\Adapter\Files' not found
$di->setShared('session',function(){
$session = new \Phalcon\Session\Adapter\Files();
$session->start();
return $session;
});
If someone knows a method in which I can create an session please let me know!
this seemed to work for me
$di->setShared('session',function(){
$session = new Phalcon\Session\Manager();
$files = new Phalcon\Session\Adapter\Stream( [
'savePath' => '/tmp',
]);
$session->setAdapter($files)->start();
return $session;
});
Phalcon\Session\Adapter\Files class was renamed to Phalcon\Session\Adapter\Stream in Phalcon 4.0.0
check the documentation for other issues you could run into if you recently upgraded
if you copied that code from the documentation then its for Phalcon 3.4.x

can not redirect to 403 page in magento 2

Hi guys I am trying to restrict customers on frontend on basis on geo location.Issue is when am trying to dispatch 403 status code from observer using $observer->getControllerAction(); ,It returns null.
Please have a look over the code i have used.
Any help is highly is highly appreciated.
protected function denyAccess($observer)
{
$action = $observer->getControllerAction();
$response = $action->getResponse();
$response->clearBody()->setStatusCode(\Magento\Framework\App\Response\Http::STATUS_CODE_403);
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
}
I have found the solution for above problem as getControllerAction method returns NULL due to which further process was not working.I had to used code below and every thing worked fine.
protected function denyAccess($observer)
{
$response = $observer->getResponse();
$response->clearBody()->setStatusCode(\Magento\Framework\App\Response\Http::STATUS_CODE_403);
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
}

Dynamic callback url laravel

I tried to make my callback url dynamic because I'm configuring socialite in a multi auth system. I tried to use the socialiteproviders/manager as below:
$clientId = env($provider."_client_id");
$clientSecret = env($provider."_client_secret");
$redirectUrl = "the url i want";
$config = new \SocialiteProviders\Manager\Config($clientId,$clientSecret,$redirectUrl);
return Socialite::with($provider)->setConfig($config)->redirect();
but it says:
Call to undefined method Laravel\Socialite\Two\FacebookProvider::setConfig()
when trying to login with facebook.
Can someone please help me? Thank you.
I could reproduce and found a solution. The code you provided was outdated, and I found other instances of it here: https://laravel.io/forum/07-28-2016-dynamic-callback-url-laravel-socialite
By default, Socialite will get the provider config in services.php by passing the $providerName = facebook
So your code now becomes:
// The services.php config will return null, fix it by using: strtoupper()
$clientId = env(strtoupper($provider . "_client_id"));
$clientSecret = env(strtoupper($provider . "_client_secret"));
$redirectUrl = "/the-url-i-want";
// ->redirect() acts as a closure, without it, you'll get an error like:
// "Serialization of 'Closure' is not allowed"
$user = Socialite::with($provider)->redirect();
return redirect()->to($redirectUrl)->with(['user', $user]);
More info on redirecting with session data:
https://laravel.com/docs/6.x/redirects#redirecting-with-flashed-session-data

symfony2 crud & http cache

I'm using Symfony2 and I have a ReaderBundle that has an Rss entity.
I'm created CRUD for this entity.
php app/console generate:doctrine:crud --entity=RSSReaderBundle:Rss --format=annotation --with-write
All was well, before I connected Cache.
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppCache.php';
require_once __DIR__.'/../app/AppKernel.php';
Debug::enable();
$kernel = new AppKernel('dev' , true);
$kernel->loadClassCache();
$kernel = new AppCache($kernel); // THAT STRING IS MAIN PROBLEM
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
And then when i'm trying to delete some record, i take this error:
No route found for "POST /rss/delete/30": Method Not Allowed (Allow: DELETE)
405 Method Not Allowed
I created a form that clearly indicates the method:
private function createDeleteForm($id)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('rss_delete', array('id' => $id)))
->setMethod("DELETE")
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()
;
}
I have not found the problem. Help please
This problem occurred since symfony2.2, see https://github.com/symfony/symfony-standard/commit/1970b831f8843a5cf551e9d88404cb62f21b90f9
You need to modify the Symfony\Component\HttpFoundation\Request::$httpMethodParameterOverride boolean manually in your app.php file:
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
Request::enableHttpMethodParameterOverride();
There is no method="DELETE" in html forms ... at least not supported in almost all browsers - only in ajax requests.
Work around this by allowing DELETE and POST requests to the route.
we must remove the string with comment "THAT STRING IS MAIN PROBLEM". Cache is working all the same. And CRUD working right
I have the same problem that you had (with PUT and DELETE HTTP method) but I don't understand your solution.
Did you:
a) just get rid of // THAT STRING IS MAIN PROBLEM
or
b) get rid of $kernel = new AppCache($kernel); // THAT STRING IS MAIN PROBLEM
The solution b) is the same as not using cache so in my case, it's not helping as the page take a very long time to load.
#Nifr:
I thought there were method PUT and DELETE. I use them in my forms following the instructions on this link: http://symfony.com/fr/doc/current/cookbook/routing/method_parameters.html
So in fact, Symfony2 is able to tell whether a method is PUT, DELETE, POST or GET. But somehow, the cache can't...
Any help on that?
Edit:
I found a solution that doesn't involve changing anything in the app.php file.
Basically, the problem comes from the fact that the getMethod method of the request object of symfony2 doesn't know about PUT or DELETE method. The point is to change that in the AppCache.php file.
We just have to override the method invalidate of the AppCache.php file:
protected function invalidate(Request $request, $catch = false)
{
$request->setMethod($request->request->get('_method'));
return parent::invalidate($request, $catch);
}
Here, I just change the method of the request by the method posted from the form.

Zend Framework 2 Unit testing controllers, POST/GET data not sending. Undefined Index

I have been trying to test my controllers as per this tutorial -> Zend Framework 2.1 Unit testing
I have tried every possible variation of the code to send POST or GET data along with the dispatch but the only thing I get back from running the test is "Undefined Index" when I try to access that data from the $_POST array in the controller.
I am using PHPUnit 3.7.17, Everything else works perfectly except for POST and GET data, I have tried the following code:
public function testIndexActionCanBeAccessed() {
$this->getRequest()
->setMethod("POST")
->setPost(new \Zend\Stdlib\Parameters(array('argument' => 'value')));
$response = $this->dispatch('/app/api/index');
$this->assertResponseStatusCode(200);
}
AND
public function testIndexActionCanBeAccessed() {
$post_data = array("argument" => "value");
$response = $this->dispatch("/app/api/index", "POST", $post_data);
$this->assertResponseStatusCode(200);
}
I can't find any help on the web how to fix this issue. Can anyone help out? Any ideas?
$p = new Parameters();
$p->set('username','foo');
$p->set('password','bar');
$this->getRequest()->setMethod('POST');
$this->getRequest()->setPost($p);
$this->dispatch('/login');
This works for me. The Parameters() constructor doesn't seem to be what you're expecting it to be.
The docs say it takes an array, but I could only get it to work this way. The Stdlib\Parameters() constructor doesn't seem to do anything with the array passed in.
Get/Post data not sending, this issue is related to server, can you check the function use for fetching data from server.

Resources