脚本宝典收集整理的这篇文章主要介绍了php – 如何使用API管理PayPal订阅?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
This page表示使用CreateRecurringPaymentsProfile的方法包含ID,尽管我不是使用API创建订阅,所以我将无法做到这一点.
有没有API方法只能获得ID?谢谢.
<?PHP /** DoDirectPayment NVP example; last modified 08MAY23. * * Process a credIT card payment. */ $environment = 'sandBox'; // or 'beta-sandBox' or 'live' /** * 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($methodName_,$nvpStr_) { global $environment; // Set up your API credentials,PayPal end point,and API version. $API_UserName = urlencode('debash_1332929919_biz_api1.gmail.COM'); $API_Password = urlencode('1332929952'); $API_Signature = urlencode('AIiPJKMw38NGZuaiDaeLWrH9x.WBAK4WXF1vh9.Y.YxEM-4DlbDLMEVe'); $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; } // Set request-specific fields. $paymentType = urlencode('Sale'); // or 'Sale' $FirstName = urlencode('Debashis'); $lastName = urlencode('Banerjee'); $creditCardType = urlencode('visa'); $creditCardNumber = urlencode('4860795409505688'); $expDateMonth = '3'; // Month must be padded with leading zero $padDateMonth = urlencode(str_pad($expDateMonth,2,'0',STR_PAD_LEFT)); $expDateYear = urlencode('2017'); $cvv2Number = urlencode('111'); $address1 = urlencode('Kaikala'); $address2 = urlencode('Hooghly'); $city = urlencode('Kaikala'); $state = urlencode('WB'); $zip = urlencode('712405'); $country = urlencode('IN'); // US or other valid country code $amount = urlencode('71'); $currencyID = urlencode('USD'); // or other currency ('GBP','EUR','JPY','CAD','AUD') // Add request-specific fields to the request string. $nvpStr = "&PAYMENTACTION=$paymentType&AMT=$amount&CREDITCARDTYPE=$creditCardType&ACCT=$creditCardNumber". "&EXPDATE=$padDateMonth$expDateYear&CVV2=$cvv2Number&FIRSTNAME=$firstName&LASTNAME=$lastName". "&STREET=$address1&CITY=$city&STATE=$state&ZIP=$zip&COUNTRYCODE=$country&CURRENCYCODE=$currencyID"; // Execute the API operation; see the PPHttpPost function above. $httpParsedResponseAr = PPHttpPost('DoDirectPayment',$nvpStr); if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) { exit('Direct Payment completed Successfully: '.print_r($httpParsedResponseAr,true)); } else { exit('DoDirectPayment Failed: ' . print_r($httpParsedResponseAr,true)); } ?>
请访问https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/library_code
谢谢
以上是脚本宝典为你收集整理的php – 如何使用API管理PayPal订阅?全部内容,希望文章能够帮你解决php – 如何使用API管理PayPal订阅?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。