i'm trying to integrate stripe payments into my first website
think i'm most of the way there but i could use some help
zachsnow has quit
markin
sure, happy to try to help
couldusesomehelp
awesome, thank you. i'm using node.js and express, and trying to create a custom checkout for an HTML element on my page rather than the default button
i've pasted the stuff onto my HTML page between script tags that creates the handler, opens, and closes it
markin
ok
couldusesomehelp
although i'm not sure what should go here
markin
so the handler has a token key that takes a callback function
couldusesomehelp
// Use the token to create the charge with a server-side script. // You can access the token ID with `token.id`
zachsnow joined the channel
markin
yeah, so that function takes a token as its argument, you can then access the id of the token (token.id), and its up to you to chose how to send it to your server side code (you could append it to a form, or ajax, etc)
couldusesomehelp
hmm ok. my background is in front-end stuff, html and css, and this is my first time doing this kind of work. so i might need to ask a friend for help with that part
or if you have a simple example code that could go there and work
markin
sample code kinda depend on how you have your front end stuff (like is there a pre-existing form), and your backend a tad
couldusesomehelp
gotcha
no pre-existing form on the front end, just want to use Stripe's dropdown form
markin
My sample code was going to be inserting the token's id as a hidden input to a form and then submitting that form
couldusesomehelp
interesting. ok i'll bring that option up to my friend
on the server side, i put all the stuff from // Set your secret key: remember to change this to your live secret key in production and stripe.customers.create into my app.js
admin_maverb joined the channel
but running the app i get an error, stripeToken is not defined
markin
your server-side code is throwing that error?
couldusesomehelp
yeah
breaks the page
markin
so that means basically what it says, I'm guessing when you create the customer / charge you do source: stripeToken but you have to define what stripeToken is
the node way would be like var stripeToken = req.params.stripeToken (assuming thats what the name of the form input is)
couldusesomehelp
var stripeToken = request.body.stripeToken;
is what i have. i tried changing it to req. and it didn't work
oh maybe req.params will work
markin
well the route handlers in node take 2 parameters (so like app.get("/charge", function (req, res) so it'd be the name of that first parameter
couldusesomehelp
but this should essentially not work until i have the correct code in that other function we mentioned earlier?
markin
right
well really var stripeToken = request.body.stripeToken; should really only run in response to post requests
couldusesomehelp
so i'd have something like app.post("/charge", function (req, res) {var stripeToken = req.body.stripeToken}) ?
drale2k_ has quit
halfamind joined the channel
actually i think this is enough info for me to work with
thanks so much for your help :)
markin
yeah, though all your charge code would go in that function
Garopano: is it throwing an error? in PHP, you need to turn on some flags so that it prints out the error instead of just silently dying
Garopano
it gives me the last error: // Something else happened, completely unrelated to Stripe
praboud
another way of coming at this is to look in the stripe dashboard, since the second line will make an API request, and you can see what the result of that was in the logs section of the dashboard
huh, fascinating
maybe the logs, then?
Garopano
okay, I'll take a look at the dashboard. one sec.
when I run the script, it doesn't generate anything in the Stripe logs
praboud
ok
Garopano
am I using the right syntax for managed accounts?
praboud
if you print out the body of the error that you caught (var_dump, or whatever), what do you get?
Garopano: that looks right, assuming you're creating the charge on the platform
and even if you weren't, you wouldn't be getting this error (I think), so I'll wager it's unrelated to the syntax
Garopano
okay, I'll try it again and print out the error. one sec.
weird - why is it being caught in the last `catch`?
Garopano
I have no idea
saikat joined the channel
praboud
I may stand corrected then - are you creating the charges on the connected account?
also, can you make a gist of the complete code snippet? I'm curious why that error is being caught in that way
Garopano
I'm not sure. I thought I was doing it using the platform account. I'll do the entire snippet. one sec.
bklane has quit
praboud
when you create the charge, are you doing something like \Stripe\Charge::create(array(...), array("stripe_account"=>"...")); ?
if you're passing stripe_account, or using the secret key of the connected account, you're making the charge on the connected account side
BittBurger joined the channel
BittBurger
Anyone in support here?
Garopano
I don't specify a stripe account
praboud
BittBurger: just me still, it's a quiet day
Garopano
should I specify one when I do the charge?
markin
Hola!
praboud
I think markin's around as well
markin
Lol
praboud
ah, beat me to it
BittBurger
I need a better response to my issue than "ask Magento". That isnt going to fly. I assume support saw our previous conversaation Praboud
Because i got the laziest response on planet earth when i opened the ticket
praboud
Garopano: it depends on whether you want to create the charge on the platform or on the connected side
BittBurger: ticket to stripe or magento?
markin
BittBurger: magneto's API would control any import type thing
BittBurger
I have no reason to open a ticket with Magento
stop blaming magento]\
this is Stripes API
Magento has no problems with any other API's.
Garopano
oh, I see. when I created the charge. yes, I did specify the Stripe account when I made the charge.
the connected Stripe account
BittBurger
Your API can control whats sent through it. I can't expect Magento to change its entire software for the Stripe API
markin
I've worked with stripes API for years, stripe doesn't do any sort of import or export, that's done on the implementation
Magneto connects to stripe not vice versa
BittBurger
Well maybe the first problem is that technically, stripe hasn't bothered to even make an official Magento API, right?
I had to download one that some guy wrote
markin
Yeah, stripe doesn't build plugins for third parties
BittBurger
BitPay does ... nearly 30
markin
So that "some guy" is responsible
BittBurger
My fulfillment service does for at least 30
ok ill contact him.
markin
Then use bitpay. Stripe is meant to be by developers for developers
admin_maverb has quit
BittBurger
So stripe doesnt want to work with the general consumer public?
only developers
markin
They just provide the low level API libraries
BittBurger
oh
BitPay is a payment processor for Bitcoin transactions. Was just saying that as a payment processor, they've made API's for all the major stores.
Garopano
praboud, so if I specified the connected Stripe account when I initially made the charge, do I need to somehow reference that account when I do the refund?
BittBurger
Ill contact this API maker
praboud
Garopano: exactly, you'd need to add array("stripe_account" => the account id) to the charge fetch, and the refund creation
markin
Other people build plugins and stuff on top of the API libraries that can make it easier to integrate but stripe is just focused on making the libraries and API simple. It'd be hard for stripe to have the resources to do everything