如何把钱从PayPal帐户通过API转移到另一个支付宝账户 [英] How to transfer money from PayPal account to another PayPal account via API

查看:876
本文介绍了如何把钱从PayPal帐户通过API转移到另一个支付宝账户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经花了很长时间寻找一种方式将资金从业务贝宝通过API转移到多用户的PayPal帐户。即我有收件人的PayPal电子邮件地址,我想通过API从我们的帐户传递x资金他们。

I have spent a long time looking for a way to transfer money from a business paypal via an API to several users' paypal accounts. I.e. I have the recipient's paypal email address and I would like to transfer X funds from our account to theirs via API.

贝宝支付自适应沿着正确的路线似乎是,但我看不到正确的命令来得到它的工作(并避免验证步骤的用户,即整个过程不能被自动)

PayPal adaptive payments seems along the right lines, but I can't see the right commands to get it to work (and avoid the user having to verify a step, i.e. the whole process cant be automated)

有<一个href=\"http://stackoverflow.com/questions/16313193/paypal-transfer-money-using-api-credentials\">lots <一href=\"http://stackoverflow.com/questions/6117985/paypal-transfer-money-from-one-account-to-another\">of <一href=\"http://stackoverflow.com/questions/12227436/paying-from-any-account-to-any-other-via-paypal-api\">other <一href=\"http://stackoverflow.com/questions/19058532/is-it-possible-to-send-money-from-my-own-paypal-account-to-an-email-address-usin\">similar在做题,但都没有满意答卷,尤其是因为MassPay不能在美国贝宝的外部使用今天告诉我的电话。

There are lots of other similar questions on SO, but none have satisfactory responses, especially since MassPay cant be used outside of the US paypal told me on the phone today.

任何帮助或经验将非常AP preciated - !谢谢

Any help or experience would be hugely appreciated - thank you!

推荐答案

由于它是,它不是测试,但它来自一块code的工作良好,我只是不希望复制并粘贴;-)
这code使用自适应付款的PayPal API。

As it is, it isn't tested, but it comes from a piece of code that works well, I just didn't want to copy and paste that ;-) This code uses the Adaptive Payments PayPal API.

下面就来源链接

$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
}

这篇关于如何把钱从PayPal帐户通过API转移到另一个支付宝账户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