Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ CLAUDE.md
acr.yaml
acr.lock
.github/copilot-instructions.md
Gemfile.lock
11 changes: 4 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

source "https://rubygems.org"

# Specify your gem's dependencies in paystack-ruby.gemspec
gemspec

gem "irb"
gem "rake", "~> 13.0"

gem "minitest", "~> 5.16"

gem "standard", "~> 1.3"
group :development do
gem "rake", "~> 13.0"
gem "minitest", "~> 5.16"
end
146 changes: 128 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,153 @@
# Paystack::Ruby
# Paystack Ruby SDK

TODO: Delete this and the text below, and describe your gem
> The official Ruby SDK for the Paystack API — generated from the Paystack OpenAPI specification.

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/paystack/ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Ruby ≥ 3.1](https://img.shields.io/badge/ruby-%3E%3D3.1-red)](https://www.ruby-lang.org)

---

## Requirements

- **Ruby 3.1 or later**
- Standard library HTTP stack (`net/http`) — no extra runtime HTTP dependency

---

## Installation

TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
Add this line to your application's Gemfile:

Install the gem and add to the application's Gemfile by executing:
```ruby
gem "paystack-ruby"
```

Then execute:

```bash
bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
bundle install
```

If bundler is not being used to manage dependencies, install the gem by executing:
Or install directly:

```bash
gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
gem install paystack-ruby
```

---

## Quick Start

```ruby
require "paystack"

paystack = Paystack::Client.new(ENV.fetch("PAYSTACK_SECRET_KEY"))

result = paystack.transaction.initialize(
{
email: "customer@example.com",
amount: 100_000 # kobo
}
)

puts result.data[:authorization_url]
```

## Usage
---

TODO: Write usage instructions here
## Configuration

## Development
Initialize `Paystack::Client` with your secret key:

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
```ruby
paystack = Paystack::Client.new("sk_live_xxxxxxxxxxxx")
```

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
| Option | Type | Required | Default |
|---|---|---|---|
| `api_key` | `String` | ✅ | — |

---

## Response Shape

All resource methods return a `Paystack::Response` object exposing:

```ruby
response.http_status # Integer
response.status # Boolean
response.message # String
response.data # Hash / Array / nil
response.meta # Hash / nil
```

---

## Error Handling

API failures raise typed exceptions:

```ruby
begin
paystack.transaction.initialize({ email: "customer@example.com", amount: 100_000 })
rescue Paystack::AuthenticationError,
Paystack::ValidationError,
Paystack::NotFoundError,
Paystack::RateLimitError,
Paystack::ServerError => e
puts e.message
puts e.http_status
end
```

---

## API Reference

The SDK exposes one method per API resource on the `Paystack::Client` instance.

| Resource | Property | Description | Methods |
|---|---|---|---|
| [ApplePay](./docs/apple_pay.md) | `paystack.apple_pay` | A collection of endpoints for managing application's top-level domain or subdomain accepting payment via Apple Pay | 3 |
| [Balance](./docs/balance.md) | `paystack.balance` | A collection of endpoints gaining insights into the amount on an integration | 2 |
| [Bank](./docs/bank.md) | `paystack.bank` | A collection of endpoints for managing bank details | 3 |
| [BulkCharge](./docs/bulk_charge.md) | `paystack.bulk_charge` | A collection of endpoints for creating and managing multiple recurring payments | 6 |
| [Charge](./docs/charge.md) | `paystack.charge` | A collection of endpoints for configuring and managing the payment channels when initiating a payment | 7 |
| [Customer](./docs/customer.md) | `paystack.customer` | A collection of endpoints for creating and managing customers on an integration | 12 |
| [DedicatedVirtualAccount](./docs/dedicated_virtual_account.md) | `paystack.dedicated_virtual_account` | A collection of endpoints for creating and managing payment accounts for customers | 9 |
| [DirectDebit](./docs/direct_debit.md) | `paystack.direct_debit` | A collection of endpoints for managing Direct Debit | 2 |
| [Dispute](./docs/dispute.md) | `paystack.dispute` | A collection of endpoints for managing transactions complaint made by customers | 8 |
| [Integration](./docs/integration.md) | `paystack.integration` | A collection of endpoints for managing some settings on an integration | 2 |
| [Miscellaneous](./docs/miscellaneous.md) | `paystack.miscellaneous` | A collection of endpoints that provides utility functions | 3 |
| [Order](./docs/order.md) | `paystack.order` | A collection of endpoints for creating and managing orders | 5 |
| [Page](./docs/page.md) | `paystack.page` | A collection of endpoints for creating and managing links for the collection of payment for products | 6 |
| [PaymentRequest](./docs/payment_request.md) | `paystack.payment_request` | A collection of endpoints for managing invoices for the payment of goods and services | 9 |
| [Plan](./docs/plan.md) | `paystack.plan` | A collection of endpoints for creating and managing recurring payment configuration | 4 |
| [Product](./docs/product.md) | `paystack.product` | A collection of endpoints for creating and managing inventories | 5 |
| [Refund](./docs/refund.md) | `paystack.refund` | A collection of endpoints for creating and managing transaction reimbursement | 4 |
| [Settlement](./docs/settlement.md) | `paystack.settlement` | A collection of endpoints for gaining insights into payouts | 2 |
| [Split](./docs/split.md) | `paystack.split` | A collection of endpoints for spliting a transaction and managing the splits | 6 |
| [Storefront](./docs/storefront.md) | `paystack.storefront` | A collection of endpoints for creating and managing storefronts | 11 |
| [Subaccount](./docs/subaccount.md) | `paystack.subaccount` | A collection of endpoints for creating and managing accounts for sharing a transaction with | 4 |
| [Subscription](./docs/subscription.md) | `paystack.subscription` | A collection of endpoints for creating and managing recurring payments | 7 |
| [Terminal](./docs/terminal.md) | `paystack.terminal` | A collection of endpoints for building delightful in-person payment experiences | 8 |
| [Transaction](./docs/transaction.md) | `paystack.transaction` | A collection of endpoints for managing payments | 9 |
| [Transfer](./docs/transfer.md) | `paystack.transfer` | A collection of endpoints for automating sending money to beneficiaries | 11 |
| [TransferRecipient](./docs/transfer_recipient.md) | `paystack.transfer_recipient` | A collection of endpoints for creating and managing beneficiaries that you send money to | 6 |
| [VirtualTerminal](./docs/virtual_terminal.md) | `paystack.virtual_terminal` | A collection of endpoints for building in-person payments without a physical terminal | 9 |

Detailed method-level documentation for each resource is available in [`docs/`](./docs/).

---

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/paystack-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/paystack-ruby/blob/main/CODE_OF_CONDUCT.md).
> ⚠️ **This SDK is auto-generated** from the Paystack OpenAPI specification. Regenerate instead of manually editing generated files.

