I have a PHP web page which uses the creates an invoice and allows the user to pay via PayPal. The script identifies the IPN listening page via https and that gets called once the user has completed their transaction. Inside the IPN script that is called, I am updating the invoice status to "paid" and other relevant information upon a successful payment. The good news is that all functions perfectly. However, when I add a single payment inside the routine, to a vendor that gets a percent of the sale, the script executes over and over and over and never stops. The part of the script that seems to be causing the trouble is
case "Completed":
$vBody = "PayPal has identifed this transaction as Completed. Your account will be credited.";
// BEGIN MassPay API Call
// Create PayPal object.
$PayPalConfig = array(
'Sandbox' => $sandbox,
'APIUsername' => $api_username,
'APIPassword' => $api_password,
'APISignature' => $api_signature,
'PrintHeaders' => $print_headers,
'LogResults' => $log_results,
'LogPath' => $log_path,
);
$PayPal = new angelleye\PayPal\PayPal($PayPalConfig);
// Prepare request arrays
$MPFields = array(
'emailsubject' => 'Notification of Payment', // The subject line of the email that PayPal sends when the transaction is completed. Same for all recipients. 255 char max.
'currencycode' => 'USD', // Three-letter currency code.
'receivertype' => 'EmailAddress' // Indicates how you identify the recipients of payments in this call to MassPay. Must be EmailAddress or UserID
);
// Build MPItems array.
$Item1 = array(
'l_email' => 'recipient@gmail.com', // Required. Email address of recipient. You must specify either L_EMAIL or L_RECEIVERID but you must not mix the two.
'l_receiverid' => '', // Required. ReceiverID of recipient. Must specify this or email address, but not both.
'l_amt' => '3.00', // Required. Payment amount.
'l_uniqueid' => $Post["invoice"], // Transaction-specific ID number for tracking in an accounting system.
'l_note' => 'Payment per PayPal transaction processing fee.' // Custom note for each recipient.
);
$MPItems = array($Item1);
//$MPItems = $Item1; // ($Item1, $Item2, etc
$PayPalRequestData = array('MPFields'=>$MPFields, 'MPItems' => $MPItems);
// Pass data into class for processing with PayPal and load the response array into $PayPalResult
$PayPalResult = $PayPal->MassPay($PayPalRequestData);
// END MassPay API Call
//Update database on succcessful payment
The script executes fine and the mass payment to the vendor in the Sandbox works, but it NEVER STOPS. If I complete a transaction using it, the senders PayPal account would be drained of all funds. I have read that there may be an issue with the Sandbox, but not sure if that is accurate and there is no way I can put this into production. Can anyone give me an idea of how to solve or identify the problem?
答案 0 :(得分:0)
尝试使用:
break;
或者:
exit();
使脚本在第一次执行后停止执行的原因