Square Examples

241 views
Skip to first unread message

Jason T.

unread,
May 4, 2017, 10:42:50 PM5/4/17
to cfpayment

Hello, Just started experimenting with cfpayment. Has anyone used cfpayment along with Square (https://squareup.com/developers) ? Square has examples on their site, but nothing for ColdFusion.

Risto

unread,
May 19, 2017, 1:35:28 PM5/19/17
to cfpayment
Hi Jason,

I just got tasked with a square job. I didn't find anything out there. After a while they all use REST and start looking the same.
It would be cool to add a gateway for square to cfpayment. I wish there was an explanation somewhere how to add another gateway besides just looking
at one of the other cfcs

Risto

unread,
May 19, 2017, 1:41:01 PM5/19/17
to cfpayment
Actually, I spoke too soon. On github there is a docs folder that has a pdf with some documentaion

Jason T.

unread,
May 19, 2017, 1:44:07 PM5/19/17
to cfpayment
I was able to get the Square API working via REST outside of cfpayment. I wanted to see if it could get it working before trying to integrate into cfpayment. It all relies on submitting a card nonce rather than the card number itself. Took me a little bit to wrap my head around how that worked.

Gene Rice

unread,
Jul 3, 2017, 7:16:02 AM7/3/17
to cfpayment
Where did you find info on submitting a card nonce rather than the number? I'm stuck on a project with a deadline. Any help would be greatly appreciated!

Jason T.

unread,
Jul 5, 2017, 9:35:17 PM7/5/17
to cfpayment
You can find the full documentation here:


You'll want the REST API Docs for integration with ColdFusion: https://docs.connect.squareup.com/articles/processing-payment-rest 

In order to get the card nonce, you have to use a secure form and it only works over an SSL connection. I used the example form they provided on this page: https://docs.connect.squareup.com/articles/paymentform-overview and substituted my account information as needed. Once you get that nonce, you can programmatically submit that to the server and process that nonce using ColdFusion to charge the actual credit card. 

Here's a quick example. You'll need to get your locationid and the authorization code and substitute those below in the places I have noted.

<cfset params = {
"amount_money" = {
"amount": 100,
"currency": "USD"
}
}>

<cfset params = {
"card_nonce" = "CBASEFO1lvpcxGS_FzAJQNrOuuwgAQ",
"amount_money" = {
"amount" = 100,
"currency" = "USD"
},
"idempotency_key" = CreateUUID(),
"delay_capture" =  false
}>

<cfhttpparam type="header" name="Accept" value="application/json">
<cfhttpparam type="header" name="Authorization" value="Bearer sandbox-YOUR_AUTHCODE_HERE">
<cfhttpparam type="body" value="#SerializeJSON(params)#" >
</cfhttp>  
<cfset response = ret.filecontent>

<cfif IsJson(response)>
<cfdump var="#DeserializeJSON(response)#">
</cfif>






Reply all
Reply to author
Forward
0 new messages