The paystack_sdk gem provides a simple and intuitive interface for interacting with Paystack's payment gateway API. It allows developers to easily integrate Paystack's payment processing features into their Ruby applications. With support for various endpoints, this SDK simplifies tasks such as initiating transactions, verifying payments, managing customers, and more.
Add this line to your application's Gemfile:
gem 'paystack_sdk'And then execute:
bundle installOr install it yourself as:
gem install paystack_sdkHere’s a basic example of how to use the paystack_sdk gem:
require 'paystack_sdk' # Initialize the SDK with your Paystack secret key paystack = PaystackSdk::Client.new(secret_key: "sk_test_xxx") # Example: Initialize a payment params = {email: "customer@email.com", amount: "2300", currency: "USD"} response = paystack.transactions.initiate(params) if response.success? puts response.authorization_url else puts resposne.error_message end # Example: Verify a payment response = paystack.transactions.verify(reference: "transaction_reference") if response.success? puts "Payment verified successfully!" else puts "Payment verification failed: #{response.error_message}" endThere will be times you may need access to the original API response. For such cases, you can use the #original_response method on the response object.
The return value is a hash with all the values from the HTTP request. This could be useful when you need to debug or gain access to the response its raw state.
For example
response = transaction.list puts response.original_response # => This will return the exact response received from PaystackRefer to the documentation for more detailed usage examples and supported endpoints.
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run:
bundle exec rake installTo release a new version, update the version number in version.rb, and then run:
bundle exec rake releaseThis will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/nanafox/paystack_sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the PaystackSdk project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the code of conduct.