mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-06-06 00:01:04 -04:00
Merge pull request #505 from stripe/brandur-update-readme
Update README
This commit is contained in:
commit
150432183a
72
README.md
72
README.md
@ -50,8 +50,8 @@ gem 'stripe'
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The library needs to be configured with your account's secret key which is
|
The library needs to be configured with your account's secret key which is
|
||||||
available in the [Dashboard][dashboard]. Assign its value to `Stripe.api_key`
|
available in your [Stripe Dashboard][dashboard]. Set `Stripe.api_key` to its
|
||||||
and the library will send it along automatically with every request:
|
value:
|
||||||
|
|
||||||
``` ruby
|
``` ruby
|
||||||
require "stripe"
|
require "stripe"
|
||||||
@ -66,14 +66,11 @@ Stripe::Charge.retrieve(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also set a per-request key and/or account like in the examples below.
|
### Per-request Configuration
|
||||||
This is often useful for Connect applications that use multiple API keys during
|
|
||||||
the lifetime of a process.
|
|
||||||
|
|
||||||
Authentication is transparently handled for you in subsequent method calls on
|
For apps that need to use multiple keys during the lifetime of a process, like
|
||||||
the returned object.
|
one that uses [Stripe Connect][connect], it's also possible to set a
|
||||||
|
per-request key and/or account:
|
||||||
For example:
|
|
||||||
|
|
||||||
``` ruby
|
``` ruby
|
||||||
require "stripe"
|
require "stripe"
|
||||||
@ -91,6 +88,40 @@ Stripe::Charge.retrieve(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Configuring a Client
|
||||||
|
|
||||||
|
While a default HTTP client is used by default, it's also possible to have the
|
||||||
|
library use any client supported by [Faraday][faraday] by initializing a
|
||||||
|
`Stripe::StripeClient` object and giving it a connection:
|
||||||
|
|
||||||
|
``` ruby
|
||||||
|
conn = Faraday.new
|
||||||
|
client = Stripe::StripeClient.new(conn)
|
||||||
|
client.request do
|
||||||
|
charge, resp = Stripe::Charge.retrieve(
|
||||||
|
"ch_18atAXCdGbJFKhCuBAa4532Z",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
puts resp.request_id
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuring CA Bundles
|
||||||
|
|
||||||
|
By default, the library will use its own internal bundle of known CA
|
||||||
|
certificates, but it's possible to configure your own:
|
||||||
|
|
||||||
|
Stripe.ca_bundle_path = "path/to/ca/bundle"
|
||||||
|
|
||||||
|
### Configuring Automatic Retries
|
||||||
|
|
||||||
|
The library can be configured to automatically retry requests that fail due to
|
||||||
|
an intermittent network problem:
|
||||||
|
|
||||||
|
Stripe.max_network_retries = 2
|
||||||
|
|
||||||
|
[Idempotency keys][idempotency-keys] are added to requests to guarantee that
|
||||||
|
retries are safe.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
Run all tests:
|
Run all tests:
|
||||||
@ -109,25 +140,8 @@ Update bundled CA certificates from the [Mozilla cURL release][curl]:
|
|||||||
|
|
||||||
bundle exec rake update_certs
|
bundle exec rake update_certs
|
||||||
|
|
||||||
## Configuration
|
[connect]: https://stripe.com/connect
|
||||||
|
|
||||||
### ca_bundle_path
|
|
||||||
|
|
||||||
The location of a file containing a bundle of CA certificates. By default the
|
|
||||||
library will use an included bundle that can successfully validate Stripe
|
|
||||||
certificates.
|
|
||||||
|
|
||||||
### max_network_retries
|
|
||||||
|
|
||||||
When `max_network_retries` is set to a positive integer, stripe will retry
|
|
||||||
requests that fail on a network error. Idempotency keys will be added to `POST`
|
|
||||||
and `DELETE` requests to ensure the safety of retrying. There will be a short delay
|
|
||||||
between each retry, with an exponential backoff algorithm used to determine the
|
|
||||||
length of the delay. Default value is 0.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
Stripe.max_network_retries = 2
|
|
||||||
|
|
||||||
[curl]: http://curl.haxx.se/docs/caextract.html
|
[curl]: http://curl.haxx.se/docs/caextract.html
|
||||||
|
[faraday]: https://github.com/lostisland/faraday
|
||||||
|
[idempotency-keys]: https://stripe.com/docs/api/ruby#idempotent_requests
|
||||||
[dashboard]: https://dashboard.stripe.com/account
|
[dashboard]: https://dashboard.stripe.com/account
|
||||||
|
Loading…
x
Reference in New Issue
Block a user