worldpay_cnp 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89bf5fce70ba0dbff1493a07c9c63a9619a17a633b64bf163681b0fd002ec942
4
- data.tar.gz: 74fa0c70f00a2df9a223e3f4644caab533cdb2efb95ea7707a1e1cfda457bd20
3
+ metadata.gz: efe9c0d58a5d3ef6293c5268f0c24623d8213bdacacbf8819a80d01e3569dace
4
+ data.tar.gz: 350d10906becd6853f4c5b68d993442b420af7b787517ba6db35c149531d6664
5
5
  SHA512:
6
- metadata.gz: ed19a23c8647fed3ce365d80f5494ca66342b88bf4c6ab095ed2b44fe8f7290ba9f1c3b215614dd7bc8acbcd420795f5db5bebaf21a2dd560102c271e231fab9
7
- data.tar.gz: c8082c88313c40675b1ca1d6609b00a18e0153defd5cdb8c948db9b955f9a2b458d90f92110d06203a9b67b88f51b200cb7f1e3bdbbf3bd911ea6035d09e8422
6
+ metadata.gz: f3406a6b4b3f57d754b41df7fd02f2f67904daef33a4ef1a74a5753cf72d7d4f0e8449fb4e0a0a5acfdf66efc0eaa3c179daa5394845d74ca73f4f4bc77120b2
7
+ data.tar.gz: bd64252e528e89ce2d070df15a6f5fb7259f6e93a9d32af52576e1eca7ef72cba516fc54a35f53d98513d9a2537232b63c500d8547bd6213a2bf0e2bc17a934a
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # WorldpayCnp Ruby gem
2
2
 
