Michael
Michael

Reputation: 1813

Method not found - Using the GoCardless Java library with ColdFusion

I am trying to implement GoCardless subscriptions in ColdFusion using their Java library (as per the documentation here https://gocardless.com/docs/java/merchant_client_guide#installation-and-setup). I am quite new to using Java with ColdFusion and I am getting the following error:

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.

The code which is producing the error is as follows:

<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)>

My first thought was that the subscription object was not of the correct type for the newSubscriptionUrl method but I don't think this is the case because when I dump GoCardless.connect it shows the following:

Dump of GoCardless.connect

This shows that the first argument passed to the newSubscriptionUrl method should be of the class gocardless.connect.Subscription.

When I dump the subscription object it shows that this is indeed the case:

Dump of GoCardless.connect

Like I say I am new to using Java with ColdFusion so I don't really know what might be causing this issue and whether the code I have so far written is even correct. Any help would be greatly appreciated.

Thanks, Michael.

Upvotes: 2

Views: 426

Answers (1)

Adam Cameron
Adam Cameron

Reputation: 29870

The method's signature is this:

newSubscriptionUrl(Subscription, String, String, String)

However you are calling it as:

newSubscriptionUrl(Subscription)

Hence the error message. You need to make sure to call the method as it's intended.

Upvotes: 1

Related Questions