ghanna1
Contributor
ghanna1
Contributor
Activity
‎Jul 31, 2023
07:37 AM
Thanks. I forgot to come back here and delete my post. I had a brain fart. Post was allowed on the CF server instead of the Woocommerce site's webserver.
... View more
‎Jul 30, 2023
07:03 PM
Hi folks, I'm working with the Woocommerce API. All my get commands work fine, but the put command returns a 405 error - verb not allowed. I've checked the cfm handlers in IIS, and it's set to allow all, and I do not have WebDEV installed in IIS. Any other suggestions on what to check? Thanks.. Gary
... View more
‎Sep 08, 2022
01:08 PM
Hi folks. I am trying to get data from an array in a JSON file. I create the variable webhook from the JSON. I need to get the product_ID from the two arrays. When I dump webhook to a file, it looks like this: ... line_items: [array] 1) [struct] id: 14 image: [struct] id: 57 src: https://i0.wp.com/www.blah.com/wp-content/uploads/2022/07/block_logo_round.png?fit=1200%2C1200&ssl=1 meta_data: [array] 1) [struct] display_key: _reduced_stock display_value: 1 id: 155 key: _reduced_stock value: 1 name: Block & Tackle Smokehouse and Tavern parent_name: undefined price: 19 product_id: 56 quantity: 1 sku: [empty string] subtotal: 19.00 subtotal_tax: 0.00 2) [struct] id: 15 image: [struct] id: [empty string] src: [empty string] meta_data: [array] 1) [struct] display_key: _reduced_stock display_value: 1 id: 156 key: _reduced_stock value: 1 name: Paddle parent_name: undefined price: 54 product_id: 82 quantity: 1 sku: [empty string] subtotal: 54.00 subtotal_tax: 0.00 First, I'm setting count to the Array Length. <cfset count = #ArrayLen(webhook.line_items)# /> That does return the length correctly. Then I am looping over the results; <cfloop from="1" to="#count#" index="C">
<!--- database code here --->
#webhook.line_items["#c#"].product_ID#
</cfloop> I'm getting the "You have attempted to dereference a scalar variable of type class java.lang.Double as a structure with members." Suggestions on what I am doing wrong? Thanks in advance for any help! Gary
... View more
‎May 20, 2022
05:10 AM
The .bat file only updates the password. The user ID is manually edited in the neo-security.xml file.
... View more
‎May 19, 2022
03:15 PM
Somehow I managed to forget my CF21 admin password. I ran the passwordreset.bat. (selected option 1). I looked in neo-security.xml to verify the admin user name. Restarted the services and still can't get in. Restarted the server - still can't get in. I've done the entire procedure multiple times trying a couple of different password combos. Tried changing the admin username in neo-security and restarted everything. I'm out of ideas. What am I missing??? Gary
... View more
‎Mar 09, 2022
05:53 AM
Just saw this response. Thanks! I will try it.
... View more
‎Mar 09, 2022
05:53 AM
Charlie, I downloaded jsoup and tried the sample code from the example it and just runs until it eventually times out. <!--- cache it to speed it up --->
<cfif not cacheIdExists("cnnhtml")>
<cfhttp url="http://www.cnn.com">
<cfset cnnhtml = cfhttp.filecontent>
<cfset cachePut("cnnhtml",cnnhtml)>
<cfelse>
<cfset cnnhtml = cacheGet("cnnhtml")>
</cfif>
<cfscript>
jsoup = createObject("java", "org.jsoup.Jsoup");
doc = jsoup.parse(cnnhtml);
links = doc.select("img");
</cfscript>
<cfdump var="#variables#" abort />
<cfloop index="e" array="#links#">
<cfoutput>
#e.attr("src")# --- Title: #e.attr("title")# --- Alt: #e.attr("alt")#<br/>
</cfoutput>
</cfloop> Did I miss something? Gary
... View more
‎Mar 01, 2022
12:39 PM
I'm going to try it tomorrow and I'll report back how it goes and mark the answer then.
... View more
‎Mar 01, 2022
12:23 PM
Thanks Charlie. I'm going to play with jsoup. Looks like a fun approach.
... View more
‎Mar 01, 2022
11:37 AM
Hello, I'd like to pull specific data off a page using cfhttp if it's possible. I start by getting the entire page. <cfhttp url="https://somesite.com/stream/" result="test">
<cfdump var="#test#"> In a perfect world, I'd like to extract just the first occurrence of the title and artist from the results into two variables. <li><span class="song-time">1:49 PM</span> <span class="song-title">Wanted Dead Or Alive</span>—<span class="song-artist">Bon Jovi</span></li> Is there a way to capture everything between the two span classes into two variables? I don't need the time span. Thanks! Gary
... View more
‎Feb 22, 2022
05:20 AM
1 Upvote
Thank you! This is something I've had on the back burner for years to save our fulfilment team the task of double data entry between our portal and UPS. We've used the UPS API before but after writing all the code they dumped the particular platform we were using for a more secure method. A few days ago I stumbled upon the Shippo API which allows you to compare multiple carriers, print the label then uses webhooks to update the status and delivery. Way more functionality than UPS and easier to work with. G
... View more
‎Feb 21, 2022
03:12 PM
Hi, I have a stuct that looks like this: If I need to display the attributes array. This works: <cfoutput>#shipment_response.data.rates["9"].attributes[1]#</cfoutput> However sometimes the Array is [empty]. How can I determine if it exists? I tried: <cfif StructKeyExists(shipment_response.data.rates["9"], "attributes[1]")>
<cfoutput>#shipment_response.data.rates["9"].attributes[1]#</cfoutput>
</cfif> It doesn't execute the cfoutput either way (exists or empty). What am I doing wrong with StructKeyExists? Thanks in advance for any suggestions! Gary
... View more
‎Nov 19, 2021
03:22 PM
Charlie, We have about 4000 devices in the field that check in every 5 seconds and another 10,000 devices that check in every hour. Then add the rest of our traffic and I estimate around 1100 per second. I didn't look at Fusion for an exact count. We're adding load balaning this weekend to split the traffic between our two datacenters. PS - sent you an email yesterday to try and get on your schedule to look at this.
... View more
‎Nov 19, 2021
10:33 AM
Thanks. Just need the temp fix while we dig into what is going on. We can see that traffic has increased to about 1100 transactions a second but as you mentioned there likely is more to the story.
... View more
‎Nov 19, 2021
06:36 AM
Hi, I've had to increase the allocated memory once before but I forget where to do it? I've looked through CF admin but I must be missing it. Thanks in advance... Gary
... View more
‎Nov 08, 2021
05:04 AM
1 Upvote
Take a look at: https://github.com/Gary-Hanna/Stripe-Coldfusion-API It will at least give you a start at how the Stripe API works.
... View more
‎Nov 08, 2021
04:53 AM
1 Upvote
Look here: https://github.com/Gary-Hanna/Stripe-Coldfusion-API Let me know if you need any help.
... View more
‎Jan 21, 2021
06:00 AM
BKBK, I appreciate your response. You are always helpful. In this case, however, you are partially correct. Yes, metadata would have fixed the issue in 2016 but is not needed in 2018 or 2021. "To reiterate, the error does not originate from the struct stFields. It originates from squareupdata, the output of a cfhttp post. But we don't know the contents of squareupdata. So the original question is moot." As I said above the issue is in stFields, not SquareUpData. SquareUpData is the response data from Square. You do not post SquareUpData it is a read only response. You post stFields and Square responds with a check_out URL in SquareUpData unless there is an error and then Square responds with the error in SquareUpData. The field order.Total_Money_Amount is a read-only field calculated by Square based on the fields in order.line_items.quantity and order.line_items.amount. Quantity and amount need to be integers. If Square can't read quantity and amount then the total order amount is less than 1 and Square responds in SquareUpData what the error is.
... View more
‎Jan 20, 2021
06:20 AM
I have updated to 2021. I appreciate your help though. For the next person reading this... 1) The field order.total_money_amount is actually a read-only field that Square calculates in the response. It is based on you sending order.amount and order.quantity. You don't send total_money in the request. 2) SquareUpData is the response data, not the data you send. Here's an example of working code: <cfset REQUEST.location_id = "YourLocationID">
<cfset REQUEST.Access_Token = "YourToken">
<cfset REQUEST.Square_Server = "connect.squareup.com">
<cfset REQUEST.Square_Version = "2020-12-16">
<cfif StructKeyExists(Session, "total") AND StructKeyExists(Session, "CustomerID")>
<cfset session.total = session.total * 100 />
<cfset REQUEST.Amount = #session.total#>
<cfif isDefined("URL.transactionId")>
<cfset rtFields = {
"order_ids": [
"#URL.orderID#"
]
}>
<cfhttp method="post" result="objGet" url="https://#REQUEST.Square_Server#/v2/locations/#REQUEST.location_id#/orders/batch-retrieve">
<cfhttpparam type="header" name="Accept" value="application/json">
<cfhttpparam type="header" name="Authorization" value="Bearer #REQUEST.Access_Token#">
<cfhttpparam type="header" name="Cache-Control" value="no-cache">
<cfhttpparam type="header" name="Content-Type" value="application/json">
<cfhttpparam type="body" value="#serializeJSON(rtFields)#">
</cfhttp>
<cfelse>
<cfset REQUEST.Base_Price_Money_Amount = #session.total#>
<cfset REQUEST.idempotency_key = #CreateUUID()#>
<cfset REQUEST.order_idempotency_key = #CreateUUID()#>
<cfset stFields = {
"idempotency_key": "#REQUEST.idempotency_key#",
"order": {
"idempotency_key": "REQUEST.order_idempotency_key",
"order": {
"location_id": "#session.REQUEST_LocationID",
"customer_id": "C-#session.CustomerID#",
"line_items": [
{
"quantity": '1',
"name": "Item Name",
"note": "Any Item Note",
"uid": "uid",
"base_price_money": {
"amount": int(#REQUEST.Base_Price_Money_Amount#),
"currency": "USD"
}
}
]
}
},
"ask_for_shipping_address": false,
"merchant_support_email": "CustomerService@example.com",
"redirect_url": "https://someURL.com/SquareOrderComplete.cfm"
}>
<cfhttp method="post" result="objGet" url="https://#REQUEST.Square_Server#/v2/locations/#REQUEST.location_id#/checkouts">
<cfhttpparam type="header" name="Square-Version" value="#REQUEST.Square_Version#">
<cfhttpparam type="header" name="Authorization" value="Bearer #REQUEST.Access_Token#">
<cfhttpparam type="header" name="Content-Type" value="application/json">
<cfhttpparam type="body" value="#serializeJSON(stFields)#">
</cfhttp>
</cfif>
<cfscript>
squareupdata = deserializeJSON(#objGet.FileContent#);
</cfscript> 3) If using CF2016 you need to add the metadata above in BKBK's post. You don't need it in 2018 and 2021. 4) Square checkout (unlike Stripe) after the customer completes the checkout does not return JSON. The customer can't get to the order complete page until the card has been approved. You get ID's for reference in the order complete URL.
... View more
‎Jan 19, 2021
01:14 PM
Square uses the lowest common denominator of any currency. So in the US, that's a penny. Sending 1 equals $0.01 where sending 100 equals $1.00. The issue was in CF 2016 when serializing the JSON CF wasn't sending the amounts as integers even if you wrapped it as INT(#value#). In CF2018 and CF2021 serializing the JSON created the value as an integer and Square was happy. We tested the exact same code in 2016, 2018, and 2021. It failed in 2016 and worked perfectly in the newer versions.
... View more
‎Jan 18, 2021
04:57 PM
It seems the issue was how CF2016 processes the JSON. The exact same code works in CF2021.
... View more
‎Jan 17, 2021
03:02 PM
I am having an issue with the square API and want to make sure I'm not doing something stupid. Here's my code: <cfset stFields = {
"order": {
"idempotency_key": "xxxxxx-215d-4dce-b92a-90c306eb5eba",
"location_id": "xxxxxx",
"total_money": {
"amount": 99999,
"currency_code": "USD"
},
"order": {
"location_id": "xxxxx",
"customer_id": "asdasd"
}
},
"idempotency_key": "xxxxxx-215d-4dce-b92a-90c306eb5eba",
"ask_for_shipping_address": false,
"merchant_support_email": "consectetur@loremipsum.com",
"redirect_url": "https://abc.com"
}
> I keep getting the error: {"errors":[{"category":"INVALID_REQUEST_ERROR","code":"VALUE_TOO_LOW","detail":"`order.total_money.amount` must be greater than 1.","field":"order.total_money.amount"}]} Yet... It looks to me like there's a value... Any ideas???
... View more
‎Dec 27, 2020
01:20 PM
Might not be the best way to do it but this worked to simply remove the # for the JSON results: <cfset content = replace(#cfhttp.filecontent#, "##", "", "all") />
<cfset results = deserializeJSON(content) />
... View more
‎Dec 27, 2020
12:44 PM
I tried your suggestion: <cfif Isdefined("results.track.album.image[2]['#text']")>
do something
</cfif> and still got: An expression that began on line 26, column 48. The expression might be missing an ending #, for example, #expr instead of #expr#. An expression beginning with /", on line 26, column 17.This message is usually caused by a problem in the expressions structure. An expression beginning with Isdefined, on line 26, column 7.This message is usually caused by a problem in the expressions structure. A cfif tag beginning on line 26, column 2.
... View more
‎Dec 27, 2020
11:42 AM
Hello, I need help understanding how to check if a variable is defined when the json variable contains a # in its name as shown in the image: I tried using ## but it not correct: <cfif Isdefined('results.track.album.image[2].##text') AND #results.track.album.image[2].##text# NEQ ''> Suggestions? Thanks! Gary
... View more
‎Dec 23, 2020
05:19 AM
1 Upvote
BKBK, Thanks for going through all that effort! I really appreciate it. I must have fat-fingered something the first time I tried your example. I also got it to work late last night using: <cfexecute name="d:\lame\lame.exe"
arguments="-b 128 ""d:\lame\ABBA - Dancing Queen.mp3"" ""d:\lame\Abba - Dancing Queen128.mp3""" /> Appreciate everyone's help! Gary
... View more
‎Dec 22, 2020
04:43 PM
Lame.exe only requires quotation marks if there are spaces in the input or output file. For a test, I renamed the input file to queen.mp3 and the output file to queen128.mp3. I ran the command line as: lame -b 128 queen.mp3 queen128.mp3 which worked as expected. I tried the same argument without quotes in CF and it works. So it's something wrong in how we're creating the argument with quotation marks. <cfexecute name="d:\lame\lame.exe"
arguments="-b 128 d:\lame\queen.mp3 d:\lame\queen128.mp3">
... View more
‎Dec 22, 2020
04:18 PM
Thanks for the suggestions. I tried BKBK's: <cfexecute name="d:\lame\lame.exe"
arguments='-b 128 "d:\lame\Abba - Dancing Queen.mp3"
"d:\lame\Abba - Dancing Queen 128.mp3"' I also tried adding timeout as Charlie suggested. <cfexecute name="d:\lame\lame.exe"
arguments='-b 128 "d:\lame\Abba - Dancing Queen.mp3"
"d:\lame\Abba - Dancing Queen 128.mp3"'
timeout = "20"
outputFile = "D:\lame\output.txt"> I also tried Charlie's suggestion of running CMD: <cfexecute name="c:\windows\system32\cmd.exe" arguments='/c d:\lame\lame.exe -b 128 "Abba - Dancing Queen.mp3" "Abba - Dancing Queen 128.mp3" '
timeout = "20"
outputFile = "D:\lame\output.txt"> Still no luck. Even if the arguments are wrong Lame.exe returns something. If CF is launching the exe shouldn't I see something besides an empty output.txt file created? I thought it would capture whatever lame.exe outputted. Gary
... View more