Module: StripeMock

Defined in:
lib/stripe_mock.rb,
lib/stripe_mock/utils.rb,
lib/stripe_mock/version.rb,
lib/stripe_mock/webmock.rb,
lib/stripe_mock/failures.rb,
lib/stripe_mock/data/cards.rb,
lib/stripe_mock/data/tokens.rb,
lib/stripe_mock/data/charges.rb,
lib/stripe_mock/data/transfers.rb,
lib/stripe_mock/data/bank_account.rb,
lib/stripe_mock/credit_cards/cards.rb,
lib/stripe_mock/data/balance_transaction.rb

Defined Under Namespace

Modules: CreditCards, Data

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.capture_requestsObject



2
3
4
5
6
7
# File 'lib/stripe_mock/webmock.rb', line 2

def self.capture_requests
  require 'webmock'

  WebMock.allow_net_connect!
  WebMock::API.stub_request(:any, /https:\/\/api\.stripe\.com/).to_rack(MockedStripe)
end

.card_failuresObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/stripe_mock/failures.rb', line 7

def card_failures
  {
    incorrect_number: {
      message: "Your card number is incorrect.",
      code: 'incorrect_number',
      param: 'number',
      type: 'card_error'
    },
    invalid_number: {
      message: "This card number looks invalid.",
      code: 'invalid_number',
      param: 'number',
      type: 'card_error'
    },
    invalid_expiry_month: {
      message: "Your card's expiration month is invalid.",
      code: 'invalid_expiry_month',
      param: 'exp_month',
      type: 'card_error'
    },
    invalid_expiry_year: {
      message: "Your card's expiration year is invalid.",
      code: 'invalid_expiry_year',
      param: 'exp_year',
      type: 'card_error'
    },
    invalid_cvc: {
      message: "Your card's security code is invalid.",
      code: 'invalid_cvc',
      param: 'cvc',
      type: 'card_error'
    },
    expired_card_month: {
      message: "Your card's expiration month is invalid.",
      code: 'invalid_expiry_month',
      param: 'exp_month',
      type: 'card_error'
    },
    expired_card_year: {
      message: "Your card's expiration year is invalid.",
      code: 'invalid_expiry_year',
      param: 'exp_year',
      type: 'card_error'
    },
    incorrect_cvc: {
      message: "Your card's security code is incorrect.",
      code: 'incorrect_cvc',
      param: 'cvc',
      type: 'card_error',
      charge: 'ch_xxx'
    },
    incorrect_zip: {
      message: "The zip code you supplied failed validation.",
      code: 'incorrect_zip',
      param: 'address_zip',
      type: 'card_error',
      charge: 'ch_xxx'
    },
    card_declined: {
      message: "Your card was declined.",
      code: 'card_declined',
      type: 'card_error',
      charge: 'ch_xxx'
    },
    missing: {
      message: "Cannot charge a customer that has no active card",
      code: 'missing',
      param: 'card',
      type: 'card_error'
    },
    processing_error: {
      message: "An error occurred while processing your card. Try again in a little bit.",
      code: 'processing_error',
      type: 'card_error',
      charge: 'ch_xxx'
    }
  }
end

.new_id(prefix) ⇒ Object



2
3
4
# File 'lib/stripe_mock/utils.rb', line 2

def self.new_id(prefix)
  "#{ prefix }_#{ Faker::Internet.password(16) }"
end

.stop_capturingObject



9
10
11
# File 'lib/stripe_mock/webmock.rb', line 9

def self.stop_capturing
  WebMock.reset!
end

.transfer_failuresObject



3
4
5
# File 'lib/stripe_mock/failures.rb', line 3

def transfer_failures
  %w(insufficient_funds account_closed no_account invalid_account_number debit_not_authorized bank_ownership_changed account_frozen could_not_process bank_account_restricted invalid_currency)
end