2
votes

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.

1
The newSubscriptionUrl() method signature in the dump above shows it needs four arguments, one Connection and three strings (redirectUri, cancelUri, state). As the CF code isn't providing them, you'll get the error above.barnyr
I'll give this a try although the example code in the documentation shows only one argument being passed: GoCardless.connect.newSubscriptionUrl(subscription);Michael
In fact the documentation describes them as 'additional parameters'.Michael

1 Answers

1
votes

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.