Skip to content

About

MockCard SDK for Ruby: run payment webhook chaos tests in CI (duplicate, late, missing and 3DS-abandoned webhooks), assert outcomes in Minitest or RSpec, and guard production against monitoring probes.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mockcard (Ruby)

Payment failure testing for Ruby. Run MockCard's chaos scenarios against your webhook handler in CI, assert what your app did, and guard production against MockCard's monitoring probes. Standard library only. Rails apps: add mockcard-rails for the middleware, credentials and generator.

Author: Arixeva Labs hello@arixevalabs.com · mockcard.io · MIT

gem "mockcard", group: :test

Chaos run (Minitest or RSpec)

include MockCard::Assertions

run = MockCard::Runner.run_chaos(MockCard::Client.new,
  project_id: "prj_…", target: "http://127.0.0.1:3000/webhooks/stripe",
  assertions: { "duplicate" => { "order fulfilled once" => ->(_ctx) { Order.paid.count == 1 } } })
assert_chaos_run_passed(run)

Works with the Pay gem: point target at Pay's webhook route.

Production probe guard

if MockCard::Probe.probe?(request.headers) && MockCard::Probe.verify(request.headers, request.raw_post, ENV["MOCKCARD_PROBE_SECRET"])
  response.set_header(MockCard::Probe::ACK_HEADER, "skipped")
  return head :ok
end

API reference: https://www.mockcard.io/openapi.yaml

About

MockCard SDK for Ruby: run payment webhook chaos tests in CI (duplicate, late, missing and 3DS-abandoned webhooks), assert outcomes in Minitest or RSpec, and guard production against monitoring probes.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages