stripity_stripe v2.0.0-alpha.3 Stripe.Connect.OAuth

Work with Stripe Connect.

You can:

  • generate the URL for starting the OAuth workflow
  • authorize a new connected account with a token
  • deauthorize an existing connected account

Stripe API reference: https://stripe.com/docs/connect/reference

Summary

Functions

Generate the URL to start a Stripe workflow. You can pass in a CSRF token to be sent to Stripe, which they send you back at the end of the workflow to further secure the interaction. Make sure you verify this token yourself upon receipt of the callback

De-authorizes the connected account

Execute the OAuth callback to Stripe using the code supplied in the request parameter of the oauth redirect at the end of the onboarding workflow

Functions

authorize_url()
authorize_url :: {:ok, map} | {:error, Stripe.api_error_struct}
authorize_url(csrf_token)
authorize_url(String.t) ::
  {:ok, map} |
  {:error, Stripe.api_error_struct}

Generate the URL to start a Stripe workflow. You can pass in a CSRF token to be sent to Stripe, which they send you back at the end of the workflow to further secure the interaction. Make sure you verify this token yourself upon receipt of the callback.

Example

iex(1)> {:ok, result} = Stripe.Connect.OAuth.authorize_url(csrf_token)
deauthorize(stripe_user_id)
deauthorize(String.t) ::
  {:ok, map} |
  {:error, Stripe.api_error_struct}

De-authorizes the connected account.

Requires the customer to re-establish the link using the onboarding workflow.

Example

iex(1)> {:ok, result} = Stripe.Connect.OAuth.deauthorize(stripe_user_id)
token(code)
token(String.t) ::
  {:ok, map} |
  {:error, Stripe.api_error_struct}

Execute the OAuth callback to Stripe using the code supplied in the request parameter of the oauth redirect at the end of the onboarding workflow.

Example

iex(1)> {:ok, resp} = Stripe.Connect.OAuth.token(code)
...(1)> IO.inspect resp
%Stripe.Connect.OAuth.TokenResponse{
    access_token: "ACCESS_TOKEN",
    livemode: false,
    refresh_token: "REFRESH_TOKEN",
    scope: "read_write",
    stripe_publishable_key: "PUBLISHABLE_KEY",
    stripe_user_id: "USER_ID",
    token_type: "bearer"
}