AbacatePay SDK for Ruby on Rails
💻 Installation
Add this line to your application's Gemfile:
gem 'abacatepay-ruby'
And then execute:
bundle install
Or install it yourself as:
gem install abacatepay-ruby
🔧 Configuration
Configure your API token and environment in an initializer:
# config/initializers/abacatepay.rb
AbacatePay.configure do |config|
config.api_token = ENV['ABACATEPAY_TOKEN']
config.environment = :sandbox # or :production
end
🌟 Resources
Billing
Initialize the Billing Client
billing_client = AbacatePay::Clients::BillingClient.new
List Billings
Retrieve a list of all billings:
billing_client.list
Create a Billing
To create a billing, use the following code:
billing_client.create(
AbacatePay::Resources::Billing.new(
frequency: AbacatePay::Enums::Billing::Frequencies::ONE_TIME,
methods: [AbacatePay::Enums::Billing::Methods::PIX],
products: [
AbacatePay::Resources::Billing::Product.new(
external_id: 'abc_123',
name: 'Product A',
description: 'Description of product A',
quantity: 1,
price: 100 # Price in cents
)
],
metadata: AbacatePay::Resources::Billing::Metadata.new(
return_url: 'https://www.abacatepay.com',
completion_url: 'https://www.abacatepay.com'
),
customer: AbacatePay::Resources::Customer.new(
metadata: AbacatePay::Resources::Customer::Metadata.new(
name: 'Abacate Lover',
cellphone: '01912341234',
email: 'lover@abacate.com',
tax_id: '13827826837'
)
)
)
)
Alternatively, you can use a previously created customer by specifying their ID:
AbacatePay::Resources::Customer.new(
id: 'cust_DEbpqcN...'
)
Customer
Initialize the Customer Client
customer_client = AbacatePay::Clients::CustomerClient.new
List Customers
Retrieve a list of all customers:
customer_client.list
Create a Customer
To create a customer, use the following code:
customer_client.create(
AbacatePay::Resources::Customer.new(
metadata: AbacatePay::Resources::Customer::Metadata.new(
name: 'Abacate Lover',
cellphone: '01912341234',
email: 'lover@abacate.com',
tax_id: '13827826837'
)
)
)
📚 Documentation
For detailed information about the API and SDK, refer to the official documentation: https://abacatepay.readme.io/reference
🤝 Contribution
Contributions are welcome! If you wish to contribute:
- Fork the repository
- Create a new branch for your feature or fix:
git checkout -b feature/your-feature-name
- Make your changes and commit them:
git commit -m "Add your detailed commit message here"
- Push to your branch:
git push origin feature/your-feature-name
- Open a pull request with a clear description of your changes
Please ensure your code:
- Includes proper documentation
- Follows Ruby style guidelines
- Includes appropriate tests
- Passes all existing tests (bundle exec rspec)
- Passes code style checks (bundle exec rubocop)