我有信用用户的网站,当必须使用信用时,他可以将它们转换为真正的钱,
例如:我是用户,我有 500 个积分,1 个积分 == 1$ 用户按下“转换为美元”按钮,然后他插入贝宝电子邮件来汇款。
现在我需要从我的贝宝账户自动付款到他应该插入的贝宝电子邮件。
我正在尝试使用批量付款,但这并不接受所有用户,只接受特定用户。
* Send HTTP POST Request
* @param string The API method name
* @param string The POST Message fields in &name=value pair format
* @return array Parsed HTTP Response body
*/
function PPHttpPost($environment,$methodName_, $nvpStr_)
{
// Set up your API credentials, PayPal end point, and API version.
// How to obtain API credentials:
// https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_NVPAPIBasics#id084E30I30RO
$API_UserName = ('mail');
$API_Password = ('passapi');
$API_Signature = ('signture');
$API_Endpoint = "https://svcs.paypal.com/AdaptivePayments/Pay";
if("sandbox" == $environment || "beta-sandbox" === $environment)
{
$API_Endpoint = "https://svcs.$environment.paypal.com/AdaptivePayments/Pay";
}
$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_HTTPHEADER, array(
"X-PAYPAL-SECURITY-USERID: {$API_UserName}",
"X-PAYPAL-SECURITY-PASSWORD: {$API_Password}",
"X-PAYPAL-SECURITY-SIGNATURE: {$API_Signature}",
"X-PAYPAL-REQUEST-DATA-FORMAT: NV",
"X-PAYPAL-RESPONSE-DATA-FORMAT: NV"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
// Set the API operation, version, and API signature in the request.
$nvpreq = $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;
}
我该怎么做?
感谢您的帮助!