stripity_stripe v1.6.0 Stripe.Connect

Helper module for Connect related features at Stripe. Through this API you can:

  • retrieve the oauth access token or the full response, using the code received from the oauth flow return

(reference https://stripe.com/docs/connect/standalone-accounts)

Summary

Functions

Generate the URL to start a stripe workflow. You can pass in a crsf 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 on reception of the workflow callback

Same as oauth_token_callback, but gives you back only the access token which you can then use with the rest of the API.

{:ok, token} = Stripe.Connect.get_token code

De-authorize an account with your connect entity. A kind of oauth reset which invalidates all tokens and requires the customer to re-establish the link using the onboarding workflow.

Example

case Stripe.Connect.oauth_deauthorize stripe_user_id do
 {:ok, success} -> assert success == true
 {:error, msg} -> flunk msg
end

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

{:ok, resp} = Stripe.Connect.oauth_token_callback code
IO.inspect resp
%{
    token_type: "bearer",
    stripe_publishable_key: "PUBLISHABLE_KEY",
    scope: "read_write",
    livemode: false,
    stripe_user_id: "USER_ID",
    refresh_token: "REFRESH_TOKEN",
    access_token: "ACCESS_TOKEN"
}

Functions

base_url()
generate_button_url(csrf_token, redirect_uri \\ "")

Generate the URL to start a stripe workflow. You can pass in a crsf 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 on reception of the workflow callback.

You can also pass redirect_uri as a second parameter if you have multiple possible redirect_uris

get_token(code)

Same as oauth_token_callback, but gives you back only the access token which you can then use with the rest of the API.

{:ok, token} = Stripe.Connect.get_token code
oauth_deauthorize(stripe_user_id)

De-authorize an account with your connect entity. A kind of oauth reset which invalidates all tokens and requires the customer to re-establish the link using the onboarding workflow.

Example

case Stripe.Connect.oauth_deauthorize stripe_user_id do
 {:ok, success} -> assert success == true
 {:error, msg} -> flunk msg
end
oauth_token_callback(code)

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

{:ok, resp} = Stripe.Connect.oauth_token_callback code
IO.inspect resp
%{
    token_type: "bearer",
    stripe_publishable_key: "PUBLISHABLE_KEY",
    scope: "read_write",
    livemode: false,
    stripe_user_id: "USER_ID",
    refresh_token: "REFRESH_TOKEN",
    access_token: "ACCESS_TOKEN"
}