omise_test_cards 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 142365489132a7bfe80d98471f402936cfc549ef
4
+ data.tar.gz: 7ffb29e7798f2940f414c3016ba105121488eda6
5
+ SHA512:
6
+ metadata.gz: ac43113ded57339ff61be1ab76180b9decee3e868e6e1e6d0e498bba21f33f7dffe419718fd0da8dee7837caed3bc498352b2c226c150570af86a09e737346d6
7
+ data.tar.gz: 49f553bb4a32c4478ac4bb3901121a6b23fa34c225bd5adc402fbe45ab74587bcdd54110cb9f186454710f49acb306648ce2882c4d8adf785775a39b5e7b4866
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.14.5
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at akira@omise.co. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omise_test_cards.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 akinrt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # OmiseTestCards
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'omise_test_cards'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omise_test_cards
18
+
19
+ ## Usage
20
+
21
+ You can get omise test cards collection set of an instance of Hashie::Mash by `OmiseTestCards.test_cards` .
22
+
23
+ Regarding to omise website [Tests](https://www.omise.co/api-testing) , there are 10 types of test card set by now( 2017-03-10 16:36:25 +0900 ) .
24
+
25
+ ```ruby
26
+ cards = OmiseTestCards.test_cards
27
+
28
+ cards.successful_charge
29
+ cards.invalid_security_code
30
+ cards.fail_3ds_card_enrollment
31
+ cards.fail_3ds_card_validation
32
+ cards.insufficient_fund
33
+ cards.stolen_or_lost_card
34
+ cards.failed_processing
35
+ cards.payment_rejected
36
+ cards.failed_fraud_check
37
+ cards.invalid_account_number
38
+ ```
39
+
40
+ See how to refer successful charge test cards below.
41
+
42
+ ```ruby
43
+ cards = OmiseTestCards.test_cards
44
+
45
+ cards.successful_charge.code
46
+ # => successful_charge
47
+
48
+ cards.successful_charge.description
49
+ # => "these credit card numbers can be used in test mode"
50
+
51
+ cards.successful_charge.cards
52
+ # => <Hashie::Array [#<Hashie::Mash brand="Visa" number="4242424242424242">, #<Hashie::Mash brand="Visa" number="4111111111111111">, #<Hashie::Mash brand="MasterCard" number="5555555555554444">, #<Hashie::Mash brand="MasterCard" number="5454545454545454">, #<Hashie::Mash brand="JCB" number="3530111333300000">, #<Hashie::Mash brand="JCB" number="3566111111111113">]>
53
+
54
+ cards.successful_charge.cards.first.brand
55
+ # => Visa
56
+
57
+ cards.successful_charge.cards.first.number
58
+ # => 4242424242424242
59
+ ```
60
+
61
+ ## Quick Start
62
+
63
+ This is a simple way to test charge on test mode.
64
+
65
+ ```ruby
66
+ require "omise"
67
+ require "omise_test_cards"
68
+
69
+ Omise.api_key = "SET_YOUR_TEST_SECRET_KEY"
70
+ Omise.vault_key = "SET_YOUR_TEST_PUBLIC_KEY"
71
+
72
+ # get sampla card
73
+ sampel_card = OmiseTestCards.test_cards.successful_charge.cards.first
74
+
75
+ begin
76
+ # create token
77
+ token = Omise::Token.create(card: {
78
+ name: "TARO OMISE",
79
+ number: sampel_card.number,
80
+ expiration_month: 3,
81
+ expiration_year: 2019,
82
+ city: "Tokyo",
83
+ postal_code: "1510051",
84
+ security_code: 123
85
+ })
86
+
87
+ # Charge 100000 JPY
88
+ charge = Omise::Charge.create({
89
+ amount: 100_000,
90
+ currency: "jpy",
91
+ card: token.id
92
+ })
93
+
94
+ if charge.paid
95
+ # handle success
96
+ puts "thanks"
97
+ else
98
+ # handle failure
99
+ raise charge.failure_code
100
+ end
101
+ rescue OmiseError => e
102
+ # handle OmiseError raised by omise library
103
+ raise e.message
104
+ end
105
+ ```
106
+
107
+
108
+ ## Development
109
+
110
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
111
+
112
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
113
+
114
+ ## Contributing
115
+
116
+ Bug reports and pull requests are welcome on GitHub at https://github.com/akinrt/omise_test_cards. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
117
+
118
+
119
+ ## License
120
+
121
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omise_test_cards"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,109 @@
1
+ module OmiseTestCards
2
+ class Cards
3
+ attr_reader :test_cards
4
+
5
+ def initialize
6
+ @test_cards ||= Hashie::Mash.new(hash_cards)
7
+ end
8
+
9
+ private
10
+
11
+ def hash_cards
12
+ {
13
+ successful_charge: {
14
+ code: "successful_charge",
15
+ description: "these credit card numbers can be used in test mode",
16
+ cards: [
17
+ { brand: "Visa", number: "4242424242424242" },
18
+ { brand: "Visa", number: "4111111111111111" },
19
+ { brand: "MasterCard", number: "5555555555554444" },
20
+ { brand: "MasterCard", number: "5454545454545454" },
21
+ { brand: "JCB", number: "3530111333300000" },
22
+ { brand: "JCB", number: "3566111111111113" },
23
+ ],
24
+ },
25
+ invalid_security_code: {
26
+ code: "invalid_security_code",
27
+ description: "charge will fail with the invalid_security_code failure code. Additionaly the security_code_check attribute on the card object will be set to false",
28
+ cards: [
29
+ { brand: "Visa", number: "4111111111160001" },
30
+ { brand: "Mastercard", number: "5555551111130001" },
31
+ { brand: "JCB", number: "3530111111110001" },
32
+ ],
33
+ },
34
+ fail_3ds_card_enrollment: {
35
+ code: "payment_rejected",
36
+ description: "charge will fail with the payment_rejected failure code because the card could not be enrolled with 3DS",
37
+ cards: [
38
+ { brand: "Visa", number: "4111111111150002" },
39
+ { brand: "Mastercard", number: "5555551111120002" },
40
+ { brand: "JCB", number: "3530111111100002" },
41
+ ],
42
+ },
43
+ fail_3ds_card_validation: {
44
+ code: "payment_rejected",
45
+ description: "charge will fail with the payment_rejected failure code because the card could not be validated with 3DS",
46
+ cards: [
47
+ { brand: "Visa", number: "4111111111140003" },
48
+ { brand: "Mastercard", number: "5555551111110003" },
49
+ { brand: "JCB", number: "3530111111190003" },
50
+ ],
51
+ },
52
+ insufficient_fund: {
53
+ code: "insufficient_fund",
54
+ description: "charge will fail with the insufficient_fund failure code",
55
+ cards: [
56
+ { brand: "Visa", number: "4111111111140011" },
57
+ { brand: "Mastercard", number: "5555551111110011" },
58
+ { brand: "JCB", number: "3530111111190011" },
59
+ ],
60
+ },
61
+ stolen_or_lost_card: {
62
+ code: "stolen_or_lost_card",
63
+ description: "charge will fail with stolen_or_lost_card failure code",
64
+ cards: [
65
+ { brand: "Visa", number: "4111111111130012" },
66
+ { brand: "Mastercard", number: "5555551111100012" },
67
+ { brand: "JCB", number: "3530111111180012" },
68
+ ],
69
+ },
70
+ failed_processing: {
71
+ code: "failed_processing",
72
+ description: "charge will fail with the failed_processing failure code",
73
+ cards: [
74
+ { brand: "Visa", number: "4111111111120013" },
75
+ { brand: "Mastercard", number: "5555551111190013" },
76
+ { brand: "JCB", number: "3530111111170013" },
77
+ ],
78
+ },
79
+ payment_rejected: {
80
+ code: "payment_rejected",
81
+ description: "charge will fail with the payment_rejected failure code",
82
+ cards: [
83
+ { brand: "Visa", number: "4111111111110014" },
84
+ { brand: "Mastercard", number: "5555551111180014" },
85
+ { brand: "JCB", number: "3530111111160014" },
86
+ ],
87
+ },
88
+ failed_fraud_check: {
89
+ code: "failed_fraud_check",
90
+ description: "charge will fail with failed_fraud_check failure code",
91
+ cards: [
92
+ { brand: "Visa", number: "4111111111190016" },
93
+ { brand: "Mastercard", number: "5555551111160016" },
94
+ { brand: "JCB", number: "3530111111140016" },
95
+ ],
96
+ },
97
+ invalid_account_number: {
98
+ code: "invalid_account_number",
99
+ description: "charge will fail with invalid_account_number failure code",
100
+ cards: [
101
+ { brand: "Visa", number: "4111111111180017" },
102
+ { brand: "Mastercard", number: "5555551111150017" },
103
+ { brand: "JCB", number: "3530111111130017" },
104
+ ],
105
+ },
106
+ }
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,3 @@
1
+ module OmiseTestCards
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,18 @@
1
+ #! ruby -I ./
2
+ require "hashie"
3
+ require "omise_test_cards/version"
4
+ require "omise_test_cards/cards"
5
+
6
+ module OmiseTestCards
7
+ def self.test_cards
8
+ @test_cards ||= Cards.new.test_cards
9
+ end
10
+
11
+ def self.define_test_cards_to_omise
12
+ if Object.const_defined?(:Omise)
13
+ Omise.define_singleton_method(:test_cards) { @test_cards ||= Cards.new.test_cards }
14
+ else
15
+ puts "you need to require 'omise' then try it again"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "omise_test_cards/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omise_test_cards"
8
+ spec.version = OmiseTestCards::VERSION
9
+ spec.authors = ["akinrt"]
10
+ spec.email = ["aki.d.sc@gmail.com"]
11
+ spec.summary = %q{Omise test cards for omise api in test mode.}
12
+ spec.description = %q{A set of common test cards for omise api in test mode.}
13
+ spec.homepage = "https://github.com/akinrt/omise_test_cards"
14
+ spec.license = "MIT"
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_runtime_dependency "hashie", "~> 3.5.5"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.14"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omise_test_cards
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - akinrt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hashie
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.5.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.5.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: A set of common test cards for omise api in test mode.
70
+ email:
71
+ - aki.d.sc@gmail.com
72
+ executables:
73
+ - console
74
+ - setup
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - CODE_OF_CONDUCT.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - lib/omise_test_cards.rb
89
+ - lib/omise_test_cards/cards.rb
90
+ - lib/omise_test_cards/version.rb
91
+ - omise_test_cards.gemspec
92
+ homepage: https://github.com/akinrt/omise_test_cards
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.5.1
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Omise test cards for omise api in test mode.
116
+ test_files: []