Charge an Account in 6 Lines of Code

61 views
Skip to first unread message

Mark King

unread,
Dec 19, 2016, 12:36:04 AM12/19/16
to cfpayment
This code is failing for me but I can't work out why. It worked 12 months ago, but now it fails.

Did Stripe change something?

<cfscript>
cfg = { path = "stripe.stripe", TestSecretKey = "sk_test_abc123etc." };
svc = createObject("component", "cfpayment.api.core").init(cfg);
gw = svc.getGateway();
account = svc.createCreditCard().setAccount(4242424242424242).setMonth(10).setYear(year(now())+1).setFirstName("John").setLastName("Doe");
money = svc.createMoney(5000);
response = gw.purchase(money = money, account = account);
if (response.getSuccess()) {
  writeoutput(response.getResult());
  writeoutput(response.getParsedResult());
}
else {
  writeoutput('Status:' & response.getStatus());
  writeoutput('Message:' & response.getMessage());
}
</cfscript>

I can't work out why it won't get through...

I get this in my browser:

Status:99

Message:


But I have no idea what status 99 means.


Thanks,
Mark


Brian G

unread,
Dec 19, 2016, 11:20:31 PM12/19/16
to cfpayment
Status 99 is an unknown response. Are you using an actual stripe test key I presume?  If you're in test mode, you can do this to get more details:

`gw.setTestMode(true);` to make sure you're in test mode before you run the test.

Then you can cfdump response.getRequestData() and response.getResult(). Feel free to post the results of those (but remove your Stripe key for example).


Brian
Reply all
Reply to author
Forward
0 new messages