【问题标题】:CFC not found with paypal sdk使用 paypal sdk 找不到 CFC
【发布时间】:2014-01-04 15:20:12
【问题描述】:

我正在使用 colfusion paypal SDK 进行直接付款,链接在这里: https://github.com/paypal/nvp-coldfusion-sdk

我在下面粘贴了 application.cfc 文件。我的问题是,每次我转到示例 --> dodirectpayment.cfm 并提交测试表单时,它都会显示“错误:找不到 ColdFusion 组件或接口 CallerService”。我认为这与引用 callerservice.cfc 文件有关,但无法弄清楚出了什么问题。任何帮助深表感谢。 application.cfc 在这里。

<cfscript>
/**
@dateCreated "July 18, 2011"
@hint "You implement methods in Application.cfc to handle ColdFusion application events and set variables in the CFC to configure application characteristics."
*/


component output="false" {

    /* **************************** APPLICATION VARIABLES **************************** */
    THIS.name = "NVPSample";
    THIS.applicationTimeout = createTimeSpan(0, 2, 0, 0);


    customtagpaths = "{#getDirectoryFromPath(ExpandPath('../lib/'))#,#getDirectoryFromPath(ExpandPath('../lib/services/'))#}";

    THIS.customTagPaths = customtagpaths; 

    THIS.serverSideFormValidation = true;
    THIS.sessionManagement = true;
    THIS.sessionTimeout = createTimeSpan(0, 0, 30, 0);

    THIS.setClientCookies = true;
    THIS.setDomainCookies = false;

    THIS.scriptProtect = true;
    THIS.secureJSON = false;
    THIS.secureJSONPrefix = "";


    THIS.enablerobustexception = true;


/* **************************** APPLICATION METHODS **************************** */

    public void function onApplicationEnd(struct ApplicationScope=structNew()) {

        return;
    }


    public boolean function onApplicationStart() {

        return true;
    }

    public void function onCFCRequest(required string cfcname, required string method, required string args) {

        return;
    }


    public void function onRequestEnd() {

        return;
    }


    public boolean function onRequestStart(required string TargetPage) {

        request.serverURL = "https://api-3t.sandbox.paypal.com/nvp";

        /* SUBJECT to be uncommented for UNIPAY all the other credentials like API username,
              password,signature can be commented for UNIPAY
              To enable Payments for Third Party Email whcih will be passed along with Partner's 3token credentials
              uncomment both subject and 3 token credentials.
       */


        request.SUBJECT="sales-facilitator@totalsportsadvantage.com"; 

        APIuserName = "sales-facilitator_api1.totalsportsadvantage.com";
        APIPassword = "1387466817";
        APISignature = "An5ns1Kso7MWUdW4ErQKJJJ4qi4-AMJWATXVSChE1ExjnH8FyoZD8U5Q";

        /*
         request.SUBJECT="clip_1309031681_biz@paypal.com"; 

        APIuserName = "clip_1309031681_biz_api1.paypal.com";
        APIPassword = "1309031732";
        APISignature = "AFcWxV21C7fd0v3bYYYRCpSSRl31An2lFbilAjH412uQjiC0OEJh45pL";
        */

        //condition to check if it is UNIPAY 
        if (isdefined("SUBJECT") && (isdefined("APIuserName") eq "false" && isdefined("APIPassword") eq "false" && isdefined("APISignature") eq "false") )
        {
            request.UNIPAYSUBJECT="#SUBJECT#"; 
            request.USER = "";
            request.PWD = "";
            request.SIGNATURE = "";
        }



        //condition to check if it is Payments for Third Party Email
        if (isdefined("SUBJECT") && isdefined("APIuserName") && isdefined("APIPassword") && isdefined("APISignature"))
        {
            request.UNIPAYSUBJECT="#SUBJECT#"; 
            request.USER = "#APIuserName#";
            request.PWD = "#APIPassword#";
            request.SIGNATURE = "#APISignature#";
        }


        //condition to check if it is 3 token credentials 
        if (isdefined("SUBJECT") eq "false" && isdefined("APIuserName") && isdefined("APIPassword") && isdefined("APISignature") )
        {
            request.UNIPAYSUBJECT=""; 
            request.USER = "#APIuserName#";
            request.PWD = "#APIPassword#";
            request.SIGNATURE = "#APISignature#";
        }


        request.PayPalURL = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
        request.version = "65.1";

        /*
        By default the API requests doesn't go through proxy. To route the requests through a proxy server
            set "useProxy" value as "true" and set values for proxyName and proxyPort. Set proxyName with
        the Host Name or the IP address of the proxy server. proxyPort should be a valid port number.
        eg: 
        useProxy = "true";
        proxyName = "127.0.0.1";
        proxyPort = "8081";
        */

        request.useProxy = "false";
        request.proxyName = "";
        request.proxyPort = "";

        return true;
    }


    public void function onSessionEnd(required struct SessionScope, struct ApplicationScope=structNew()) {

        return;
    }


    public void function onSessionStart() {

        return;
    }

}
</cfscript>

【问题讨论】:

  • 当我在您的代码示例中搜索 callerservice.cfc 时,我也找不到。
  • 它是我链接的SDK的/lib/services文件夹中的自定义标签。
  • 您通过什么方式或故障排除了什么?
  • getDirectoryFromPath(ExpandPath('../lib/services/')) 是否从您正在浏览的文件的角度解析到这些文件的实际位置?
  • getDirectoryFromPath 确实引用了这些文件的实际位置,但由于某种原因,应用程序没有在该位置找到它们。最终的解决方案是将文件复制到与 application.cfc 文件相同的文件夹中,并且一切都按预期工作。感谢您的帮助。

标签: paypal coldfusion application.cfc


【解决方案1】:

getDirectoryFromPath 确实引用了这些文件的实际位置,但由于某种原因,应用程序没有在该位置找到它们。最终的解决方案是将文件复制到与 application.cfc 文件相同的文件夹中,并且一切都按预期工作。谢谢您的帮助。

【讨论】:

  • 你让它工作很好,但我不认为这是一个很大的“解决方案”。你应该弄清楚为什么“但出于某种原因[等]”。原因是“你的应用程序在某个地方出现了问题”,你真的应该发现并修复它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-16
  • 2019-06-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-16
相关资源
最近更新 更多