使用curl执行paypal支付

使用curl执行paypal支付,curl,paypal,coldfusion,Curl,Paypal,Coldfusion,我想使用curl执行pay-pal调用,因为我们使用的是使用Linux的旧ColdFusion版本 我的代码中有这一点,这给了我对等身份验证错误,因为我们的机器上有java版本 <cffunction name="doHttppost" access="public" returntype="string"> <cfargument name="requestData" type="struct" required="yes" > <cfargume

我想使用curl执行pay-pal调用,因为我们使用的是使用Linux的旧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>

curl命令是否通过命令提示符直接从服务器工作?ColdFusion日志中是否有错误?代码是到达您的
cfexecute
语句还是在此之前失败了?用
cftry
cfcatch
块包装您的
cfexecute
行以捕获任何错误。我尝试了一下,但如果每次运行它,我都找不到方法,这是URL“it”是什么?从基础开始。正如Miguel-F所提到的,首先尝试通过命令提示符运行curl命令(很可能API有一个工作curl示例)。在从命令提示符下运行之前,将CF添加到混合中是没有意义的。嗯,好的,让我试着在PayPal中查看并找到一个curl命令的示例。您的curl命令是否通过命令提示符直接从服务器上运行?ColdFusion日志中是否有错误?代码是到达您的
cfexecute
语句还是在此之前失败了?用
cftry
cfcatch
块包装您的
cfexecute
行以捕获任何错误。我尝试了一下,但如果每次运行它,我都找不到方法,这是URL“it”是什么?从基础开始。正如Miguel-F所提到的,首先尝试通过命令提示符运行curl命令(很可能API有一个工作curl示例)。在命令提示符下运行之前,将CF添加到组合中是没有意义的。嗯,好吧,让我试试看,并在paypal中找到一个curl命令的示例
<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>
<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#">
<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