0
votes

In the process of checking out Stripe Connect.

I've got to the stage where I can access the token (which is explained here https://stripe.com/docs/connect/oauth#token-request) but I'm having trouble accessing other parts of the object.

To retrieve the object I use:

response = @client.auth_code.get_token(code, params)

and to get at the token I use:

@token = response.token #strangely it isn't response.access_token

My problem is that I can't access other parts of Stripe's response which contains amongst other things a publishable key.

I have debugged the response and I get this (trimmed down and sensitive data altered):

...@token="sk_test_abc123", @refresh_token="rt_abc123", @expires_in=nil, @expires_at=nil, @options={:mode=>:header, :header_format=>"Bearer %s", :param_name=>"bearer_token"}, @params={"livemode"=>false, "token_type"=>"bearer", "stripe_publishable_key"=>"pk_test_abc123", "stripe_user_id"=>"abc123", "scope"=>"read_write"}

Can anyone tell me how to access the stripe_publishable_key in this response?

I've tried:

response.params[:stripe_publishable_key]

and

response.params.stripe_publishable_key
2

2 Answers

1
votes

Have you tried response.params['stripe_publishable_key']

0
votes

The hash is using strings rather than symbols for keys. You have to access the values using a string like this:

response.params["stripe_publishable_key"]