explaingit

activemerchant/active_merchant

4,595RubyAudience · developerComplexity · 3/5Setup · moderate

TLDR

A Ruby library that lets your web app accept payments through 100+ payment processors, Stripe, Braintree, Authorize.Net, and more, using one consistent interface so you never rewrite payment code when switching providers.

Mindmap

mindmap
  root((Active Merchant))
    What it does
      Payment processing
      Gateway abstraction
      Refunds and voids
    Supported gateways
      Stripe
      Braintree
      100 plus others
    Tech stack
      Ruby
      Ruby on Rails
      RubyGems
    Audience
      Rails developers
      E-commerce teams
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Charge a credit card through Stripe or Authorize.Net with the same code, and switch providers without rewriting your payment logic.

USE CASE 2

Add refund, void, and stored-card features to a Ruby on Rails e-commerce app.

USE CASE 3

Integrate multiple payment gateways in one app to offer regional payment options across North America, Europe, and Asia-Pacific.

Tech stack

RubyRuby on RailsRubyGems

Getting it running

Difficulty · moderate Time to first run · 30min

Requires API credentials (keys or login/password) for each payment gateway you want to connect to, use sandbox credentials for testing.

In plain English

Active Merchant is a Ruby library that lets web applications accept payments through dozens of different payment processors using a single consistent programming interface. It was originally built by Shopify to handle their own payment needs and later released as an open-source project. Instead of writing separate integration code for every payment gateway a business might want to accept, Active Merchant provides one common interface and handles the differences between providers internally. The idea behind the library is that charging a credit card, storing a card for later, voiding a transaction, or issuing a refund should look like the same code regardless of whether the underlying processor is Stripe, Authorize.Net, Braintree, Adyen, or any of the more than one hundred other gateways the library supports. Developers write code once and can switch providers or add new ones without rewriting the payment logic throughout their application. The library works with standard Ruby applications and integrates naturally with Ruby on Rails web projects. Installation is done through RubyGems, the standard Ruby package manager, with a single command or by adding a line to a project's dependency file. The README includes a short working example showing how to charge a credit card using test credentials, going from creating a card object with the cardholder details to submitting a purchase and reading back whether it succeeded. Active Merchant has been in continuous production use since 2006. It is currently maintained by teams at Shopify and Spreedly. The list of supported gateways spans processors in North America, Europe, Asia-Pacific, Latin America, and beyond, with each gateway's supported countries listed alongside it. A feature comparison table in the project wiki shows which operations each gateway supports. The library handles amounts as whole integers in the currency's smallest unit, so dollars are passed as cents. Card validation, including automatic card type detection, is built in. The README points to a getting-started guide and full API documentation for deeper reference.

Copy-paste prompts

Prompt 1
Using Active Merchant in a Ruby on Rails app, write the code to charge a credit card $49.99 through Stripe, handle the response, and store whether the transaction succeeded.
Prompt 2
Show me how to implement a refund flow with Active Merchant, given a transaction ID, issue a full refund and check if it succeeded.
Prompt 3
How do I switch my Rails app's payment processor from Authorize.Net to Braintree using Active Merchant without changing my controller code?
Prompt 4
Write an Active Merchant integration that stores a card token for repeat billing and charges it on a recurring schedule.
Prompt 5
Set up Active Merchant in a plain Ruby script (no Rails) to test a card purchase against a sandbox gateway, include the Gemfile entry and a working example.
Open on GitHub → Explain another repo

← activemerchant on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.