securionpay 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ 2.2.4
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.5
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.11.2
6
+ script: "bundle exec rake test"
7
+ addons:
8
+ code_climate:
9
+ repo_token: 9e10e5375f827b391dd6360f98a949ff799ecfa0f0ab730ba590193116953842
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in securionpay-ruby.gemspec
4
+ gemspec
@@ -0,0 +1,113 @@
1
+ # SecurionPay ruby gem
2
+
3
+ [![Build Status](https://travis-ci.org/gwilczynski/securionpay-ruby.svg?branch=master)](https://travis-ci.org/gwilczynski/securionpay-ruby)
4
+ [![Code Climate](https://codeclimate.com/github/gwilczynski/securionpay-ruby/badges/gpa.svg)](https://codeclimate.com/github/gwilczynski/securionpay-ruby)
5
+ [![Test Coverage](https://codeclimate.com/github/gwilczynski/securionpay-ruby/badges/coverage.svg)](https://codeclimate.com/github/gwilczynski/securionpay-ruby/coverage)
6
+ [![Issue Count](https://codeclimate.com/github/gwilczynski/securionpay-ruby/badges/issue_count.svg)](https://codeclimate.com/github/gwilczynski/securionpay-ruby)
7
+ [![Dependency Status](https://gemnasium.com/badges/github.com/gwilczynski/securionpay-ruby.svg)](https://gemnasium.com/github.com/gwilczynski/securionpay-ruby)
8
+
9
+ If you don't already have SecurionPay account you can create it [here](https://securionpay.com/register).
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'securionpay'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install securionpay
26
+
27
+ ## Usage
28
+
29
+ Configuration:
30
+
31
+
32
+ ```ruby
33
+ SecurionPay::Configuration.private_key = 'private_key'
34
+ ```
35
+
36
+ If you want connect do different backent:
37
+
38
+ ```ruby
39
+ SecurionPay::Configuration.service_url = 'https://api.chuck.norris.com'
40
+ ```
41
+
42
+ ### Create a new Card
43
+ Creates a new card object.
44
+
45
+ ```ruby
46
+ customer_id = 'cust_id'
47
+ card = {
48
+ number: '4242424242424242',
49
+ expMonth: '11',
50
+ expYear: '2022',
51
+ cvc: '123',
52
+ cardholderName: 'John Doe',
53
+ }
54
+
55
+ SecurionPay::Cards.create(customer_id, card)
56
+ ```
57
+
58
+ ### Retrieve an existing Card
59
+
60
+ Retrieve an existing card object.
61
+
62
+ ```ruby
63
+ customer_id = 'cust_id'
64
+ card_id = 'card_id'
65
+
66
+ SecurionPay::Cards.retrieve(customer_id, card_id)
67
+ ```
68
+
69
+ ### Update an existing Card
70
+
71
+ Update an existing card object.
72
+
73
+ ```ruby
74
+ customer_id = 'cust_id'
75
+ card_id = 'card_id'
76
+ card = {
77
+ cardholderName: 'Mr Bean'
78
+ }
79
+ SecurionPay::Cards.update(customer_id, card_id, card)
80
+ ```
81
+
82
+ ### Delete a Card
83
+
84
+ Deletes an existing card object.
85
+
86
+ ```ruby
87
+ customer_id = 'cust_id'
88
+ card_id = 'card_id'
89
+ SecurionPay::Cards.delete(customer_id, card_id)
90
+ ```
91
+
92
+ ### List Cards
93
+
94
+ List card objects for given customer.
95
+
96
+ ```ruby
97
+ customer_id = 'cust_id'
98
+ SecurionPay::Cards.list(customer_id)
99
+ ```
100
+
101
+ ## Development
102
+
103
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
104
+
105
+ For mutation testing, run `mutant --include lib --require securionpay --use rspec SecurionPay*`
106
+
107
+ If you want to run integration tests: ``
108
+
109
+ 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).
110
+
111
+ ## Contributing
112
+
113
+ Bug reports and pull requests are welcome on GitHub at https://github.com/securionpay/securionpay-ruby
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "securionpay"
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
@@ -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,8 @@
1
+ require 'securionpay/cards'
2
+ require 'securionpay/communicator'
3
+ require 'securionpay/configuration'
4
+ require 'securionpay/version'
5
+ #
6
+ # SecurionPay start point
7
+ module SecurionPay
8
+ end
@@ -0,0 +1,13 @@
1
+ module SecurionPay
2
+ module Builders
3
+ class PathBuilder
4
+ def self.build_card_path(customer_id, card_id = nil)
5
+ if card_id
6
+ "/customers/#{customer_id}/cards/#{card_id}"
7
+ else
8
+ "/customers/#{customer_id}/cards"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,45 @@
1
+ require 'securionpay/communicator'
2
+ require 'securionpay/builders/path_builder'
3
+
4
+ module SecurionPay
5
+ class Cards
6
+ class << self
7
+ attr_accessor :communicator, :path_builder
8
+ end
9
+
10
+ @communicator = Communicator
11
+ @path_builder = Builders::PathBuilder
12
+
13
+ def self.create(customer_id, params)
14
+ communicator.post(
15
+ path_builder.build_card_path(customer_id),
16
+ params
17
+ )
18
+ end
19
+
20
+ def self.retrieve(customer_id, card_id)
21
+ communicator.get(
22
+ path_builder.build_card_path(customer_id, card_id)
23
+ )
24
+ end
25
+
26
+ def self.update(customer_id, card_id, params)
27
+ communicator.post(
28
+ path_builder.build_card_path(customer_id, card_id),
29
+ params
30
+ )
31
+ end
32
+
33
+ def self.delete(customer_id, card_id)
34
+ communicator.delete(
35
+ path_builder.build_card_path(customer_id, card_id)
36
+ )
37
+ end
38
+
39
+ def self.list(customer_id)
40
+ communicator.get(
41
+ path_builder.build_card_path(customer_id)
42
+ )
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,51 @@
1
+ require 'httparty'
2
+
3
+ module SecurionPay
4
+ class Communicator
5
+ class << self
6
+ attr_accessor :web_consumer
7
+ end
8
+
9
+ @web_consumer = HTTParty
10
+
11
+ def self.get(path)
12
+ web_consumer.get(
13
+ url(path),
14
+ request_body
15
+ )
16
+ end
17
+
18
+ def self.post(path, body)
19
+ web_consumer.post(
20
+ url(path),
21
+ request_body(body)
22
+ )
23
+ end
24
+
25
+ def self.delete(path)
26
+ web_consumer.delete(
27
+ url(path),
28
+ request_body
29
+ )
30
+ end
31
+
32
+ def self.url(path)
33
+ "#{Configuration.service_url}/#{path}"
34
+ end
35
+
36
+ def self.request_body(body = nil)
37
+ {
38
+ body: body,
39
+ basic_auth: basic_auth
40
+ }
41
+ end
42
+
43
+ def self.basic_auth
44
+ {
45
+ username: Configuration.private_key
46
+ }
47
+ end
48
+
49
+ private_class_method :url, :request_body, :basic_auth
50
+ end
51
+ end
@@ -0,0 +1,9 @@
1
+ module SecurionPay
2
+ class Configuration
3
+ class << self
4
+ attr_accessor :service_url, :private_key
5
+ end
6
+
7
+ @service_url = 'https://api.securionpay.com'.freeze
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module SecurionPay
2
+ VERSION = '0.3.0'.freeze
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'securionpay/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "securionpay"
8
+ spec.version = SecurionPay::VERSION
9
+ spec.authors = ["Grzegorz Wilczynski"]
10
+ spec.email = ["support@securionpay.com"]
11
+
12
+ spec.summary = "SecurionPay ruby gem"
13
+ spec.description = "SecurionPay ruby gem"
14
+ spec.homepage = "https://securionpay.com"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'httparty', '~> 0.13'
22
+ spec.add_development_dependency 'bundler', '~> 1.11'
23
+ spec.add_development_dependency "rake", "~> 11.1"
24
+ spec.add_development_dependency "rspec", "~> 3.4"
25
+ spec.add_development_dependency "pry", "~> 0.10"
26
+ spec.add_development_dependency "codeclimate-test-reporter", "~> 0.5"
27
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: securionpay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Grzegorz Wilczynski
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
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.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '11.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '11.1'
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.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codeclimate-test-reporter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.5'
97
+ description: SecurionPay ruby gem
98
+ email:
99
+ - support@securionpay.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".codeclimate.yml"
105
+ - ".gitignore"
106
+ - ".rubocop.yml"
107
+ - ".ruby-version"
108
+ - ".travis.yml"
109
+ - Gemfile
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - lib/securionpay.rb
115
+ - lib/securionpay/builders/path_builder.rb
116
+ - lib/securionpay/cards.rb
117
+ - lib/securionpay/communicator.rb
118
+ - lib/securionpay/configuration.rb
119
+ - lib/securionpay/version.rb
120
+ - securionpay-ruby.gemspec
121
+ homepage: https://securionpay.com
122
+ licenses: []
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.4.5.1
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: SecurionPay ruby gem
144
+ test_files: []