我試圖在ColdFusion中使用它們的Java庫實現GoCardless訂閱(根據文檔https://gocardless.com/docs/java/merchant_client_guide#installation-and-setup)。我很新的使用Java與ColdFusion和我收到以下錯誤:找不到方法 - 在ColdFusion中使用GoCardless Java庫
The newSubscriptionUrl method was not found - Either there are no methods with the specified method name and argument types or the newSubscriptionUrl method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.
這是產生錯誤的代碼如下:
<cfset GoCardless = createobject("java","gocardless.GoCardless")>
<cfset GoCardless.environment = GoCardless.Environment.SANDBOX>
<cfset GoCardless.accountDetails.setAppId("My app ID")>
<cfset GoCardless.accountDetails.setAppSecret("My app secret")>
<cfset GoCardless.accountDetails.setAccessToken("My access token")>
<cfset GoCardless.accountDetails.setMerchantId("My merchant ID")>
<cfset monthlyAmount = 35>
<cfset subscription = createobject("java","gocardless.connect.Subscription").init(
GoCardless.accountDetails.getMerchantId(),
javacast("bigdecimal",monthlyAmount),
1,
"month"
)>
<cfset GoCardless.connect.newSubscriptionUrl(subscription)>
我首先想到的是,認購對象是不是正確類型newSubscriptionUrl方法,但我不認爲是這樣,因爲當我傾倒GoCardless.connect它顯示以下內容:
這表明傳遞給newSubscriptionUrl方法的第一個參數應該是類gocardless.connect.Subscription。
當我傾倒認購對象也表明,這確實是這樣的:
就像我說我是新來使用Java在ColdFusion,所以我真的不知道什麼可能導致這個問題以及我到目前爲止編寫的代碼是否正確。任何幫助將不勝感激。
謝謝,邁克爾。
上面轉儲中的newSubscriptionUrl()方法簽名顯示它需要四個參數,一個Connection和三個字符串(redirectUri,cancelUri,state)。由於CF代碼不提供它們,你會得到上面的錯誤。 – barnyr
儘管[documentation](https://gocardless.com/docs/java/merchant_client_guide#starting-the-billing-process)中的示例代碼僅顯示一個參數傳遞,我會試試這個:GoCardless.connect .newSubscriptionUrl(訂閱); – Michael
事實上,文檔將其描述爲「附加參數」。 – Michael