3
- ![Test Suite](https://github.com/jackpocket/worldpay-cnp/workflows/Test%20Suite/badge.svg)
3
+ [![Gem Version](https://badge.fury.io/rb/worldpay_cnp.svg)][gem]
4
+ ![Test Suite](https://github.com/jackpocket/worldpay-cnp/workflows/Tests/badge.svg)
4
5
 
5
- A Ruby library for the Worldpay cnpAPI with a simple interface for creating transactions as a Ruby hash to XML and back. So no real request objects. Since the cnpAPI uses camelCase, this library will handle converting to and from snake_case for you. While Worldpay has an official [CnpOnline Ruby SDK](https://github.com/Vantiv/cnp-sdk-for-ruby), they no longer support it.
6
+ A Ruby library for the Worldpay cnpAPI with a simple interface for creating transactions as a Ruby hash to XML and back. So no real request objects. Since the cnpAPI uses `camelCase`, this converts to and from `snake_case` for you. While Worldpay has an official [CnpOnline Ruby SDK](https://github.com/Vantiv/cnp-sdk-for-ruby), they no longer support it.
6
7
 
7
8
  ## Installation
8
9
 
@@ -64,7 +65,7 @@ client.create_transaction(
64
65
  sale: {
65
66
  "@id": "123",
66
67
  "@report_group": "Default Report Group",
67
- order_id: "456"
68
+ order_id: "456",
68
69
  amount: "1000",
69
70
  order_source: "ecommerce",
70
71
  card: {
@@ -117,3 +118,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
117
118
  ## Code of Conduct
118
119
 
119
120
  Everyone interacting in the WorldpayCnp project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jackpocket/worldpay_cnp/blob/master/CODE_OF_CONDUCT.md).
121
+
122
+ [gem]: https://rubygems.org/gems/worldpay_cnp
@@ -1,3 +1,3 @@
1
1
  module WorldpayCnp
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -26,16 +26,16 @@ module WorldpayCnp
26
26
  include XML::Serializer
27
27
 
28
28
  def call(hash)
29
- ::Nokogiri::XML::Document.new.tap { |d| add_xml_elements!(d, hash) }.to_s
29
+ ::Nokogiri::XML::Document.new.tap { |d| add_xml_elements!(d, nil, hash) }.to_s
30
30
  end
31
31
 
32
32
  private
33
33
 
34
- def attributes_or_elements!(parent, key, value)
34
+ def attributes_or_elements!(document, parent, key, value)
35
35
  return parent[attribute_name(key)] = text_with(value) if attribute?(key)
36
- element = ::Nokogiri::XML::Element.new(key.to_s, parent)
36
+ element = ::Nokogiri::XML::Element.new(key.to_s, document)
37
37
  parent.add_child(element)
38
- add_xml_elements!(element, value)
38
+ add_xml_elements!(document, element, value)
39
39
  end
40
40
 
41
41
  def insert_text!(element, text)
@@ -7,7 +7,7 @@ module WorldpayCnp
7
7
 
8
8
  private
9
9
 
10
- def attributes_or_elements!(parent, key, value)
10
+ def attributes_or_elements!(document, parent, key, value)
11
11
  raise NotImplementedError
12
12
  end
13
13
 
@@ -15,12 +15,13 @@ module WorldpayCnp
15
15
  raise NotImplementedError
16
16
  end
17
17
 
18
- def add_xml_elements!(parent, obj)
18
+ def add_xml_elements!(document, parent, obj)
19
+ parent = document if parent.nil?
19
20
  case obj
20
21
  when Hash
21
- obj.each { |key, value| attributes_or_elements!(parent, key, value) }
22
+ obj.each { |key, value| attributes_or_elements!(document, parent, key, value) }
22
23
  when Array
23
- obj.each { |value| add_xml_elements!(parent, value) }
24
+ obj.each { |value| add_xml_elements!(document, parent, value) }
24
25
  else
25
26
  insert_text!(parent, obj)
26
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worldpay_cnp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Julio
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-30 00:00:00.000000000 Z
11
+ date: 2024-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5'
22
+ version: '6'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5'
32
+ version: '6'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: nokogiri
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -44,26 +44,15 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.0'
47
- description: A modern Ruby interface to the Worldpay cnpAPI.
47
+ description: A modern and simple Ruby interface to the Worldpay cnpAPI.
48
48
  email:
49
49
  - javier@jackpocket.com
50
50
  executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
- - ".env.sample"
55
- - ".github/workflows/ci.yml"
56
- - ".gitignore"
57
- - ".rspec"
58
- - CHANGELOG.md
59
- - CODE_OF_CONDUCT.md
60
- - Gemfile
61
- - Gemfile.lock
62
54
  - LICENSE.txt
63
55
  - README.md
64
- - Rakefile
65
- - bin/console
66
- - bin/setup
67
56
  - lib/worldpay_cnp.rb
68
57
  - lib/worldpay_cnp/api_client.rb
69
58
  - lib/worldpay_cnp/client.rb
@@ -78,7 +67,6 @@ files:
78
67
  - lib/worldpay_cnp/xml/nokogiri.rb
79
68
  - lib/worldpay_cnp/xml/parser.rb
80
69
  - lib/worldpay_cnp/xml/serializer.rb
81
- - worldpay-cnp.gemspec
82
70
  homepage: https://github.com/jackpocket/worldpay-cnp
83
71
  licenses:
84
72
  - MIT
@@ -86,7 +74,7 @@ metadata:
86
74
  homepage_uri: https://github.com/jackpocket/worldpay-cnp
87
75
  source_code_uri: https://github.com/jackpocket/worldpay-cnp
88
76
  changelog_uri: https://github.com/jackpocket/worldpay-cnp/blob/master/CHANGELOG.md
89
- post_install_message:
77
+ post_install_message:
90
78
  rdoc_options: []
91
79
  require_paths:
92
80
  - lib
@@ -94,15 +82,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
82
  requirements:
95
83
  - - ">="
96
84
  - !ruby/object:Gem::Version
97
- version: 2.5.0
85
+ version: '0'
98
86
  required_rubygems_version: !ruby/object:Gem::Requirement
99
87
  requirements:
100
88
  - - ">="
101
89
  - !ruby/object:Gem::Version
102
90
  version: '0'
103
91
  requirements: []
104
- rubygems_version: 3.1.4
105
- signing_key:
92
+ rubygems_version: 3.5.11
93
+ signing_key:
106
94
  specification_version: 4
107
95
  summary: A modern Ruby interface to the Worldpay cnpAPI.
108
96
  test_files: []
data/.env.sample DELETED
@@ -1,3 +0,0 @@
1
- USERNAME="YOUR_API_USERNAME"
2
- PASSWORD="YOUR_API_PASSWORD"
3
- MERCHANT_ID="YOUR_MERCHANT_ID"
@@ -1,49 +0,0 @@
1
- name: Test Suite
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- build:
11
- runs-on: ubuntu-latest
12
- strategy:
13
- matrix:
14
- ruby: [ '2.5', '2.6', '2.7' ]
15
- name: Ruby ${{ matrix.ruby }}
16
- steps:
17
- - uses: actions/checkout@v2
18
-
19
- - uses: actions/setup-ruby@v1
20
- with:
21
- ruby-version: ${{ matrix.ruby }}
22
-
23
- - uses: actions/cache@v2
24
- with:
25
- path: vendor/bundle
26
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
27
- restore-keys: |
28
- ${{ runner.os }}-gems-
29
-
30
- - name: Install rubygems
31
- run: |
32
- gem update --system --no-document
33
-
34
- - name: Install bundler
35
- run: |
36
- gem install bundler --no-document
37
-
38
- - name: Install dependencies
39
- run: |
40
- bundle config path vendor/bundle
41
- bundle install --jobs 4 --retry 3
42
-
43
- - name: Run Tests
44
- env:
45
- USERNAME: test
46
- PASSWORD: test
47
- MERCHANT_ID: test
48
- run: |
49
- bundle exec rspec
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- .env
14
- Notes.rb
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/CHANGELOG.md DELETED
@@ -1,9 +0,0 @@
1
- # Changelog
2
-
3
- ## Unreleased
4
-
5
- ...
6
-
7
- ## 0.1.0 (2020-10-30)
8
-
9
- * Initial release of worldpay_cnp gem
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
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 jjfutbol@gmail.com. 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 [https://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in worldpay_cnp.gemspec
4
- gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
- gem "dotenv"
9
- gem "vcr"
10
- gem "webmock"
data/Gemfile.lock DELETED
@@ -1,72 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- worldpay_cnp (0.1.0)
5
- http (>= 4, < 5)
6
- nokogiri (~> 1.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.7.0)
12
- public_suffix (>= 2.0.2, < 5.0)
13
- crack (0.4.4)
14
- diff-lcs (1.4.4)
15
- domain_name (0.5.20190701)
16
- unf (>= 0.0.5, < 1.0.0)
17
- dotenv (2.7.6)
18
- ffi (1.13.1)
19
- ffi-compiler (1.0.1)
20
- ffi (>= 1.0.0)
21
- rake
22
- hashdiff (1.0.1)
23
- http (4.4.1)
24
- addressable (~> 2.3)
25
- http-cookie (~> 1.0)
26
- http-form_data (~> 2.2)
27
- http-parser (~> 1.2.0)
28
- http-cookie (1.0.3)
29
- domain_name (~> 0.5)
30
- http-form_data (2.3.0)
31
- http-parser (1.2.1)
32
- ffi-compiler (>= 1.0, < 2.0)
33
- mini_portile2 (2.4.0)
34
- nokogiri (1.10.10)
35
- mini_portile2 (~> 2.4.0)
36
- public_suffix (4.0.6)
37
- rake (12.3.3)
38
- rspec (3.9.0)
39
- rspec-core (~> 3.9.0)
40
- rspec-expectations (~> 3.9.0)
41
- rspec-mocks (~> 3.9.0)
42
- rspec-core (3.9.3)
43
- rspec-support (~> 3.9.3)
44
- rspec-expectations (3.9.2)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.9.0)
47
- rspec-mocks (3.9.1)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.9.0)
50
- rspec-support (3.9.3)
51
- unf (0.1.4)
52
- unf_ext
53
- unf_ext (0.0.7.7)
54
- vcr (6.0.0)
55
- webmock (3.9.3)
56
- addressable (>= 2.3.6)
57
- crack (>= 0.3.2)
58
- hashdiff (>= 0.4.0, < 2.0.0)
59
-
60
- PLATFORMS
61
- ruby
62
-
63
- DEPENDENCIES
64
- dotenv
65
- rake (~> 12.0)
66
- rspec (~> 3.0)
67
- vcr
68
- webmock
69
- worldpay_cnp!
70
-
71
- BUNDLED WITH
72
- 2.1.4
data/Rakefile DELETED
@@ -1,6 +0,0 @@
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 DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "dotenv/load"
5
- require "worldpay_cnp"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- def authenticated_client(**options)
11
- WorldpayCnp::Client.new(
12
- username: ENV["USERNAME"],
13
- password: ENV["PASSWORD"],
14
- merchant_id: ENV["MERCHANT_ID"],
15
- environment: :prelive,
16
- **options
17
- )
18
- end
19
-
20
- def sandbox_client(**options)
21
- WorldpayCnp::Client.new(environment: :sandbox, **options)
22
- end
23
-
24
- # (If you use this, don't forget to add pry to your Gemfile!)
25
- # require "pry"
26
- # Pry.start
27
-
28
- require "irb"
29
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- read -r -p 'Do you have a Worldpay Prelive account? (y/n) ' has_account
8
-
9
- if [[ "$has_account" =~ ^(No|no|N|n)$ ]]; then
10
- echo "Then you'll need to get credentials first or rely on"
11
- echo "the sandbox environment. No account or auth required."
12
- exit 0
13
- fi
14
-
15
- echo "Enter your Prelive credentials below."
16
- read -p 'API Username: ' username
17
- read -p 'API Password: ' password
18
- read -p 'Merchant Id: ' merchant_id
19
-
20
- cp .env.sample .env
21
-
22
- sed -i '' -e "s/YOUR_API_USERNAME/$username/g" .env
23
- sed -i '' -e "s/YOUR_API_PASSWORD/$password/g" .env
24
- sed -i '' -e "s/YOUR_MERCHANT_ID/$merchant_id/g" .env
25
-
26
- echo "Done."
data/worldpay-cnp.gemspec DELETED
@@ -1,30 +0,0 @@
1
- require_relative 'lib/worldpay_cnp/version'
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "worldpay_cnp"
5
- spec.version = WorldpayCnp::VERSION
6
- spec.authors = ["Javier Julio"]
7
- spec.email = ["javier@jackpocket.com"]
8
-
9
- spec.summary = "A modern Ruby interface to the Worldpay cnpAPI."
10
- spec.description = "A modern Ruby interface to the Worldpay cnpAPI."
11
- spec.homepage = "https://github.com/jackpocket/worldpay-cnp"
12
- spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
14
-
15
- spec.add_dependency "http", '>= 4', '< 5'
16
- spec.add_dependency "nokogiri", '~> 1.0'
17
-
18
- spec.metadata["homepage_uri"] = spec.homepage
19
- spec.metadata["source_code_uri"] = spec.homepage
20
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
21
-
22
- # Specify which files should be added to the gem when it is released.
23
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
- end
27
- spec.bindir = "exe"
28
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ["lib"]
30
- end