php - paypal live - getting response code 400 PERMISSION_DENIED with RestAPI -
edited: seems having trouble business account. know how set business account restapi?
i did restapi payment in symfony paypal rest-api sdk. works in sandbox fails in live.
- the paypal account actived
- account payment solution setted website payments standard
- api client , secret key changed live credentials
- api context mode changed live
here code:
$clientid = $this->container->getparameter('paypal_client_id'); $secret = $this->container->getparameter('paypal_secret'); $paypalmode = $this->container->getparameter('paypal_mode'); // live $oauthcredential = new oauthtokencredential($clientid, $secret); $apicontext = new apicontext($oauthcredential); $apicontext->setconfig( [ 'log.logenabled' => true, 'log.filename' => $logdir.'/paypal.log', 'log.loglevel' => 'fine', 'mode' => $paypalmode, ] ); $payer = new payer(); $payer->setpaymentmethod("paypal"); $item = new item(); $item->setname($subtl->getname()) ->setdescription($subtl->getdescription()) ->setcurrency('eur') ->setquantity('1') ->settax('0') ->setprice($subprice); $items[] = $item; $sumprice = 0; /** @var item $item */ foreach ($items $item) { $sumprice += (int)$item->getprice(); } $itemlist = new itemlist(); $itemlist->setitems([$item]); $details = new details(); $details->setshipping('0') ->settax('0') ->setsubtotal($subprice); $amount = new amount(); $amount->setcurrency("eur") ->settotal($sumprice) ->setdetails($details); $transaction = new transaction(); $transaction ->setamount($amount) ->setitemlist($itemlist) ->setdescription("payment description"); $urls = new redirecturls(); $urls ->setcancelurl($baseurl . $this->cancelurl) ->setreturnurl($baseurl . $this->successurl); $payment = new payment(); $payment->setintent("sale") ->setpayer($payer) ->settransactions([$transaction]) ->setredirecturls($urls); $payment->create($apicontext);
then got approval_url, redirecting user that. after pay returns me callback url.
$clientid = $this->container->getparameter('paypal_client_id'); $secret = $this->container->getparameter('paypal_secret'); $oauthcredential = new oauthtokencredential($clientid, $secret); $apicontext = new apicontext($oauthcredential); $logdir = $this->createlogdir(); $apicontext->setconfig( [ 'log.logenabled' => true, 'log.filename' => $logdir.'/paypal.log', 'log.loglevel' => 'fine', 'mode' => $paypalmode, ] ); $query = $request->query->all(); if (isset($query['success']) && $query['success'] == 'true') { $paymentid = $query['paymentid']; $payment = payment::get($paymentid, $apicontext); $execution = new paymentexecution(); $execution->setpayerid($query['payerid']); try { $payment->execute($execution, $apicontext); try { $payment = payment::get($paymentid, $apicontext); } catch (paypalconnectionexception $ex) { // fail 1 } } catch (paypalconnectionexception $ex) { // fail 2 } if ($payment->getstate() == 'approved') { // ok } }
im getting "fail 2", , log following:
paypal\core\paypalhttpconnection: error: got http response code 400 when accessing https://api.paypal.com/v1/payments/payment/pay-66t29544vn4574806kvybffa/execute. {"name":"permission_denied","message":"no permission requested operation","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#permission_denied","debug_id":"976cbb71b5e10"}
it wasn't code. paypal not support kind of love site business accounts wanted live.
Comments
Post a Comment