## License
To request endpoint/schema changes, open an issue or pull request against the [Paystack OpenAPI specification](https://github.com/PaystackOSS/openapi).

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
---

## Code of Conduct
## License

Everyone interacting in the Paystack::Ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/paystack-ruby/blob/main/CODE_OF_CONDUCT.md).
MIT © Paystack
4 changes: 1 addition & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ require "minitest/test_task"

Minitest::TestTask.create

require "standard/rake"

task default: %i[test standard]
task default: %i[test]
60 changes: 60 additions & 0 deletions docs/apple_pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# ApplePay

A collection of endpoints for managing application's top-level domain or subdomain accepting payment via Apple Pay

## Methods

| Method | HTTP | Path | Summary |
|---|---|---|---|
| `list_domain` | `GET` | `/apple-pay/domain` | List Domains |
| `register_domain` | `POST` | `/apple-pay/domain` | Register Domain |
| `unregister_domain` | `DELETE` | `/apple-pay/domain` | Unregister Domain |

---

## `list_domain`

**HTTP:** `GET`
**Path:** `/apple-pay/domain`

```ruby
paystack.apple_pay.list_domain({ ... })
```

### Query Fields

| Name | Required |
|---|---|
| `use_cursor` | false |
| `next` | false |
| `previous` | false |

## `register_domain`

**HTTP:** `POST`
**Path:** `/apple-pay/domain`

```ruby
paystack.apple_pay.register_domain({ ... })
```

### Body Fields

| Name | Required |
|---|---|
| `domainName` | true |

## `unregister_domain`

**HTTP:** `DELETE`
**Path:** `/apple-pay/domain`

```ruby
paystack.apple_pay.unregister_domain({ ... })
```

### Body Fields

| Name | Required |
|---|---|
| `domainName` | true |
39 changes: 39 additions & 0 deletions docs/balance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Balance

A collection of endpoints gaining insights into the amount on an integration

## Methods

| Method | HTTP | Path | Summary |
|---|---|---|---|
| `fetch` | `GET` | `/balance` | Fetch Balance |
| `ledger` | `GET` | `/balance/ledger` | Balance Ledger |

---

## `fetch`

**HTTP:** `GET`
**Path:** `/balance`

```ruby
paystack.balance.fetch
```

## `ledger`

**HTTP:** `GET`
**Path:** `/balance/ledger`

```ruby
paystack.balance.ledger({ ... })
```

### Query Fields

| Name | Required |
|---|---|
| `perPage` | false |
| `page` | false |
| `from` | false |
| `to` | false |
77 changes: 77 additions & 0 deletions docs/bank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Bank

A collection of endpoints for managing bank details

## Methods

| Method | HTTP | Path | Summary |
|---|---|---|---|
| `list` | `GET` | `/bank` | List Banks |
| `resolve_account_number` | `GET` | `/bank/resolve` | Resolve Account Number |
| `validate_account_number` | `POST` | `/bank/validate` | Validate Bank Account |

---

## `list`

**HTTP:** `GET`
**Path:** `/bank`

```ruby
paystack.bank.list({ ... })
```

### Query Fields

| Name | Required |
|---|---|
| `country` | false |
| `currency` | false |
| `use_cursor` | false |
| `perPage` | false |
| `page` | false |
| `next` | false |
| `previous` | false |
| `pay_with_bank_transfer` | false |
| `pay_with_bank` | false |
| `enabled_for_verification` | false |
| `gateway` | false |
| `type` | false |
| `include_nip_sort_code` | false |

## `resolve_account_number`

**HTTP:** `GET`
**Path:** `/bank/resolve`

```ruby
paystack.bank.resolve_account_number({ ... })
```

### Query Fields

| Name | Required |
|---|---|
| `account_number` | false |
| `bank_code` | false |

## `validate_account_number`

**HTTP:** `POST`
**Path:** `/bank/validate`

```ruby
paystack.bank.validate_account_number({ ... })
```

### Body Fields

| Name | Required |
|---|---|
| `account_name` | true |
| `account_number` | true |
| `account_type` | true |
| `bank_code` | true |
| `country_code` | true |
| `document_type` | true |
| `document_number` | false |
Loading
Loading