mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-08-30 00:02:10 -04:00
Generate OAuth authorize URLs for express accounts
Connect with Express accounts uses a slightly different version of the OAuth authorize URL [1] in that it's prefixed with `/express`. Here we add a new option to `Stripe::OAuth.authorize_url` which allows `express: true` to be passed in to generate the Express variant. Note that the token endpoint has no equivalent so we don't need the option there. Fixes #717. [1] https://stripe.com/docs/connect/oauth-reference#express-account-differences
This commit is contained in:
parent
6f81c907e8
commit
403be3b106
@ -31,11 +31,14 @@ module Stripe
|
||||
def self.authorize_url(params = {}, opts = {})
|
||||
base = opts[:connect_base] || Stripe.connect_base
|
||||
|
||||
path = "/oauth/authorize"
|
||||
path = "/express" + path if opts[:express]
|
||||
|
||||
params[:client_id] = get_client_id(params)
|
||||
params[:response_type] ||= "code"
|
||||
query = Util.encode_parameters(params)
|
||||
|
||||
"#{base}/oauth/authorize?#{query}"
|
||||
"#{base}#{path}?#{query}"
|
||||
end
|
||||
|
||||
def self.token(params = {}, opts = {})
|
||||
|
@ -35,6 +35,15 @@ module Stripe
|
||||
assert_equal(["https://example.com/profile/test"], params["stripe_user[url]"])
|
||||
assert_equal(["US"], params["stripe_user[country]"])
|
||||
end
|
||||
|
||||
should "optionally return an express path" do
|
||||
uri_str = OAuth.authorize_url({}, express: true)
|
||||
|
||||
uri = URI.parse(uri_str)
|
||||
assert_equal("https", uri.scheme)
|
||||
assert_equal("connect.stripe.com", uri.host)
|
||||
assert_equal("/express/oauth/authorize", uri.path)
|
||||
end
|
||||
end
|
||||
|
||||
context ".token" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user