为啥在响应成功的同时没有通过 Paypal MassApi 转账
Posted
技术标签:
【中文标题】为啥在响应成功的同时没有通过 Paypal MassApi 转账【英文标题】:Why money not transferred through Paypal MassApi while getting success in response为什么在响应成功的同时没有通过 Paypal MassApi 转账 【发布时间】:2014-10-16 00:43:39 【问题描述】:嗨,我正在将 MassPay Api 集成到我的项目中,我想通过我在 codeigniter 上集成的 masspay api 发送批量付款。我为此创建了两个函数并获取关联 ID 和成功消息,但是当我看到我的沙盒 paypal 账户资金没有转移并且我的沙盒账户中没有交易时。
这是我的代码,请指导我如何设置
公共函数 PPHttpPost($methodName_, $nvpStr_)
$environment = 'sandbox';
// Set up your API credentials, PayPal end point, and API version.
$API_UserName = urlencode('sufyan_api1.xcluesiv.com');
$API_Password = urlencode('FQP8TTSXK8QHRCTM');
$API_Signature = urlencode('Ap7D643r8OUdvdzrOomgF0ATl.qSAygx3ERPaDvqm0umQ6aZwiX3t3r5');
$API_Endpoint = "https://api-3t.paypal.com/nvp";
if("sandbox" === $environment || "beta-sandbox" === $environment)
$API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
$version = urlencode('51.0');
// Set the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Turn off the server and peer verification (TrustManager Concept).
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);
// Set the API operation, version, and API signature in the request.
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
// Get response from the server.
$httpResponse = curl_exec($ch);
if(!$httpResponse)
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
// Extract the response details.
$httpResponseAr = explode("&", $httpResponse);
$httpParsedResponseAr = array();
foreach ($httpResponseAr as $i => $value)
$tmpAr = explode("=", $value);
if(sizeof($tmpAr) > 1)
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr))
exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
return $httpParsedResponseAr;
公共函数 paymultiple()
// Set request-specific fields.
$emailSubject =urlencode('This is created by sufyan');
$receiverType = urlencode('EmailAddress');
$currency = urlencode('USD'); // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')
// Add request-specific fields to the request string.
$nvpStr="&EMAILSUBJECT=$emailSubject&RECEIVERTYPE=$receiverType&CURRENCYCODE=$currency";
$receiversArray = array();
for($i = 0; $i < 3; $i++)
$receiverData = array( 'receiverEmail' => "engr.saadasif@gmail.com",
'amount' => "26.00",
'uniqueID' => "12",
'note' => "this is gift for you");
$receiversArray[$i] = $receiverData;
foreach($receiversArray as $i => $receiverData)
$receiverEmail = urlencode($receiverData['receiverEmail']);
$amount = urlencode($receiverData['amount']);
$uniqueID = urlencode($receiverData['uniqueID']);
$note = urlencode($receiverData['note']);
$nvpStr .= "&L_EMAIL$i=$receiverEmail&L_Amt$i=$amount&L_UNIQUEID$i=$uniqueID&L_NOTE$i=$note";
// Execute the API operation; see the PPHttpPost function above.
$httpParsedResponseAr = $this->PPHttpPost('MassPay', $nvpStr);
if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"]))
echo $email = $httpParsedResponseAr["receiver_email"];
echo $amount = $httpParsedResponseAr["mc_currency_x"];
exit('MassPay Completed Successfully: '.print_r($httpParsedResponseAr, true));
else
exit('MassPay failed: ' . print_r($httpParsedResponseAr, true));
我也启用了 ipn,我在 ipn 中给出了这个 URL 这是我的 ipn 网址:http://xxxx.com/paypal/PPHttpPost
请帮助我如何通过masspay api进行汇款
【问题讨论】:
您能否提供您从 PayPal 收到的完整回复,其中还包括相关 ID? 有解决办法吗? 【参考方案1】:我用过https://github.com/paypal/merchant-sdk-php
//Paypal Mass Pay integration
$massPayRequest = new MassPayRequestType();
$massPayRequest->MassPayItem = array();
$masspayItem = new MassPayRequestItemType();
$masspayItem->Amount = new BasicAmountType(PAYPAL_CURRENCY, $input['amount']);
$masspayItem->ReceiverEmail = $input['email'];
$massPayRequest->MassPayItem[] = $masspayItem;
$massPayReq = new MassPayReq();
$massPayReq->MassPayRequest = $massPayRequest;
$paypalService = new PayPalAPIInterfaceServiceService();
$massPayResponse = $paypalService->MassPay($massPayReq); // Call paypal mass pay
它对我有用,它需要用户金额、货币和您需要向其转账金额的电子邮件。
如果您使用 abc@gmail.com 创建了沙盒帐户,那么 paypal 使用新电子邮件创建帐户,例如 abc-facilatator@gmail.com 您需要使用新的电子邮件 ID 进行检查。在沙箱的情况下,Paypal 会将金额转移到该电子邮件 ID
如果接收者的 paypal 帐户无法使用指定的电子邮件,则直播。然后还将贝宝转账金额发送到该电子邮件。 要访问该金额,用户需要使用该电子邮件 ID 创建帐户。
【讨论】:
以上是关于为啥在响应成功的同时没有通过 Paypal MassApi 转账的主要内容,如果未能解决你的问题,请参考以下文章