如何通过 API 将资金从 PayPal 帐户转移到另一个 PayPal 帐户

2024-03-05

我花了很长时间寻找一种通过 API 将资金从企业 PayPal 转移到多个用户的 PayPal 帐户的方法。 IE。我有收件人的 PayPal 电子邮件地址,我想通过 API 将 X 笔资金从我们的帐户转移到他们的帐户。

PayPal 自适应支付似乎是正确的,但我看不到让它工作的正确命令(并避免用户必须验证步骤,即整个过程无法自动化)

lots https://stackoverflow.com/questions/16313193/paypal-transfer-money-using-api-credentials of https://stackoverflow.com/questions/6117985/paypal-transfer-money-from-one-account-to-another other https://stackoverflow.com/questions/12227436/paying-from-any-account-to-any-other-via-paypal-api similar https://stackoverflow.com/questions/19058532/is-it-possible-to-send-money-from-my-own-paypal-account-to-an-email-address-usin关于SO的问题,但没有一个得到满意的答复,特别是因为MassPay不能在美国以外的地方使用,贝宝今天在电话里告诉我。

任何帮助或经验将不胜感激 - 谢谢!


事实上,它没有经过测试,但它来自一段运行良好的代码,我只是不想复制和粘贴它;-) 此代码使用自适应支付 PayPal API。

这是一个链接source http://ideone.com/12qU9A

$payLoad=array();

//prepare the receivers
$receiverList=array();
$counter=0;
$receiverList["receiver"][$counter]["amount"]=$r["withdrawalAmount"];
$receiverList["receiver"][$counter]["email"]=$r["paypalEmail"];
$receiverList["receiver"][$counter]["paymentType"]="SERVICE";//this could be SERVICE or PERSONAL (which makes it free!)
$receiverList["receiver"][$counter]["invoiceId"]=$r["withdrawalID"];//NB that this MUST be unique otherwise paypal will reject it and get shitty. However it is a totally optional field

//prepare the call
$payLoad["actionType"]="PAY";
$payLoad["cancelUrl"]="http://www.example.com";//this is required even though it isnt used
$payLoad["returnUrl"]="http://www.example.com";//this is required even though it isnt used
$payLoad["currencyCode"]="EUR";
$payLoad["receiverList"]=$receiverList;
$payLoad["feesPayer"]="EACHRECEIVER";//this could be SENDER or EACHRECEIVER
//$payLoad["fundingConstraint"]=array("allowedFundingType"=>array("fundingTypeInfo"=>array("fundingType"=>"BALANCE")));//defaults to ECHECK but this takes ages and ages, so better to reject the payments if there isnt enough money in the account and then do a manual pull of bank funds through; more importantly, echecks have to be accepted/rejected by the user and i THINK balance doesnt
$payLoad["sender"]["email"]=$ppemail;//the paypal email address of the where the money is coming from

//run the call
$API_Endpoint = "https://svcs$ppapicall.paypal.com/AdaptivePayments/Pay";
$payLoad["requestEnvelope"]=array("errorLanguage"=>urlencode("en_US"),"detailLevel"=>urlencode("ReturnAll"));//add some debugging info the payLoad and setup the requestEnvelope
$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);

//analyse the output
$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) {//they will only be in this array if they had a paypal account
$receiverEmail = $paymentInfo["receiver"]["email"];
$receiverAmount = $paymentInfo["receiver"]["amount"];
$withdrawalID = $paymentInfo["receiver"]["invoiceId"];
$transactionId = $paymentInfo["transactionId"];//what shows in their paypal account
$senderTransactionId = $paymentInfo["senderTransactionId"];//what shows in our paypal account
$senderTransactionStatus = $paymentInfo["senderTransactionStatus"];
$pendingReason = isset($paymentInfo["pendingReason"]) ? $paymentInfo["pendingReason"] : null;
}

}else{
//deal with it
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何通过 API 将资金从 PayPal 帐户转移到另一个 PayPal 帐户 的相关文章