作为现状,它没有经过测试,但它来自一段运行良好的代码,我只是不想复制粘贴那个;-)
这段代码使用了适应性支付PayPal API。
这里有一个链接
source。
$payLoad=array();
$receiverList=array();
$counter=0;
$receiverList["receiver"][$counter]["amount"]=$r["withdrawalAmount"];
$receiverList["receiver"][$counter]["email"]=$r["paypalEmail"];
$receiverList["receiver"][$counter]["paymentType"]="SERVICE";
$receiverList["receiver"][$counter]["invoiceId"]=$r["withdrawalID"];
$payLoad["actionType"]="PAY";
$payLoad["cancelUrl"]="http://www.example.com";
$payLoad["returnUrl"]="http://www.example.com";
$payLoad["currencyCode"]="EUR";
$payLoad["receiverList"]=$receiverList;
$payLoad["feesPayer"]="EACHRECEIVER";
$payLoad["sender"]["email"]=$ppemail;
$API_Endpoint = "https://svcs$ppapicall.paypal.com/AdaptivePayments/Pay";
$payLoad["requestEnvelope"]=array("errorLanguage"=>urlencode("en_US"),"detailLevel"=>urlencode("ReturnAll"));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-PAYPAL-REQUEST-DATA-FORMAT: JSON',
'X-PAYPAL-RESPONSE-DATA-FORMAT: JSON',
'X-PAYPAL-SECURITY-USERID: '. $ppuserid,
'X-PAYPAL-SECURITY-PASSWORD: '. $pppass,
'X-PAYPAL-SECURITY-SIGNATURE: '. $ppsig,
'X-PAYPAL-APPLICATION-ID: '. $ppappid
));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payLoad));
$response = curl_exec($ch);
$response = json_decode($response, 1);
$payKey = $response["payKey"];
$paymentExecStatus=$response["paymentExecStatus"];
$correlationId=$response["responseEnvelope"]["correlationId"];
$paymentInfoList = isset($response["paymentInfoList"]) ? $response["paymentInfoList"] : null;
if ($paymentExecStatus<>"ERROR") {
foreach($paymentInfoList["paymentInfo"] as $paymentInfo) {
$receiverEmail = $paymentInfo["receiver"]["email"];
$receiverAmount = $paymentInfo["receiver"]["amount"];
$withdrawalID = $paymentInfo["receiver"]["invoiceId"];
$transactionId = $paymentInfo["transactionId"];
$senderTransactionId = $paymentInfo["senderTransactionId"];
$senderTransactionStatus = $paymentInfo["senderTransactionStatus"];
$pendingReason = isset($paymentInfo["pendingReason"]) ? $paymentInfo["pendingReason"] : null;
}
}else{
}