Где найти идентификатор соглашения о выставлении счета, затем использовать его в кассе

Приветствую всех, я смущен, где найти идентификатор соглашения о выставлении счетов (BAID) после того, как пользователь одобрит план выставления счетов.

ИСПОЛЬЗОВАНИЕ REST-API

до сих пор paypal возвращает это после выполнения соглашения.

Agreement {#346 ▼ -_propMap: array:9 [▼ "id" => "I-N61SE6562BGN" "state" => "Active" "description" => "This is a subscription fee for using Talent Scout. It will be use to maintain the site and make users secure." "payer" => Payer {#349 ▶} "plan" => Plan {#350 ▶} "links" => array:5 [▶] "start_date" => "2019-06-17T07:00:00Z" "shipping_address" => Address {#364 ▶} "agreement_details" => AgreementDetails {#365 ▶} ] } 

Я смущен, если идентификатор в вышеуказанном коде является BAID или нет. Если это BAID, который я ищу, я бы хотел вставить его в выписку, чтобы пользователю не приходилось снова входить в систему для будущих выписок.

Код, когда пользователь выбирает и проверяет

 $payer = new Payer(); $payer->setPaymentMethod('paypal'); $total = 0; Session::set('duration', $request['duration']); if($request['duration'] == '1'){ $item_1 = new Item(); $item_1->setName('1 week duration') // item name ->setCurrency('PHP') ->setQuantity(1) ->setPrice($request['hiddenprice'][0]); // unit price $total = $request['hiddenprice'][0]; } elseif($request['duration'] == '2'){ $item_1 = new Item(); $item_1->setName('2 weeks duration') // item name ->setCurrency('PHP') ->setQuantity(1) ->setPrice($request['hiddenprice'][1]); // unit price $total = $request['hiddenprice'][1]; } elseif ($request['duration'] == '3') { $item_1 = new Item(); $item_1->setName('3 weeks duration') // item name ->setCurrency('PHP') ->setQuantity(1) ->setPrice($request['hiddenprice'][2]); // unit price $total = $request['hiddenprice'][2]; } // add item to list $item_list = new ItemList(); $item_list->setItems(array($item_1)); $amount = new Amount(); $amount->setCurrency('PHP') ->setTotal($total); $transaction = new Transaction(); $transaction->setAmount($amount) ->setItemList($item_list) ->setDescription('Your transaction description'); $redirect_urls = new RedirectUrls(); $redirect_urls->setReturnUrl(\URL::route('payment.status')) ->setCancelUrl(\URL::route('payment.status')); $payment = new Payment(); $payment->setIntent('Sale') ->setPayer($payer) ->setRedirectUrls($redirect_urls) ->setTransactions(array($transaction)); try { $payment->create($this->_api_context); } catch (\PayPal\Exception\PPConnectionException $ex) { if (\Config::get('app.debug')) { echo "Exception: " . $ex->getMessage() . PHP_EOL; $err_data = json_decode($ex->getData(), true); exit; } else { die('Some error occur, sorry for inconvenient'); } } foreach($payment->getLinks() as $link) { if($link->getRel() == 'approval_url') { $redirect_url = $link->getHref(); break; } } // add payment ID to session Session::put('paypal_payment_id', $payment->getId()); if(isset($redirect_url)) { // redirect to paypal return Redirect::away($redirect_url); } Session::flash('failed', 'Something went wrong!'); return Redirect::to('/home') ->with('error', 'Unknown error occurred'); } выплачивается $payer = new Payer(); $payer->setPaymentMethod('paypal'); $total = 0; Session::set('duration', $request['duration']); if($request['duration'] == '1'){ $item_1 = new Item(); $item_1->setName('1 week duration') // item name ->setCurrency('PHP') ->setQuantity(1) ->setPrice($request['hiddenprice'][0]); // unit price $total = $request['hiddenprice'][0]; } elseif($request['duration'] == '2'){ $item_1 = new Item(); $item_1->setName('2 weeks duration') // item name ->setCurrency('PHP') ->setQuantity(1) ->setPrice($request['hiddenprice'][1]); // unit price $total = $request['hiddenprice'][1]; } elseif ($request['duration'] == '3') { $item_1 = new Item(); $item_1->setName('3 weeks duration') // item name ->setCurrency('PHP') ->setQuantity(1) ->setPrice($request['hiddenprice'][2]); // unit price $total = $request['hiddenprice'][2]; } // add item to list $item_list = new ItemList(); $item_list->setItems(array($item_1)); $amount = new Amount(); $amount->setCurrency('PHP') ->setTotal($total); $transaction = new Transaction(); $transaction->setAmount($amount) ->setItemList($item_list) ->setDescription('Your transaction description'); $redirect_urls = new RedirectUrls(); $redirect_urls->setReturnUrl(\URL::route('payment.status')) ->setCancelUrl(\URL::route('payment.status')); $payment = new Payment(); $payment->setIntent('Sale') ->setPayer($payer) ->setRedirectUrls($redirect_urls) ->setTransactions(array($transaction)); try { $payment->create($this->_api_context); } catch (\PayPal\Exception\PPConnectionException $ex) { if (\Config::get('app.debug')) { echo "Exception: " . $ex->getMessage() . PHP_EOL; $err_data = json_decode($ex->getData(), true); exit; } else { die('Some error occur, sorry for inconvenient'); } } foreach($payment->getLinks() as $link) { if($link->getRel() == 'approval_url') { $redirect_url = $link->getHref(); break; } } // add payment ID to session Session::put('paypal_payment_id', $payment->getId()); if(isset($redirect_url)) { // redirect to paypal return Redirect::away($redirect_url); } Session::flash('failed', 'Something went wrong!'); return Redirect::to('/home') ->with('error', 'Unknown error occurred'); } 

Код, когда платеж является успешным

 // Get the payment ID before session clear $payment_id = Session::get('paypal_payment_id'); // clear the session payment ID Session::forget('paypal_payment_id'); if (empty(Input::get('PayerID')) || empty(Input::get('token'))) { Session::flash('failed', 'Something went wrong!'); return Redirect::to('/paymentprocess') ->with('error', 'Payment failed'); } $payment = Payment::get($payment_id, $this->_api_context); // PaymentExecution object includes information necessary // to execute a PayPal account payment. // The payer_id is added to the request query parameters // when the user is redirected from paypal back to your site $execution = new PaymentExecution(); $execution->setPayerId(Input::get('PayerID')); //Execute the payment $result = $payment->execute($execution, $this->_api_context); // echo '<pre>';print_r($result);echo '</pre>';exit; // DEBUG RESULT, remove it later // dd($result->id); if ($result->getState() == 'approved') { // payment made $data = new Paypalpayment; $user = User::find(Session::get('id')); $data->id = null; $data->payment_id = $result->id; $data->user_id = Session::get('id'); $data->firstname = $user['firstname']; $data->lastname = $user['lastname']; $data->state = 'pending'; $data->duration = Session::get('duration'); $data->save(); Session::forget('duration'); Session::flash('success', 'Payment Successful!'); return Redirect::to('/paymentprocess') ->with('success', 'Payment success'); } Session::flash('failed', 'Payment failed!!'); return Redirect::to('/paymentprocess') ->with('error', 'Payment failed');