我找到了我的 Laravel 或 PHP 解决方案,自适应付款仍然有效,我使用了旧方法并设法创建了多个接收者的发票并在他的沙盒帐户中接收。
我将分享我的发现,以便其他人也可以受益,虽然我不能给自己任何功劳,但解决方案可以在 youtube optikalefx 的频道中找到,并通过 paypal api 支持我。
这里是解决方案,希望对其他程序员有所帮助
$createPacket = array(
"actionType" => "PAY", // Payment action type
"currencyCode" => "USD", // Payment currency code
"receiverList" => array(
"receiver" => array(
array(
"amount" => "25", // Payment amount
"email" => "nike@paypal.com", // Receiver's email address
),
array(
"amount" => "150", // Payment amount
"email" => "xiaomi@paypal.com", // Receiver's email address
),
),
),
"returnUrl" => url("/"), // Redirect URL after approval
"cancelUrl" => url("/"), // Redirect URL after cancellation
"requestEnvelope" => array(
"errorLanguage" => "en_US", // Language used to display errors
"detailLevel" => "ReturnAll", // Error detail level
),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($createPacket));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-PAYPAL-SECURITY-USERID:" . "YOUR_USER_ID",
"X-PAYPAL-SECURITY-PASSWORD:" . "YOUR_SECURITY_PASSWORD",
"X-PAYPAL-SECURITY-SIGNATURE:" . "YOUR_SIGNATURE",
"X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T", //USE THIS Global SANDBOX APP ID
"X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
]);
$response = json_decode(curl_exec($ch), true);
return redirect("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=".$response['payKey']));