使用curl执行paypal付款

时间:2017-05-30 17:27:02

标签: curl paypal coldfusion

我想使用curl执行pay-pal调用,因为我们使用的是旧的ColdFusion版本

我的代码上有这个,由于我们机器上的java版本而给出了对等身份验证错误

<cffunction name="doHttppost" access="public" returntype="string">
    <cfargument name="requestData" type="struct" required="yes" >
    <cfargument name="serverURL" type="string" required="yes" >
    <cfargument name="useProxy" type="boolean" required="yes" >
    <cfargument name="proxyName" type="string" required="no" >
    <cfargument name="proxyPort" type="string" required="no" >

    <cfif useProxy is "true">
        <CFHTTP URL="#serverURL#" METHOD="POST" proxyserver=#proxyName# proxyport="#proxyPort#">
          <cfloop collection=#requestData# item="key">
              <CFHTTPPARAM NAME="#key#" VALUE="#requestData[key]#" TYPE="FormField" ENCODED="YES">
          </cfloop>
        </CFHTTP>
    <cfelse>
        <CFHTTP URL="#serverURL#" METHOD="POST">
          <cfloop collection=#requestData# item="key">
              <CFHTTPPARAM NAME="#key#" VALUE="#requestData[key]#" TYPE="FormField" ENCODED="YES">
          </cfloop>
        </CFHTTP>
    </cfif>
    <cfdump var="#cfhttp#" abort>
    <cfreturn #cfhttp.FileContent#>
</cffunction>

我正在尝试使用它:

<cfscript>
function structToList(s) {
    var delim = "&";
    var i = 0;
    var newArray = structKeyArray(arguments.s);

    if (arrayLen(arguments) gt 1) delim = arguments[2];

    for(i=1;i lte structCount(arguments.s);i=i+1) newArray[i] = newArray[i] & "=" & arguments.s[newArray[i]];

    return arraytoList(newArray,delim);
}
</cfscript>

以下是使用CURL命令调用API

<CFSET requestData.USER = "#variables.pp_username#">
<CFSET requestData.PWD = "#variables.pp_password#">
<CFSET requestData.SIGNATURE = "#variables.pp_signature#">
<CFSET requestData.SUBJECT = "">
<CFSET requestData.VERSION = "#variables.pp_version#">
<CFSET requestData.METHOD = "CreateRecurringPaymentsProfile">
<cfset sURL = structToList(requestData)>
<cfset targ = 'https://api-3t.paypal.com/nvp/ -d "#sURL#"'>
<cfexecute name = "/bin/curl" arguments = "#targ#" timeout = "10" variable = "tdata" />
<cfdump var="#tdata#">

但似乎没有任何工作,它只是给我一个空白页面,我尝试了我能想到的一切,可能

URL:

<cfset sendURL = "https://api-3t.sandbox.paypal.com/nvp SUBJECT=&CANCELURL=https://www.website.com/membership/&L_BILLINGAGREEMENTDESCRIPTION0=Monthly Subscription&NOSHIPPING=1&AMT=4.95&L_PAYMENTREQUEST_0_NAME0=Central Subscription&PWD=1306278099&VERSION=72.0&PAYMENTREQUEST_0_ITEMAMT=4.95&SIGNATURE=ADJN1tvFsnuWAZo61FL-QGJSk-epGHRrOb6EVH8C&PAYMENTREQUEST_0_DESC=Monthly Subscription&L_PAYMENTREQUEST_0_QTY0=1&PAYMENTREQUEST_0_AMT=4.95&L_PAYMENTREQUEST_0_ITEMAMT=4.95&L_PAYMENTREQUEST_0_NUMBER0=Month495&PAYMENTREQUEST_0_CURRENCYCODE=USD&L_PAYMENTREQUEST_0_CUSTOM=8B523DA2-DB69-EDDC-F1524640267728B5&PAYMENTREQUEST_0_PAYMENTACTION=sale&RETURNURL=https://www.website.com/membership/thanks.cfm&L_PAYMENTREQUEST_0_AMT0=4.95&USER=1306278086_biz_api1.ignitegt.com&L_PAYMENTREQUEST_0_DESC0=Monthly Subscription&PAYMENTREQUEST_0_CUSTOM=8B523DA2-DB69-EDDC-F1524640267728B5&METHOD=expressCheckout&L_BILLINGTYPE0=RecurringPayments">
我得到的错误是:

ACK=Failure&L_ERRORCODE0=81002&L_SHORTMESSAGE0=Unspecified%20Method&L_LONGMESSAGE0=Method%20Specified%20is%20not%20Supported&L_SEVERITYCODE0=Error

0 个答案:

没有答案