我的 api 调用出现 500 错误:
Catchable Fatal Error: Argument 2 passed to Payum\Paypal\ExpressCheckout\Nvp\Api::__construct() must implement interface Payum\Core\HttpClientInterface, none given, called in /var/www/myapp/src/App/UserBundle/Controller/SubscriptionController.php on line 65 and defined
我认为构造函数https://github.com/Payum/PaypalExpressCheckoutNvp/blob/master/Api.php存在问题。没有关于 2 参数的默认值……这有什么问题吗?
这是我的作曲家:
"payum/paypal-express-checkout-nvp": "^1.3",
"payum/payum-bundle": "^2.0",
"php-http/guzzle6-adapter": "^1"
这是我的控制器:
protected function getPaypalOptions()
{
return array(
'username' => $this->container->getParameter('paypal.express_checkout.username'),
'password' => $this->container->getParameter('paypal.express_checkout.password'),
'signature' => $this->container->getParameter('paypal.express_checkout.signature'),
'return_url' => null,
'cancel_url' => null,
'sandbox' => $this->container->getParameter('paypal.sandbox'),
'useraction' => $useraction,
'cmd' => Api::CMD_EXPRESS_CHECKOUT,
);
}
public function indexAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('AppUserBundle:Subscription')->findBy(
array('companies' => $this->get('security.context')->getToken()->getUser()->getCompanies()),
array('id' => 'DESC')
);
for ($i=0;$i<count($entity);$i++)
{
if ($entity[$i]->getProfileId()!='') {
$details['PROFILEID'] = $entity[$i]->getProfileId();
$api = new Api($this->getPaypalOptions());
$arrStatus = $api->getRecurringPaymentsProfileDetails($details);
$entity[$i]->paypalstatus = $arrStatus['STATUS'];
}
}
return $this->render('AppUserBundle:Subscription:index.html.twig', array(
'entities' => $entity
));
}