我想爲rails 3.2.13應用程序設置Stripe Connect。我已指示用戶條紋與從條接收回授權代碼:條紋連接 - 檢索訪問令牌
HTTP/1.1 302 Found
Location: http://localhost:3000/yourshop/stripe?scope=read_write&state=1234&code=AUTHORIZATION_CODE
下一步涉及使POST請求經由access_token_url以接收所述的access_token,每條紋文檔:
curl -X POST https://connect.stripe.com/oauth/token \
-d client_secret=sk_test_code \
-d code=AUTHORIZATION_CODE \
-d grant_type=authorization_code
我沒有任何curl的經驗是一個Rails應用程序,我無法找到Stripe API中的任何東西,看起來像這個POST請求包含在Stripe Gem中:
Gem file:
gem 'omniauth-stripe-connect'
gem 'stripe'
型號
def save_with_stripe_account
code = self.stripe_code
customer = curl -X POST https://connect.stripe.com/oauth/token \
-d "client_secret=ENV['STRIPE_SECRET_KEY']" \
-d "code=code" \
-d "grant_type=authorization_code"
raise customer.inspect
end
錯誤:
syntax error, unexpected tCONSTANT, expecting keyword_do or '{' or '('
不知道如果只是誤格式化爲捲曲的軌道,或者如果需要使用別的東西。
我不知道條紋API,但只是讓你知道:[捲曲](http://curl.haxx.se/docs/manpage.html)是一個命令行工具,所以你**不能**在你的Ruby代碼中複製粘貼爲一個curl命令。至少你需要在Ruby中執行[系統調用](http://martinhauser.com/wiki/Ruby_System_Calls)。在實踐中,我建議您使用Stripe gem本身(可能包括您需要的),或者 - 如果您需要自己執行自定義HTTP請求,請使用Ruby HTTP庫,例如[curb](https://rubygems.org/gems/curb),它使用libcurl或'Net :: HTTP'官方庫。 – deltheil