Invalid Construct error?

292 views
Skip to first unread message

Peter Knoch

unread,
Jan 3, 2017, 2:45:05 PM1/3/17
to cfpayment
Hey, just started using cfpayment in order to process payments through stripe, and on my development machine, it was working fantastically (my development machine is a windows laptop running Coldfusion 2016, and using the built in web-server, not IIS).
As soon as I moved the changes to the test server, it threw me an error.

Invalid construct: Either argument or name is missing.

When using named parameters to a function, each parameter must have a name.

The CFML compiler was processing:

  • An expression beginning with process, on line 282, column 27.This message is usually caused by a problem in the expressions structure.
  • A cfreturn tag beginning on line 282, column 18.
  • A cfreturn tag beginning on line 282, column 18.

The Test Server is running Coldfusion 9, and using IIS to create the web server.

<cfscript>
cfg = { path = "stripe.stripe", TestSecretKey = "notARealKey" };
svc = createObject("component", "cfpayment.api.core").init(cfg);
gw = svc.getGateway();
account = svc.createCreditCard().setAccount(attributes.card_number).setVerificationValue(attributes.card_code).setMonth(attributes.card_exp_month).setYear(attributes.card_exp_year).setFirstName(attributes.first_name).setLastName(attributes.last_name);
money = svc.createMoney(attributes.amount * 100);
response = gw.purchase(money = money, account = account);
ccResponseCall = response;
if (response.getSuccess()) {
//These just write out the output (in a really ugly fashion)
//WriteDump(var=DeserializeJSON(response.getResult()), abort=true);
  //writeoutput(response.getResult());
ccResponse = TRUE;
}
else {
sErrors = response.getMessage();
ccResponse = FALSE;
}
</cfscript>

This is the snippet of code that it's running to charge the card, any thoughts on why it isn't working currently?

Any insight on this issue?

Peter Knoch

unread,
Jan 4, 2017, 2:21:47 PM1/4/17
to cfpayment
Fixed the problem for myself, it looks like the issue was in stripe.cfc, specifically on lines 282, 364, 378, and 379. Apparently CF9 doesn't like the format of the JSON entries there and needed them to be surrounded with single quotes to be recognized as strings.

Brian G

unread,
Jan 4, 2017, 4:22:20 PM1/4/17
to cfpayment
Peter - thanks for checking into it and submitting the PR. Did you run the unit tests?  I ask because this:

options = '{"ConnectedAccount": arguments.ConnectedAccount, "customer": arguments.customer}'

is a string which is different from:

options = {"ConnectedAccount": arguments.ConnectedAccount, "customer": arguments.customer})

which is an object.  I don't think this will work because the process() routine requires options to be a struct: 

<cfargument name="options" type="struct" required="false" default="#structNew()#" />


Brian

Peter Knoch

unread,
Jan 4, 2017, 6:08:53 PM1/4/17
to cfpayment
I just ran the unit tests, and you are absolutely correct. I've closed the pull request, although I'm not sure at all why those changes fixed the problem in my code. I wasn't even using anything that would implement those lines, so I guess the problem resolved itself by ignoring those perceived "errors". Thanks for taking the time to review that. I'm still getting used to accepting credit card transactions on ColdFusion, so cfpayment is a lifesaver.

Peter

Brian G

unread,
Jan 4, 2017, 7:52:29 PM1/4/17
to cfpayment
Peter - no problems at all, I appreciate you taking the time to submit a PR instead of just coming here and saying, "It doesn't work". :) 

Brian
Reply all
Reply to author
Forward
0 new messages