简体   繁体   中英

Why paypal sandbox account amount does not updating?

My code is successfully processing payments to paypal and then return to success page, buy business account amount does not updating.

I am trying paypal sdk in laravel and below is my script which I am using it, but on front side it is successfully going to paypal page where I login using buyer account then pay and then paypal return to success page. But in seller account the amount does not showing and nor deducting from buyer account.

public function createpayment(){
        $apiContext = new \PayPal\Rest\ApiContext(
            new \PayPal\Auth\OAuthTokenCredential(
                'Ac.................asd',     // ClientID
                'Ac.................sdf'      // ClientSecret
            )
        );
        $payer = new Payer();
        $payer->setPaymentMethod("paypal");
        $item1 = new Item();
        $item1->setName('Ground Coffee 40 oz')
            ->setCurrency('USD')
            ->setQuantity(1)
            ->setSku("123123") // Similar to `item_number` in Classic API
            ->setPrice(7.5);
        $item2 = new Item();
        $item2->setName('Granola bars')
            ->setCurrency('USD')
            ->setQuantity(5)
            ->setSku("321321") // Similar to `item_number` in Classic API
            ->setPrice(2);

        $itemList = new ItemList();
        $itemList->setItems(array($item1, $item2));

        $details = new Details();
        $details->setShipping(1.2)
            ->setTax(1.3)
            ->setSubtotal(17.50);

        $amount = new Amount();
        $amount->setCurrency("USD")
            ->setTotal(20)
            ->setDetails($details);

        $transaction = new Transaction();
        $transaction->setAmount($amount)
            ->setItemList($itemList)
            ->setDescription("Payment description")
            ->setInvoiceNumber(uniqid());


        /* $baseUrl = getBaseUrl(); */
        $redirectUrls = new RedirectUrls();
        $redirectUrls->setReturnUrl(route('success'))
        ->setCancelUrl(route('cancel'));


        $payment = new Payment();
        $payment->setIntent("sale")
            ->setPayer($payer)
            ->setRedirectUrls($redirectUrls)
            ->setTransactions(array($transaction));
         /* $payment->create($apiContext);
        return  redirect($payment->getApprovalLink()); */

        try {
            $payment->create($apiContext);
        } catch (Exception $ex) {
            ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
            exit(1);

        }
        $approvalUrl = $payment->getApprovalLink();

        echo $payment, $approvalUrl;
    }

    public function success(){
        $apiContext = new \PayPal\Rest\ApiContext(
            new \PayPal\Auth\OAuthTokenCredential(
                'Ac.................asd',     // ClientID
                'Ac.................sdf'      // ClientSecret     // ClientSecret
            )
        );

        return request();
    }

I want this code to be transfer money from buyer to seller account and then return success page with response. Can someone kindly guide me about I would like to appreciate.

On the success page you need to execute the payment in order to actually finish the transaction.

https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payments/ExecutePayment.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM