mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
Move code examples from charge to customer and remove save mention (#899)
This commit is contained in:
parent
dcb503dc71
commit
7182ae0f8b
35
README.md
35
README.md
@ -14,8 +14,6 @@ The library also provides other features. For example:
|
|||||||
|
|
||||||
- Easy configuration path for fast setup and use.
|
- Easy configuration path for fast setup and use.
|
||||||
- Helpers for pagination.
|
- Helpers for pagination.
|
||||||
- Tracking of "fresh" values in API resources so that partial updates can be
|
|
||||||
executed.
|
|
||||||
- Built-in mechanisms for the serialization of parameters according to the
|
- Built-in mechanisms for the serialization of parameters according to the
|
||||||
expectations of Stripe's API.
|
expectations of Stripe's API.
|
||||||
|
|
||||||
@ -65,13 +63,11 @@ value:
|
|||||||
require "stripe"
|
require "stripe"
|
||||||
Stripe.api_key = "sk_test_..."
|
Stripe.api_key = "sk_test_..."
|
||||||
|
|
||||||
# list charges
|
# list customers
|
||||||
Stripe::Charge.list()
|
Stripe::Customer.list()
|
||||||
|
|
||||||
# retrieve single charge
|
# retrieve single customer
|
||||||
Stripe::Charge.retrieve(
|
Stripe::Customer.retrieve("cus_123456789")
|
||||||
"ch_18atAXCdGbJFKhCuBAa4532Z",
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Per-request Configuration
|
### Per-request Configuration
|
||||||
@ -83,7 +79,7 @@ per-request key and/or account:
|
|||||||
```ruby
|
```ruby
|
||||||
require "stripe"
|
require "stripe"
|
||||||
|
|
||||||
Stripe::Charge.list(
|
Stripe::Customer.list(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
api_key: "sk_test_...",
|
api_key: "sk_test_...",
|
||||||
@ -92,8 +88,8 @@ Stripe::Charge.list(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Stripe::Charge.retrieve(
|
Stripe::Customer.retrieve(
|
||||||
"ch_18atAXCdGbJFKhCuBAa4532Z",
|
"cus_123456789",
|
||||||
{
|
{
|
||||||
api_key: "sk_test_...",
|
api_key: "sk_test_...",
|
||||||
stripe_account: "acct_...",
|
stripe_account: "acct_...",
|
||||||
@ -101,9 +97,9 @@ Stripe::Charge.retrieve(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Stripe::Charge.retrieve(
|
Stripe::Customer.retrieve(
|
||||||
{
|
{
|
||||||
id: "ch_18atAXCdGbJFKhCuBAa4532Z",
|
id: "cus_123456789",
|
||||||
expand: %w(balance_transaction)
|
expand: %w(balance_transaction)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -112,8 +108,8 @@ Stripe::Charge.retrieve(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Stripe::Charge.capture(
|
Stripe::Customer.capture(
|
||||||
"ch_18atAXCdGbJFKhCuBAa4532Z",
|
"cus_123456789",
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
stripe_version: "2018-02-28",
|
stripe_version: "2018-02-28",
|
||||||
@ -123,6 +119,7 @@ Stripe::Charge.capture(
|
|||||||
```
|
```
|
||||||
|
|
||||||
Keep in mind that there are different method signatures depending on the action:
|
Keep in mind that there are different method signatures depending on the action:
|
||||||
|
|
||||||
- When operating on a collection (e.g. `.list`, `.create`) the method signature is
|
- When operating on a collection (e.g. `.list`, `.create`) the method signature is
|
||||||
`method(params, opts)`.
|
`method(params, opts)`.
|
||||||
- When operating on resource (e.g. `.capture`, `.update`) the method signature is
|
- When operating on resource (e.g. `.capture`, `.update`) the method signature is
|
||||||
@ -138,10 +135,8 @@ method:
|
|||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
client = Stripe::StripeClient.new
|
client = Stripe::StripeClient.new
|
||||||
charge, resp = client.request do
|
customer, resp = client.request do
|
||||||
Stripe::Charge.retrieve(
|
Stripe::Customer.retrieve("cus_123456789",)
|
||||||
"ch_18atAXCdGbJFKhCuBAa4532Z",
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
puts resp.request_id
|
puts resp.request_id
|
||||||
```
|
```
|
||||||
@ -227,6 +222,7 @@ There are a few options for enabling it:
|
|||||||
The library has a hook for when a HTTP call is made which can be used for
|
The library has a hook for when a HTTP call is made which can be used for
|
||||||
monitoring. The callback receives a `RequestEvent` object with the following
|
monitoring. The callback receives a `RequestEvent` object with the following
|
||||||
data:
|
data:
|
||||||
|
|
||||||
- HTTP method (`Symbol`)
|
- HTTP method (`Symbol`)
|
||||||
- request path (`String`)
|
- request path (`String`)
|
||||||
- HTTP response code (`Integer`) if available, or `nil` in case of a lower
|
- HTTP response code (`Integer`) if available, or `nil` in case of a lower
|
||||||
@ -235,6 +231,7 @@ data:
|
|||||||
- the number of retries (`Integer`)
|
- the number of retries (`Integer`)
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
Stripe::Instrumentation.subscribe(:request) do |request_event|
|
Stripe::Instrumentation.subscribe(:request) do |request_event|
|
||||||
tags = {
|
tags = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user