
Security News
Oxlint Introduces Type-Aware Linting Preview
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
This is the official Ruby library for integrating with Chargebee.
Note: Chargebee now supports two API versions - V1 and V2, of which V2 is the latest release and all future developments will happen in V2. This library is for API version V2. If you’re looking for V1, head to chargebee-v1 branch.
Install the latest version of the gem with the following command...
$ sudo gem install chargebee -v '~>2'
See our Ruby API Reference.
ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
result = ChargeBee::Subscription.create({
:id => "sub_KyVqDh__dev__NTn4VZZ1",
:plan_id => "basic",
})
subscription = result.subscription
puts "created subscription is #{subscription}"
Idempotency keys are passed along with request headers to allow a safe retry of POST requests.
require 'chargebee'
ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
result = ChargeBee::Customer.create({
:first_name => "John",
:last_name => "Doe",
:email => "john@test.com",
:locale => "fr-CA",
:billing_address => {
:first_name => "John",
:last_name => "Doe",
:line1 => "PO Box 9999",
:city => "Walnut",
:state => "California",
:zip => "91789",
:country => "US"
}
},
nil,
{"chargebee-idempotency-key" => "<<UUID>>"} # Replace <<UUID>> with a unique string
)
customer = result.customer
card = result.card
responseHeader = result.get_response_headers # Retrieves response headers
puts(responseHeader)
idempotencyReplayedValue = result.is_idempotency_replayed # Retrieves Idempotency replayed header value
puts(idempotencyReplayedValue)
is_idempotency_replayed
method can be accessed to differentiate between original and replayed requests.
Chargebee's SDK includes built-in retry logic to handle temporary network issues and server-side errors. This feature is disabled by default but can be enabled when needed.
500
, 502
, 503
, and 504
.429 Too Many Requests
response is received with a Retry-After
header, the SDK waits for the specified duration before retrying.
Note: Exponential backoff and max retries do not apply in this case.
retryConfig
parameter in the environment configuration.You can enable and configure the retry logic by passing a retryConfig
object when initializing the Chargebee environment:
require 'chargebee'
ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
# Set comprehensive retry configuration
ChargeBee::default_env.retry_config = {
enabled: true,
max_retries: 1,
delay_ms: 2000,
retry_on: [500]
}
# ... your Chargebee API operations ...
You can enable and configure the retry logic for rate-limit by passing a retryConfig
object when initializing the Chargebee environment:
require 'chargebee'
ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
# Set comprehensive retry configuration
ChargeBee::default_env.retry_config = {
enabled: true,
max_retries: 1,
delay_ms: 1000,
retry_on: [429]
}
# ... your Chargebee API operations ...
See the LICENSE file.
FAQs
Unknown package
We found that chargebee demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.