-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
192 changed files
with
18,499 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
STRIPE_TEST_SECRET_KEY=sk_test_eFvAvN5rz4GqAbsWxg63Jx79 | ||
STRIPE_TEST_OAUTH_ACCESS_TOKEN=sk_test_WnZmEBIHhMcDltNe98sqWN7z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
html/ | ||
pkg/ | ||
.DS_Store | ||
stripe-mock-server.pid | ||
Gemfile.lock | ||
stripe-mock-server.log | ||
.idea | ||
.ruby-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--colour --format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
sudo: required | ||
language: ruby | ||
rvm: | ||
- 2.4.6 | ||
- 2.5.5 | ||
- 2.6.3 | ||
- 2.7.0 | ||
before_install: | ||
- gem install bundler -v '< 2' | ||
before_script: | ||
- "sudo touch /var/log/stripe-mock-server.log" | ||
- "sudo chown travis /var/log/stripe-mock-server.log" | ||
script: "bundle exec rspec && bundle exec rspec -t live" | ||
|
||
env: | ||
global: | ||
- IS_TRAVIS=true STRIPE_TEST_SECRET_KEY_A=sk_test_BsztzqQjzd7lqkgo1LjEG5DF00KzH7tWKF STRIPE_TEST_SECRET_KEY_B=sk_test_rKCEu0x8jzg6cKPqoey8kUPQ00usQO3KYE STRIPE_TEST_SECRET_KEY_C=sk_test_qeaB7R6Ywp8sC9pzd1ZIABH700YLC7nhmZ STRIPE_TEST_SECRET_KEY_D=sk_test_r1NwHkUW7UyoozyP4aEBD6cs00CI5uDiGq | ||
|
||
notifications: | ||
webhooks: | ||
urls: | ||
- https://webhooks.gitter.im/e/44a1f4718ae2efb67eac | ||
on_success: change # options: [always|never|change] default: always | ||
on_failure: always # options: [always|never|change] default: always | ||
on_start: false # default: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
### Unreleased | ||
|
||
- [#806](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/806) - Remove `payment_method_types` from required arguments for `Stripe::Checkout::Session` | ||
- [#806](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/806) - Raise more helpful exception when Stripe::Price cannot be found within a `Stripe::Checkout::Session` `line_items` argument. | ||
|
||
|
||
### 3.1.0.rc3 (pre-release 2021-07-14) | ||
|
||
- [#785](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/785): `Stripe::Product` no longer requires `type`. [@TastyPi](https://github.com/TastyPi) | ||
- [#784](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/784): Fix "Wrong number of arguments" error in tests. [@TastyPi](https://github.com/TastyPi) | ||
- [#782](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/782): Support expanding `setup_intent` in `Stripe::Checkout::Session`. [@TastyPi](https://github.com/TastyPi) | ||
|
||
### 3.1.0.rc2 (pre-release 2021-03-03) | ||
|
||
- [#767](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/767): Fixes tests and more [@lpsBetty](https://github.com/lpsBetty) | ||
|
||
### 3.1.0.rc1 (pre-release 2021-02-17) | ||
|
||
- [#765](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/765): Properly set the status of a trialing subscription. [@csalvato](https://github.com/csalvato) | ||
- [#764](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/764): Fixes erroneous error message when fetching upcoming invoices. [@csalvato](https://github.com/csalvato) | ||
- [#762](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/762): Support Stripe Connect with Customers by adding stripe_account header namespace for customer object [@csalvato](https://github.com/csalvato) | ||
- [#755](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/755): Add allowed params to subscriptions [@dominikdarnel ](https://github.com/dominikdarnel) | ||
- [#748](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/758): Support Prices - [@hidenba](https://github.com/hidenba) and [@jamesprior](https://github.com/jamesprior). | ||
- [#747](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/747/files): Fix ruby 2.7 deprecation warnings. Adds Ruby 3.0.0 compatibility. [@coding-chimp](https://github.com/coding-chimp) | ||
- [#715](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/715): Added application_fee_amount to mock charge object - [@espen](https://github.com/espen) | ||
- [#709](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/709): Remove unnecessary check on customer's currency - [@coorasse](https://github.com/coorasse) | ||
|
||
### 3.0.1 (TBD) | ||
|
||
- Added Changelog file | ||
- [#640](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/640): Support Payment Intent status requires_capture - [@theodorton](https://github.com/theodorton). | ||
- [#685](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/685): Adds support for pending_invoice_item_interval - [@joshcass](https://github.com/joshcass). | ||
- [#682](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/682): Prevent customer metadata from being overwritten with each update - [@sethkrasnianski](https://github.com/sethkrasnianski). | ||
- [#679](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/679): Fix for [#678](https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues/678) Add active filter to Data::List - [@rnmp](https://github.com/rnmp). | ||
- [#668](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/668): Fix for [#665](https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues/665) Allow to remove discount from customer - [@mnin](https://github.com/mnin). | ||
- [#667](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/667): | ||
Remove empty and duplicated methods from payment methods - [@mnin](https://github.com/mnin). | ||
- [#664](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/664): Bugfix: pass through PaymentIntent amount to mocked Charge - [@typeoneerror](https://github.com/typeoneerror). | ||
- [#654](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/654): fix for [#626](https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues/626) Added missing decline codes - [@iCreateJB](https://github.com/iCreateJB). | ||
- [#648](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/648): Initial implementation of checkout session API - [@fauxparse](https://github.com/fauxparse). | ||
- [#644](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/644): Allow payment_behavior attribute on subscription create - [@j15e](https://github.com/j15e). | ||
|
||
### 3.0.0 (2019-12-17) | ||
|
||
##### the main thing is: | ||
|
||
- [#658](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/658) Make the gem compatible with Stripe Gem v.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
source 'https://rubygems.org' | ||
|
||
platforms :ruby_19 do | ||
gem 'mime-types', '~> 2.6' | ||
gem 'rest-client', '~> 1.8' | ||
end | ||
|
||
group :test do | ||
gem 'rake' | ||
gem 'dotenv' | ||
end | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2013 Gilbert | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# encoding: utf-8 | ||
|
||
require 'rubygems' | ||
require 'rake' | ||
|
||
begin | ||
gem 'rubygems-tasks', '~> 0.2' | ||
require 'rubygems/tasks' | ||
|
||
Gem::Tasks.new | ||
rescue LoadError => e | ||
warn e.message | ||
warn "Run `gem install rubygems-tasks` to install Gem::Tasks." | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env ruby | ||
|
||
lib = File.expand_path(File.dirname(__FILE__) + '/../lib') | ||
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib) | ||
|
||
require 'trollop' | ||
|
||
opts = Trollop::options do | ||
opt :port, "Listening port", :type => :int, :default => 4999 | ||
opt :host, "Host to listen on", :type => :string, :default => '0.0.0.0' | ||
opt :server, "Server to use", :type => :string, :default => 'thin' | ||
opt :debug, "Request and response output", :default => true | ||
opt :pid_path, "Location to put server pid file", :type => :string, :default => './stripe-mock-server.pid' | ||
end | ||
|
||
require 'stripe_mock' | ||
require 'stripe_mock/server' | ||
|
||
StripeMock::Server.start_new(opts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
require 'ostruct' | ||
require 'multi_json' | ||
require 'dante' | ||
require 'time' | ||
|
||
require 'stripe' | ||
|
||
require 'stripe_mock/version' | ||
require 'stripe_mock/util' | ||
require 'stripe_mock/error_queue' | ||
|
||
require 'stripe_mock/data' | ||
require 'stripe_mock/data/list' | ||
|
||
require 'stripe_mock/errors/stripe_mock_error' | ||
require 'stripe_mock/errors/unsupported_request_error' | ||
require 'stripe_mock/errors/uninitialized_instance_error' | ||
require 'stripe_mock/errors/unstarted_state_error' | ||
require 'stripe_mock/errors/server_timeout_error' | ||
require 'stripe_mock/errors/closed_client_connection_error' | ||
|
||
require 'stripe_mock/client' | ||
require 'stripe_mock/server' | ||
|
||
require 'stripe_mock/api/instance' | ||
require 'stripe_mock/api/client' | ||
require 'stripe_mock/api/server' | ||
|
||
require 'stripe_mock/api/bank_tokens' | ||
require 'stripe_mock/api/account_balance' | ||
require 'stripe_mock/api/conversion_rate' | ||
require 'stripe_mock/api/card_tokens' | ||
require 'stripe_mock/api/debug' | ||
require 'stripe_mock/api/errors' | ||
require 'stripe_mock/api/global_id_prefix' | ||
require 'stripe_mock/api/live' | ||
require 'stripe_mock/api/test_helpers' | ||
require 'stripe_mock/api/webhooks' | ||
|
||
require 'stripe_mock/request_handlers/helpers/bank_account_helpers.rb' | ||
require 'stripe_mock/request_handlers/helpers/external_account_helpers.rb' | ||
require 'stripe_mock/request_handlers/helpers/card_helpers.rb' | ||
require 'stripe_mock/request_handlers/helpers/charge_helpers.rb' | ||
require 'stripe_mock/request_handlers/helpers/coupon_helpers.rb' | ||
require 'stripe_mock/request_handlers/helpers/subscription_helpers.rb' | ||
require 'stripe_mock/request_handlers/helpers/token_helpers.rb' | ||
|
||
require 'stripe_mock/request_handlers/validators/param_validators.rb' | ||
|
||
require 'stripe_mock/request_handlers/account_links.rb' | ||
require 'stripe_mock/request_handlers/express_login_links.rb' | ||
require 'stripe_mock/request_handlers/accounts.rb' | ||
require 'stripe_mock/request_handlers/external_accounts.rb' | ||
require 'stripe_mock/request_handlers/balance.rb' | ||
require 'stripe_mock/request_handlers/balance_transactions.rb' | ||
require 'stripe_mock/request_handlers/charges.rb' | ||
require 'stripe_mock/request_handlers/cards.rb' | ||
require 'stripe_mock/request_handlers/sources.rb' | ||
require 'stripe_mock/request_handlers/customers.rb' | ||
require 'stripe_mock/request_handlers/coupons.rb' | ||
require 'stripe_mock/request_handlers/disputes.rb' | ||
require 'stripe_mock/request_handlers/events.rb' | ||
require 'stripe_mock/request_handlers/invoices.rb' | ||
require 'stripe_mock/request_handlers/invoice_items.rb' | ||
require 'stripe_mock/request_handlers/orders.rb' | ||
require 'stripe_mock/request_handlers/plans.rb' | ||
require 'stripe_mock/request_handlers/prices.rb' | ||
require 'stripe_mock/request_handlers/recipients.rb' | ||
require 'stripe_mock/request_handlers/refunds.rb' | ||
require 'stripe_mock/request_handlers/transfers.rb' | ||
require 'stripe_mock/request_handlers/payment_intents.rb' | ||
require 'stripe_mock/request_handlers/payment_methods.rb' | ||
require 'stripe_mock/request_handlers/setup_intents.rb' | ||
require 'stripe_mock/request_handlers/payouts.rb' | ||
require 'stripe_mock/request_handlers/subscriptions.rb' | ||
require 'stripe_mock/request_handlers/subscription_items.rb' | ||
require 'stripe_mock/request_handlers/tokens.rb' | ||
require 'stripe_mock/request_handlers/country_spec.rb' | ||
require 'stripe_mock/request_handlers/ephemeral_key.rb' | ||
require 'stripe_mock/request_handlers/products.rb' | ||
require 'stripe_mock/request_handlers/tax_rates.rb' | ||
require 'stripe_mock/request_handlers/checkout_session.rb' | ||
require 'stripe_mock/instance' | ||
|
||
require 'stripe_mock/test_strategies/base.rb' | ||
require 'stripe_mock/test_strategies/mock.rb' | ||
require 'stripe_mock/test_strategies/live.rb' | ||
|
||
module StripeMock | ||
|
||
@default_currency = 'usd' | ||
@checkout_base = "https://checkout.stripe.com/pay/" | ||
lib_dir = File.expand_path(File.dirname(__FILE__), '../..') | ||
@webhook_fixture_path = './spec/fixtures/stripe_webhooks/' | ||
@webhook_fixture_fallback_path = File.join(lib_dir, 'stripe_mock/webhook_fixtures') | ||
|
||
class << self | ||
attr_accessor :default_currency | ||
attr_accessor :checkout_base | ||
attr_accessor :webhook_fixture_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module StripeMock | ||
|
||
def self.set_account_balance(value) | ||
case @state | ||
when 'local' | ||
instance.account_balance = value | ||
when 'remote' | ||
client.set_account_balance(value) | ||
else | ||
raise UnstartedStateError | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module StripeMock | ||
|
||
def self.generate_bank_token(bank_params = {}) | ||
case @state | ||
when 'local' | ||
instance.generate_bank_token(bank_params) | ||
when 'remote' | ||
client.generate_bank_token(bank_params) | ||
else | ||
raise UnstartedStateError | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module StripeMock | ||
|
||
def self.generate_card_token(card_params = {}) | ||
case @state | ||
when 'local' | ||
instance.generate_card_token(card_params) | ||
when 'remote' | ||
client.generate_card_token(card_params) | ||
else | ||
raise UnstartedStateError | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module StripeMock | ||
|
||
def self.client | ||
@client | ||
end | ||
|
||
def self.start_client(port=4999) | ||
return false if @state == 'live' | ||
return @client unless @client.nil? | ||
|
||
Stripe::StripeClient.send(:define_method, :execute_request) { |*args, **keyword_args| StripeMock.redirect_to_mock_server(*args, **keyword_args) } | ||
@client = StripeMock::Client.new(port) | ||
@state = 'remote' | ||
@client | ||
end | ||
|
||
def self.stop_client(opts={}) | ||
return false unless @state == 'remote' | ||
@state = 'ready' | ||
|
||
restore_stripe_execute_request_method | ||
@client.clear_server_data if opts[:clear_server_data] == true | ||
@client.cleanup | ||
@client = nil | ||
true | ||
end | ||
|
||
private | ||
|
||
def self.redirect_to_mock_server(method, url, api_key: nil, api_base: nil, params: {}, headers: {}) | ||
handler = Instance.handler_for_method_url("#{method} #{url}") | ||
|
||
if mock_error = client.error_queue.error_for_handler_name(handler[:name]) | ||
client.error_queue.dequeue | ||
raise mock_error | ||
end | ||
|
||
Stripe::Util.symbolize_names client.mock_request(method, url, api_key: api_key, params: params, headers: headers) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module StripeMock | ||
|
||
def self.set_conversion_rate(value) | ||
case @state | ||
when 'local' | ||
instance.conversion_rate = value | ||
when 'remote' | ||
client.set_conversion_rate(value) | ||
else | ||
raise UnstartedStateError | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module StripeMock | ||
|
||
def self.toggle_debug(toggle) | ||
if @state == 'local' | ||
@instance.debug = toggle | ||
elsif @state == 'remote' | ||
@client.set_server_debug(toggle) | ||
end | ||
end | ||
|
||
end |
Oops, something went wrong.