Page 1 of 1

dont understand Curl

Posted: Mon Oct 22, 2018 8:51 pm
by adventuresofgreg
Hey there. I'm trying to authenticate a Stripe transaction with LC script, and Yp totally don't understand Curl. According to the Stripe api guide, this is what I need to post to the stripe api URL:

curl https://api.stripe.com/v1/charges \
-u sk_test_123456ABCDEFG: \
-d amount=999 \
-d currency=usd \
-d description="Example charge" \
-d source=tok_visa

Tried POST ing that data a million ways to the URL, and I get nothing back. Can someone help?

Cheers,
Greg

Re: dont understand Curl

Posted: Tue Oct 23, 2018 9:30 pm
by jacque
Curl is a shell command, did you try that?

For POST you'd need something like this:

Code: Select all

put "sk_test_123456ABCDEFG?amount=999&currency=usd&description=Example charge&source=tok_visa" into tCmd
post tCmd to "https://api.stripe.com/v1/charges"
But I'm not quite sure where the "?" should go, it depends on what the server expects. It might need to be at the beginning instead of after the "sk_test" entry.

Re: dont understand Curl

Posted: Tue Oct 23, 2018 10:34 pm
by adventuresofgreg
Thank you. I tried something like your POST command, but didn't have a "?" in there. I'll give that a shot. But reading around - doesn't a Curl command require some kind of header?

Re: dont understand Curl

Posted: Tue Oct 23, 2018 10:39 pm
by adventuresofgreg
tried that post and it doesn't work. How would I send this as a shell command?

Re: dont understand Curl

Posted: Tue Oct 23, 2018 11:03 pm
by jacque
I'm not sure how the flags will impact it, but basically you can put the whole string into a variable and then:

get shell(tVar)

See the shell function in the dictionary. There's several examples there.

Re: dont understand Curl

Posted: Wed Oct 24, 2018 12:43 pm
by adventuresofgreg
field "stripeCurl" =

$ curl https://api.stripe.com/v1/charges \
-u sk_test_abc123: \
-d amount=999 \
-d currency=usd \
-d description="Example charge" \
-d source=tok_visa

My code:
get shell(field "stripeCurl")
put it

I get error:
/bin/sh: line 1: command not found

Re: dont understand Curl

Posted: Wed Oct 24, 2018 5:55 pm
by Klaus
Leave out the $!

Code: Select all

curl https://api.stripe.com/v1/charges ...
Should do the trick.

Re: dont understand Curl

Posted: Wed Oct 24, 2018 11:35 pm
by adventuresofgreg
oh my god Klaus! Thats it. I was so shocked to see my it that didn't just say error, that it actually scared me a bit! Thanks!

Next question: I need to run this from lc server on Linux. My standard shell command should work right?