PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 22, 2022

[FIXED] How to complete pending transactions in paypal payouts

 November 22, 2022     laravel, paypal, php     No comments   

Issue

I am trying to implement a single Payout functionality in Paypal. I have referred to the sample code given by Paypal's documentation here. Everything seems to be working in order but the response given by PayPal indicates this: "batch_status": "PENDING". Here is my payout function:

public function payoutWithPaypal()
{
    $request_amount = session()->get('request_amount');
    $transaction_id = session()->get('transaction_id');
    $receiver_email = session()->get('receiver_email');

    $payouts = new \PayPal\Api\Payout();
    $senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
    $senderBatchHeader->setSenderBatchId(uniqid())->setEmailSubject("You have a Payout!");
    $senderItem = new \PayPal\Api\PayoutItem();
    $senderItem->setRecipientType('Email')
                ->setNote('Thanks for your patronage!')
                ->setReceiver($receiver_email)
                ->setSenderItemId("001")
                ->setAmount(new \PayPal\Api\Currency('{
                            "value":"'.$request_amount.'",
                            "currency":"USD"
                        }'));

    $payouts->setSenderBatchHeader($senderBatchHeader)->addItem($senderItem);
    $request = clone $payouts;
    
    try {
        $output = $payouts->create(array('sync_mode' => 'false'), $this->_api_context);

    } catch (\Exception $ex) {
         dd($ex);
    }

    return $output;

}

The solutions provided here have not really solved my issue.


Solution

Payouts run in a batch. For a batch status to begin as 'PENDING' is normal. The status of each payout within the batch is what matters. You can query them as needed, and if they are individually pending some reason may be given.

The most common reason for a PayPal payment to be pending in sandbox or live is if there is no PayPal account with a confirmed email (in sandbox or live, respectively) at the address to which the payment was sent. Receivers have 30 days to create an account and/or confirm the email on their account to accept the payment, otherwise it will be automatically refunded after 30 days. Reminders are sent to that email during this period.



Answered By - Preston PHX
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing