Sandbox mode Paypal authentication error: Laravel 5.5

Link

code

public function ShowPaymentWithPaypal()
{
    $payer = new Payer();
    $payer->setPaymentMethod('paypal');
    $item_1 = new Item();
    $item_1->setName('Item 1') /** item name **/
        ->setCurrency('USD')
        ->setQuantity(1)
        ->setPrice(2); /** unit price **/

    $item_list = new ItemList();
    $item_list->setItems(array($item_1));
    $amount = new Amount();
    $amount->setCurrency('USD')
        ->setTotal(2);

    $transaction = new Transaction();
    $transaction->setAmount($amount)
        ->setItemList($item_list)
        ->setDescription('Your transaction description');

    $redirect_urls = new RedirectUrls();
    $redirect_urls->setReturnUrl(\URL::route('ReturnedFromPaypal')) /** Specify return URL **/
        ->setCancelUrl(\URL::route('CancelledPaymentWithPaypal'));

    $payment = new Payment();
    $payment->setIntent('Sale')
        ->setPayer($payer)
        ->setRedirectUrls($redirect_urls)
        ->setTransactions(array($transaction));
        /** dd($payment->create($this->_api_context));exit; **/

    try {
        $payment->create($this->_api_context);
    } catch (\PayPal\Exception\PPConnectionException $ex) {
        dd($ex);
        if (\Config::get('app.debug')) {
            \Session::put('error','Connection timeout');
            return "Error occured";
            /** echo "Exception: " . $ex->getMessage() . PHP_EOL; **/
            /** $err_data = json_decode($ex->getData(), true); **/
            /** exit; **/
        } else {
            \Session::put('error','Some error occur, sorry for inconvenient');
            return "Error occured";
            /** 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::put('error','Unknown error occurred');
    return "Last line error";
}

What is the problem?

When I try to login to make a payment using credentials in the form of a sandbox, I get the following error.

We cannot process your payment using your PayPal account. this time. Return to the seller and try a different payment method.

I am following this to set up Paypal in Laravel 5.5

XHR Error Details

enter image description here Did I miss something?

+4
source share
1 answer

Looks like a Paypal restriction.

, , , PayPal 100 000 .

, - , .

, ? , 0,01 ().

, , ? .

,

+2

Source: https://habr.com/ru/post/1622019/


All Articles