#ryan-store-response

1 messages ยท Page 1 of 1 (latest)

narrow yacht
#

I'm not sure what you mean

gaunt spade
#

the function(err, response){}

#

im trying to store the response at the top level

#

can i jsut store in a var above?

#

sorry

#

I know its really silly

narrow yacht
#

Why not just return the response object at the end of the function call and store that way?

#

It's alright! It's not a silly question. I'm just trying to understand (:

gaunt spade
#

i need ot return the repsonse as a promise for. firbebase function

#

when I return directly from the inner function

#

new resource(stripe).request({
"expected_total": 2998
},
function(err, response) {
// asynchronously called
return response // <====
}
);

#

like this?

#

i need it at top level to make it accessible in the rest of the main function

narrow yacht
#

I'm not sure I can answer that question without looking at your whole integration and I'm not very familiar with Firebase. returning the response object will ensure that whatever called the function in the first place will have access to the response. I have no idea whether or not that function exists in main or how to get the return value to the main function

gaunt spade
#

ahh okay i seeee

#

thank you two-shoes

#

for your time

gaunt spade
#

@narrow yacht does this help explain a bit?

#

im trying to get the function to return the order object or payment intent

#

but I am being silly

narrow yacht
#

I'm not sure if that will work or not. I would recommend logging out the response object so you can see exactly where the information you want to return lives. It's usually best to return the whole object if you need multiple properties from it.

gaunt spade
#

hey @narrow yacht

#

thank you for your time

#

sorry for being silly but it seems I could use this function instead

#

which is a lot more readable to someone not akilled like me

#

but when I use this function I get TypeError: stripe.orders.submit is not a function

#

any idea why that would be?

#

my tripe object is initialised

#

stripe

#

and thank you again

narrow yacht
#

Can you link the docs you're using?

gaunt spade
#

i just realised my test key was in there woops ahah

narrow yacht
#

Is the stripe object declared within a scope that is accessible by the function call?

gaunt spade
#

yes definitely

#

i am using stripe.orders.create( for testing right above that call so the stripe.orders works fine for that call

narrow yacht
#

Can you post all the relevant code and leave a comment on it right above the line that's creating the error? I have no way to know what to advise without more context

gaunt spade
#

Screenshot 2022-05-12 at 22.50.19

#

thats the error produced

narrow yacht
#

Can you send me the account ID that's being used to make the call? (it will look like this acct_abc123)

gaunt spade
#

my main account?

#

sure

#

acct_1KhXZFGtw6jWtSam

#

thanks so much two shoes

#

and I am really sorry for taking up your time

#

I really appreciateit โค๏ธ

narrow yacht
#

Can you post the code where you're initializing the stripe object as well? Like the whole page as text, rather than a screenshot?

gaunt spade
narrow yacht
#

Can you try initializing stripe inside of the CreateOrder function and see if that fixes it?

gaunt spade
#

ill give it a go ๐Ÿ˜„

#

even like this same error

#

but don't worry two shoes

#

I am taking too much of your time

#

I will go try figure it out

#

and I want to give my greatest thanks for your assistance tonight

narrow yacht
#

No worries! That's what I'm here for. Happy to help and best of luck ๐Ÿ™Œ