Last active
July 3, 2017 17:14
-
-
Save tristansokol/ac2b2850153e58b7ca8a5c5af407458c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get locaiton id | |
<cfset jsonString = serializejson(request.params)> | |
<cfset requestPath = "connect.squareup.com/v2/locations">; | |
<cfhttp url="#requestPath#" method="get" result="response"> | |
<cfhttpparam type="HEADER" name="Accept" value="application/json"> | |
<cfhttpparam type="HEADER" name="Content-Type" value="application/json"> | |
<cfhttpparam type="HEADER" name="Authorization" value="Bearer myid"> | |
<cfhttpparam type="body" name="params" value="#jsonString#"> | |
</cfhttp> | |
<cfset v_result = deserializeJSON(response.FileContent)> | |
<cfset v_locationid = "#v_result.locations[1].id#"> | |
//make charge request - see https://docs.connect.squareup.com/articles/paymentform-overview for information about card_nonce | |
<cfset IDKey = CreateUUID()> | |
<cfset request.params.card_nonce = form.nonce> | |
<cfset request.params.amount_money.amount = 100> | |
<cfset request.params.amount_money.currency = 'USD'> | |
<cfset request.params.idempotency_key = IDKey> | |
<cfset jsonString = serializejson(request.params)> | |
<cfset requestPath = "https://connect.squareup.com/v2/locations/<replace_locationid>/transactions"> | |
<cfhttp url="#requestPath#" method="post" result="response"> | |
<cfhttpparam type="HEADER" name="Accept" value="application/json"> | |
<cfhttpparam type="HEADER" name="Content-Type" value="application/json"> | |
<cfhttpparam type="HEADER" name="Authorization" value="Bearer <replace_access_token>"> | |
<cfhttpparam type="body" name="params" value="#jsonString#"> | |
</cfhttp> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment