百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

braintree_ruby

> 编程语言
开源

Braintree Ruby 库

445 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

Braintree Ruby 库

Braintree Ruby library

The Braintree gem provides integration access to the Braintree Gateway.

Please Note

The Payment Card Industry (PCI) Council has mandated that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, Braintree is updating its services to require TLS 1.2 for all HTTPS connections. Braintree will also require HTTP/1.1 for all connections. Please see our technical documentation for more information.

Installation

ruby
gem install braintree

Or add to your Gemfile:

ruby
gem 'braintree'

Optionally, you may also include Nokogiri for more performant XML parsing. If Nokogiri is not present, REXML will be used instead. The gem uses Nokogiri for XML parsing.

Dependencies

  • builder
  • nokogiri

The Braintree Ruby SDK is tested against Ruby versions 2.6, 2.7, 3.0, 3.4, and 4.0

The Ruby core development community has released End-of-Life branches for Ruby versions lower than 2.6, which are no longer receiving security updates. As a result, Braintree no longer supports these versions of Ruby. We have updated our gem specifications to reflect these updates.

Versions

:warning: The SSL certificates for Ruby SDK versions older than 2.82.0 are set to expire by March 30, 2026. If you do not update your SDK to the latest version with the updated certificates by March 30, 2026, 100% of your impacted traffic will fail

Braintree employs a deprecation policy for our SDKs. For more information on the statuses of an SDK check our developer docs. Minimum supported versions are also available in our developer docs.

Major version number Status Released Deprecated Unsupported
4.x.x Active May 2021 TBA TBA
3.x.x Deprecated October 2020 May 2023 May 2024
2.x.x Deprecated April 2010 October 2022 October 2023

Documentation

  • Official documentation

Updating from an Inactive, Deprecated, or Unsupported version of this SDK? Check our Migration Guide for tips.

Quick Start Example

…

You retrieve your merchant_id, public_key, and private_key when signing up for Braintree. Signing up for a sandbox account is easy, free, and instant.

Bang Methods

Most methods have a bang and a non-bang version (e.g. gateway.customer.create and gateway.customer.create!). The non-bang version will either return a SuccessfulResult or an ErrorResult. The bang version will either return the created or updated resource, or it will raise a ValidationsFailed exception.

Example of using non-bang method:

ruby
result = gateway.customer.create(:first_name => "Josh")
if result.success?
  puts "Created customer #{result.customer.id}"
else
  puts "Validations failed"
  result.errors.for(:customer).each do |error|
    puts error.message
  end
end

Example of using bang method:

ruby
begin
  customer = gateway.customer.create!(:first_name => "Josh")
  puts "Created customer #{customer.id}"
rescue Braintree::ValidationsFailed
  puts "Validations failed"
end

We recommend using the bang methods when you assume that the data is valid and do not expect validations to fail. Otherwise, we recommend using the non-bang methods.

Developing (Docker)

The Makefile and Dockerfile will build an image containing the dependencies and drop you to a terminal where you can run tests.

make

Linting

The Rakefile includes commands to run Rubocop. To run the linter commands use rake: rake lint.

Tests

The unit specs can be run by anyone on any system, but the integration specs are meant to be run against a local development server of our gateway code. These integration specs are not meant for public consumption and will likely fail if run on your system. To run unit tests use rake: rake test:unit.

Suppress Braintree Logs

To suppress logs from Braintree on environments where they are considered noise (e.g. test) use the following configuration:

ruby
logger = Logger.new("/dev/null")
logger.level = Logger::INFO
gateway.config.logger = logger

License

See the LICENSE file for more info.

Issues· 14 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubybraintreepaymentsruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言