#rmoura-api-key

1 messages ยท Page 1 of 1 (latest)

tall drift
#

hello, what language are you using? Also why would you want to only do that on a particular endpoint? Shouldn't you just be setting it once, as the Platform's API key

runic plover
#

I'm using Ruby. The platform that I'm developing adopted a method of requesting the users for their secret key and then would change the API key depending on the action. We are now trying to implement the Stripe connect method but still keeping that old method (for convenience to the users that already set up Stripe before). In order to keep from changing the Stripe.api_key property, this pre-request API key would really come in handy.

tall drift
#

gotcha, the link you sent, that shows an example right

require 'stripe'
charge = Stripe::Charge.retrieve(
  'ch_3JcehN2eZvKYlo2C1IleuGd9',
  {
    api_key: 'sk_test_4eC3rjtT1zdp7dc',
  }
)

how you pass api_key in the options hash

runic plover
#

Stripe::Account.retrieve({ api_key: stripe.prop('account_secret_key') })

#

It gives me an error about the argument. It seems that retrieve doenst support the argument options (hash).

tall drift
#

I think you want an empty hash ({}, { api_key: ...})

then the options hash

runic plover
#

๐Ÿ˜ฎ

tall drift
#

or rather, the first param being the Account ID you're fetching so something like the above snippet which has the Charge ID as the first param

runic plover
#

Same error :/

#

It works if I just give nil (NULL)

#

Thank you ๐Ÿ™‚

eternal kettle
#

๐Ÿ‘‹ Just hopping in for @tall drift since they had to go - have you got it figured out, or is it still not working?

runic plover
#

Can I do the same with Stripe::WebhookEndpoint.list({limit: 3})???

#

like specify the api_key

eternal kettle
#

Yup! You should be able to

eternal kettle
#

unarchived in case you need it @runic plover

runic plover
#

Im doing this Stripe::WebhookEndpoint.list(limit: 100, metadata: { api_key: payment_method.prop('account_secret_key') })

#

But a exception is caught No API key provided. Set your API key using "Stripe.api_key = <API-KEY>". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions.

eternal kettle
#

why are you setting it as metadata?

runic plover
#

what should I set? The documentation is really good but this part of listing a webhook only mentions these options

eternal kettle
#

You want to do this:

Stripe::WebhookEndpoint.list({limit: 100}, { api_key:payment_method.prop('account_secret_key')})