0

檢查條紋連接的過程。條紋連接 - 處理響應

我已經到了可以訪問令牌的階段(這裏解釋的是https://stripe.com/docs/connect/oauth#token-request),但是我無法訪問該對象的其他部分。

要檢索我使用對象:

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

,並在我使用令牌來獲得:

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

我的問題是,我無法訪問包含條紋的響應的其他部分除其他外可發佈的關鍵。

我已經調試的響應,我得到這個(下調和敏感數據改變):

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

任何人都可以告訴我如何訪問此響應中的stripe_publishable_key?

我已經試過:

response.params[:stripe_publishable_key] 

response.params.stripe_publishable_key 

回答

1

你試過response.params['stripe_publishable_key']

+0

哦這麼簡單!我花了那麼多年哈哈 – tommyd456

0

哈希值使用字符串而非鍵符號。你必須使用這樣的字符串來訪問這些值:

response.params["stripe_publishable_key"]