Skip to content

Commit

Permalink
updated readme for stripe connect, bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymedavis committed Jul 26, 2015
1 parent af80426 commit f6f9574
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Stripe.net.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Stripe.net</id>
<version>4.1.0</version>
<version>4.2.0</version>
<authors>Jayme Davis</authors>
<owners>Jayme Davis</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down
2 changes: 1 addition & 1 deletion rakefile.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'albacore'

VERSION = "4.1.0"
VERSION = "4.2.0"

task :default => [:build35, :build40, :output35, :output40]

Expand Down
73 changes: 66 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,38 @@ First, thank you! It is a lot of work to learn someone else's codebase, so I app
* Do not submit pull requests for more than one fix. Keep them small and focused.
* Please code review yourself. There are a lot of pull requests with typos and mistakes. Don't worry, we all do it. But a code review of yourself will help. :)
* Please review the diff in GitHub that I will see before I merge your pull requests. If it's hard for you to tell what the differences are, it's going to be hard for me too.
* Please do not include files in your pull requests that are just white space changes.

Quick Start
-----------

It is recommended that you install Stripe.net via NuGet. If you wish to build it yourself via build.cmd, you will need
ruby installed along with the gems albacore and zip.
ruby installed along with the gems albacore and zip. You could also just build the assembly in Visual Studio by opening the solution and compiling.

Add a reference to Stripe.net.dll.

Next you will need to provide Stripe.net with your api key. There are 3 ways to do this: Choose one.
Next you will need to provide Stripe.net with your api key. There are 4 ways to do this:

a) Add an AppSetting with your api key to your config (this is the easiest way)
a) Add an AppSetting with your api key to your config (this is the easiest way and will work throughout the app on every request)

<appSettings>
...
<add key="StripeApiKey" value="[your api key here]" />
...
</appSettings>

b) In your application initialization, call (this is a programmatic way, but you only have to do it once during startup)
b) In your application initialization, call this method (this is a programmatic way, but you only have to do it once during startup)

StripeConfiguration.SetApiKey("[your api key here]");

c) In any of the service constructors documented below, you can optionally pass the api key (not recommended for single app/single key use). i.e...
c) In any of the service constructors, you can optionally pass the api key (will be assigned that apikey for the life of the service instance).

var planService = new StripePlanService("[your api key here]");

d) In any of the service calls, you can pass a [StripeRequestOptions](#striperequestoptions) object with the apikey specified.

var planService = new StripePlanService();
planService.Get(*planId*, new StripeRequestOptions() { ApiKey = "[your api key here]" });

Stripe API Version
------------------

Expand Down Expand Up @@ -806,7 +810,62 @@ StripeEventListOptions supports a type, [StripeListOptions](#stripelistoptions-p
Stripe Connect
--------------

For information about how to use Stripe Connect, see this comment https://github.com/jaymedavis/stripe.net/pull/43#issuecomment-10903921
The Stripe Connect documentation can be a little intimidating, so I am going to try to break it down a little. Stripe Connect gives you the ability to accept money on behalf of other accounts,
and access or modify connected accounts depending on permissions.

1) The first thing you need to do is [register your platform](https://dashboard.stripe.com/account/applications/settings) with Stripe Connect. Stripe.net at this time only supports
[Standalone Accounts](https://stripe.com/docs/connect/standalone-accounts), which is very useful because it supports every country Stripe supports. Managed Accounts are a
valuable service as well, but they are not available in Stripe.net yet.

2) The next thing to do, is have another party connect to your site. To do this, put a link on your site which will start the authorization process, or you can use a
[Stripe Connect Button](https://stripe.com/about/resources). Your link will need to contain some querystring paramaters:
response_type: code
client_id: *your client id from the stripe connect dashboard*
scope: read_only (default), or read_write (lets you modify their data as well) // this is optional and defaults to read_only
redirect_uri: this is optional, and will return the user to this page when the connection is complete
other options are available and you can learn more about them with the [Connect OAuth Reference](https://stripe.com/docs/connect/reference)

3) When the user clicks the link on your site, they will be prompted to authorize the connection. At this point, they can create a new Stripe account or setup the connection with an existing account.

Your link will look something like this:
https://connect.stripe.com/oauth/authorize?response_type=code&client_id=*your_client_id_from_the_stripe_connect_dashboard&scope=read_write

4) The link above will return a code when the setup is complete (and also return back to your redirect_uri if specified). With this code, you can make a request to Stripe to get the StripeUserId for accessing
their account.

In Stripe.net, you can accomplish this with the following code:

var stripeOAuthTokenService = new StripeOAuthTokenService();
var stripeOAuthTokeCreateOptions = new StripeOAuthTokenCreateOptions()
{
ClientSecret = ConfigurationManager.AppSettings["StripeApiKey"],
Code = *the code returned from above*,
GrantType = "authorization_code"
};

StripeOAuthToken stripeOAuthToken = stripeOAuthTokenService.Create(_stripeOAuthTokeCreateOptions);

5) You're done! Whenever you need to access the connected account, you simply need the StripeUserId from the StripeOAuthToken to be passed as part of the [StripeRequestOptions](#striperequestoptions)
which all service calls now support as an optional parameter.

For example, to get the plans on the connected account, you could run the following code:

var planService = new StripePlanService();
StripePlan response = planService.List(null /* StripeListOptions */, new StripeRequestOptions() { StripeConnectAccountId = *the StripeUserId on the StripeOAuthToken above* });

Depending on if your permissions are read_write or read_only, you can do anything on the connected account you can do on your own account just by passing the StripeUserId as
part of StripeRequestOptions.

StripeRequestOptions
--------------------

All of the service methods accept an optional StripeRequestOptions object. This is used if you need to use an [Idempotency Key](https://stripe.com/docs/api?lang=curl#idempotent_requests),
if you are using Stripe Connect, or if you want to pass the ApiKey on each method.

var requestOptions = new StripeRequestOptions();
requestOptions.ApiKey = *optional*; // this is not required unless you choose to pass the apikey on every service call
requestOptions.IdempotencyKey = "some string"; // this is for [Idempotent Requests](https://stripe.com/docs/api?lang=curl#idempotent_requests) (to make sure a charge wont go through more than once)
requestOptions.StripeConnectAccountId = "acct_*" // if you are using Stripe Connect and want to issue a request on the connected account

Errors
------
Expand Down
2 changes: 1 addition & 1 deletion src/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
[assembly: AssemblyCompany("Jayme Davis")]
[assembly: AssemblyProduct("Stripe.net")]
[assembly: AssemblyCopyright("Copyright (C) Jayme Davis 2015")]
[assembly: AssemblyVersion("4.1.0")]
[assembly: AssemblyVersion("4.2.0")]

0 comments on commit f6f9574

Please sign in to comment.