用于PHP多付款捕获的REST API SDK

I have tool using the REST API SDK for PHP that captures payments for multiple companies in PayPal. If I Post one or more transactions to capture from different companies. The transactions are marked 'Captured' within PayPal everything is great. The issue is trying to capture multiple transactions from the same company within the same Post. What happens is only the first transaction in the array gets marked as 'Captured' in PayPal but any other transaction in that same array does not. Seemingly they get ignored.

The PayPal logs with the application do not show any errors. Here is the method that grabs the POST transaction Ids:

if(isset($_POST['toCapture']) && ! empty($_POST['toCapture'])){

// Array of transaction ids to capture
$idsToCapture = $_POST['toCapture'];


for($i = 0; $i < $arrayCount; $i++) {


    // Transaction id for current iteration in the loop
    $theId = $idsToCapture[$i]; //transactionId

    // Function call to get information for transaction id being processed in current iteration of loop
    $infoToCapture = getInfoToCapture($theId);


    $theCompany = $infoToCapture['Company'];

    $theAmt = number_format($infoToCapture['DocumentAmount'], 2); // DocAmt formatted to two decimal places

    $ohId = $infoToCapture['OrderHeaderId'];


    try {

            // Setting $theId to $authId
            $authId =  $theId;

            // Maing sure the ids to be processed do not have an acknoledgement from PayPal
            $checkAckNull = isAckNull($authId);


            // Setting the amount we want to capture
            $amt = new Amount();
            $amt->setCurrency("USD")
                ->setTotal($theAmt);

            // If there is no acknowledgment from PayPal, process the capture
            if($checkAckNull == NULL){
                ### Capture
                $capture = new Capture();
                $capture->setId($authId)
                    ->setAmount($amt);

                // it is the $apiContexts that are different for each company
                switch ($theCompany) {

                    case "BLL":
                        allTheImportantStuff( $apiContextBLL, $authId, $ohId, $capture, $theCompany );
                        break;
                    case "LOT":
                        allTheImportantStuff( $apiContextLOT, $authId, $ohId, $capture, $theCompany );
                        break;
                    case "SNA":
                        allTheImportantStuff( $apiContextSNA, $authId, $ohId, $capture, $theCompany );
                        break;
                    case "FAB":
                        allTheImportantStuff( $apiContextFAB, $authId, $ohId, $capture, $theCompany );
                        break;
                    case "STS":
                        allTheImportantStuff( $apiContextSTS, $authId, $ohId, $capture, $theCompany );
                        break;
                    case "MIA":
                        allTheImportantStuff( $apiContextMIA, $authId, $ohId, $capture, $theCompany );
                        break;
                }

            } // end if
            else {

            }

    } catch (PayPal\Exception\PayPalConnectionException $ex) {
        echo "Exception: " . $ex->getMessage() . PHP_EOL;
        echo '<pre>'; var_dump( $ex->getData() ); echo '</pre>';
        $fail = "failure";
        insertFail($theCompany, $ohId, $theId, $fail);

    } // end try/catch

} // end for loop

}

Here is the allTheImportantStuff method:

function allTheImportantStuff( $apiContext, $authId, $ohId, $capture, $theCompany ){

global $mode;


// Lookup the authorization.
$authorization = Authorization::get($authId, $apiContext);


// Perform a capture
$getCapture = $authorization->capture($capture, $apiContext);


// Get acknowledgment from capture
$ack = $getCapture->getId();


// Get state from capture
$state = $getCapture->getState();


return insertAck($theCompany, $ohId, $ack, $authId, $state);

}

Up until (roughly) a few weeks ago this code worked. I am not using the latest version of the REST API SDK for PHP but trying to avoid updating because other tools are using the SDK as well and work fine. I hope I have explained the issue thoroughly enough. Any thoughts or ideas on what may be going on or how to fix would be greatly appreciated.