No release in over 3 years
Rails Payment Sandbox helps developers test payment flows locally without hitting real gateways. It simulates Stripe, Razorpay, PayPal, and provides fake transactions with random statuses.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 3.12
 Project Readme

RailsPaymentSandbox

Gem Version

RailsPaymentSandbox simulates multiple payment gateways locally with fake transactions for development and testing purposes. It saves developers from needing real API keys, sandbox accounts, or actual money movement when testing payment flows.


Features

  • ๐Ÿ”Œ Supports multiple gateways:
    • Stripe
    • Razorpay
    • PayPal
    • Paytm
    • Google Pay (GPay)
    • Apple Pay
    • PhonePe
    • Amazon Pay
    • Cashfree
  • ๐ŸŽฒ Random or controlled statuses: success, failed, pending
  • ๐Ÿงพ Generates fake transaction_id and order_id
  • ๐Ÿ›  No real API calls, safe for local and CI environments
  • ๐Ÿ“Š Easy integration with RSpec or Rails apps

Installation

Add this line to your Gemfile:

gem 'payment_sandbox_rails'

And then run:

bundle install

Or install it yourself:

gem install payment_sandbox_rails

Usage

require "rails_payment_sandbox"

# Create a new sandbox payment (random status)
payment = RailsPaymentSandbox::Gateway.new(
  gateway: :stripe,
  amount: 1000,          # amount in smallest unit (e.g. paise for INR)
  currency: "INR"
)

result = payment.process

puts result
# {
#   gateway: :stripe,
#   order_id: "ORD-1696212345-4821",
#   transaction_id: "STR-1696212345-4821",
#   amount: 1000,
#   currency: "INR",
#   status: :success,
#   message: "Stripe payment completed successfully"
# }

Force a Specific Status

payment = RailsPaymentSandbox::Gateway.new(
  gateway: :razorpay,
  amount: 500,
  status: :failed
)

puts payment.process
# => { gateway: :razorpay, status: :failed, message: "Razorpay payment failed", ... }

Provide a Custom Order ID

payment = RailsPaymentSandbox::Gateway.new(
  gateway: :paypal,
  amount: 1500,
  order_id: "ORD-TEST-12345"
)

puts payment.process[:order_id]
# => "ORD-TEST-12345"

Development

After checking out the repo, run:

bin/setup
rake spec

You can also run bin/console for an interactive prompt.

To install this gem onto your local machine:

bundle exec rake install

To release a new version:

  1. Update the version number in lib/rails_payment_sandbox/version.rb.
  2. Run bundle exec rake release (this will create a git tag, push commits/tags, and publish to rubygems.org).

Contributing

Bug reports and pull requests are welcome on GitHub: ๐Ÿ‘‰ https://github.com/[USERNAME]/rails_payment_sandbox


License

This project is licensed under the MIT License.