online_payment_platform 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +48 -0
- data/LICENSE +24 -0
- data/README.md +60 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/online_payment_platform.rb +27 -0
- data/lib/online_payment_platform/client.rb +11 -0
- data/lib/online_payment_platform/client/merchant.rb +53 -0
- data/lib/online_payment_platform/client/status.rb +11 -0
- data/lib/online_payment_platform/client/transaction.rb +45 -0
- data/lib/online_payment_platform/methods.rb +45 -0
- data/lib/online_payment_platform/version.rb +5 -0
- data/online_payment_platform.gemspec +32 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '0937e1707235efc53134f36f3d811ed8d3de39169557241e163eb6f818bdeacf'
|
4
|
+
data.tar.gz: fb970bb584c1265c3a4e68ea51f5434cc76eed5cdfb866f53ad25ef4b87005fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 314e98563f72d6622387306008c3c01a4a316c7647fe62304a0b809e95b53245bfe8b3b668ec905612fe14736f5b3b897959a1435af30b006664a33d990c8700
|
7
|
+
data.tar.gz: 6f5cf1eb3916c2c4ba069c02bb52325d2ea66d604924e620b00ce6e9beb15821710e08e35404881c345b55ed2631ad725c4d8f775543f5cbf7a30d3d481aa353
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
DisabledByDefault: false
|
4
|
+
DisplayCopNames: true
|
5
|
+
TargetRubyVersion: 3.0.0
|
6
|
+
Exclude:
|
7
|
+
- bin/*
|
8
|
+
- tmp/**/*
|
9
|
+
Documentation:
|
10
|
+
Enabled: false
|
11
|
+
Metrics/LineLength:
|
12
|
+
Max: 120
|
13
|
+
Lint/UselessAssignment:
|
14
|
+
Enabled: true
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Enabled: false
|
17
|
+
Metrics/AbcSize:
|
18
|
+
Enabled: true
|
19
|
+
Max: 35
|
20
|
+
Lint/UriEscapeUnescape:
|
21
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Added
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
online_payment_platform (0.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.7.0)
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
11
|
+
byebug (11.1.3)
|
12
|
+
crack (0.4.5)
|
13
|
+
rexml
|
14
|
+
diff-lcs (1.4.4)
|
15
|
+
hashdiff (1.0.1)
|
16
|
+
public_suffix (4.0.6)
|
17
|
+
rake (12.3.3)
|
18
|
+
rexml (3.2.4)
|
19
|
+
rspec (3.10.0)
|
20
|
+
rspec-core (~> 3.10.0)
|
21
|
+
rspec-expectations (~> 3.10.0)
|
22
|
+
rspec-mocks (~> 3.10.0)
|
23
|
+
rspec-core (3.10.1)
|
24
|
+
rspec-support (~> 3.10.0)
|
25
|
+
rspec-expectations (3.10.1)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.10.0)
|
28
|
+
rspec-mocks (3.10.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.10.0)
|
31
|
+
rspec-support (3.10.2)
|
32
|
+
webmock (3.11.2)
|
33
|
+
addressable (>= 2.3.6)
|
34
|
+
crack (>= 0.3.2)
|
35
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
byebug
|
42
|
+
online_payment_platform!
|
43
|
+
rake (~> 12.0)
|
44
|
+
rspec (~> 3.0)
|
45
|
+
webmock
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.1.4
|
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
+
distribute this software, either in source code form or as a compiled
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
+
means.
|
7
|
+
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
+
of this software dedicate any and all copyright interest in the
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
11
|
+
of the public at large and to the detriment of our heirs and
|
12
|
+
successors. We intend this dedication to be an overt act of
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
14
|
+
software under copyright law.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Ruby wrapper for the postcode.eu endpoints
|
2
|
+
https://www.postcode.nl/en/services/adresdata/international
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'international_postcode_api'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle install
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install international_postcode_api
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Create an initializer (config/intializers/international_postcode_api.rb)
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
InternationalPostcodeApi.configure do |config|
|
26
|
+
config.api_key = 'your-API-key'
|
27
|
+
config.secret_key = 'your-secret-key'
|
28
|
+
|
29
|
+
# set new base_uri if new versions are released
|
30
|
+
# config.base_uri = 'https://api.postcode.eu/international/v1'
|
31
|
+
|
32
|
+
# Do not switch to Dutch endpoint for Dutch requests will dynamicly switch by default
|
33
|
+
# config.dynamic_endpoints = false
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
## Methods
|
38
|
+
|
39
|
+
All methods can be called from the client object:
|
40
|
+
```ruby
|
41
|
+
InternationalPostcodeApi::Client.autocomplete('Amsterdam', 'nld')
|
42
|
+
required: term
|
43
|
+
optional: country_code, default: 'nld'
|
44
|
+
|
45
|
+
InternationalPostcodeApi::Client.details('$1234...')
|
46
|
+
required: context
|
47
|
+
|
48
|
+
InternationalPostcodeApi::Client.dutch_postcode('1000AB', '50', 'A')
|
49
|
+
required: zipcode, house_number
|
50
|
+
optional: house_number_addition, default: nil
|
51
|
+
|
52
|
+
# important!! #postcode only returns a hash with :street and :city dynamicly depending on
|
53
|
+
# which endpoint you are using, if you need access to the raw response use #dutch_postcode or #autocomplete + #details
|
54
|
+
|
55
|
+
InternationalPostcodeApi::Client.postcode('1000AB', '50', 'DE')
|
56
|
+
required: zipcode, house_number
|
57
|
+
optional: country_code, default: 'NL'
|
58
|
+
|
59
|
+
InternationalPostcodeApi::Client.supported_countries
|
60
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'online_payment_platform'
|
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
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'online_payment_platform/version'
|
4
|
+
require 'online_payment_platform/client'
|
5
|
+
require 'online_payment_platform/client/status'
|
6
|
+
require 'online_payment_platform/client/merchant'
|
7
|
+
require 'online_payment_platform/client/transaction'
|
8
|
+
|
9
|
+
module OnlinePaymentPlatform
|
10
|
+
class << self
|
11
|
+
attr_accessor :configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
self.configuration ||= Configuration.new
|
16
|
+
yield(configuration)
|
17
|
+
end
|
18
|
+
|
19
|
+
class Configuration
|
20
|
+
attr_accessor :api_key, :base_uri, :sandbox_mode
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@sandbox_mode = true
|
24
|
+
@base_uri = @sandbox_mode ? 'https://api-sandbox.onlinebetaalplatform.nl/v1/' : 'https://api.onlinebetaalplatform.nl/v1/'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OnlinePaymentPlatform
|
4
|
+
class Client
|
5
|
+
class Merchant
|
6
|
+
attr_reader :uid, :features, :transactions
|
7
|
+
|
8
|
+
extend Methods
|
9
|
+
|
10
|
+
def initialize(opts = {})
|
11
|
+
@features = opts
|
12
|
+
@uid = @features['uid']
|
13
|
+
@transactions = Transaction.new @uid
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(opts = {})
|
17
|
+
parent = self.class
|
18
|
+
parent.assert_one_of!(opts, :notify_url, :return_url, :metadata, :status)
|
19
|
+
response = parent.post parent.generate_uri(:merchants, uid), opts
|
20
|
+
Merchant.new response
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete
|
24
|
+
update(status: :terminated)
|
25
|
+
end
|
26
|
+
|
27
|
+
def suspend
|
28
|
+
update(status: :suspended)
|
29
|
+
end
|
30
|
+
|
31
|
+
def migrate(opts = {})
|
32
|
+
parent = self.class
|
33
|
+
parent.assert_required_keys!(opts, :coc_nr, :country)
|
34
|
+
response = parent.post parent.generate_uri(:merchants, uid, :migrate), opts
|
35
|
+
Merchant.new response
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.create(opts = {})
|
39
|
+
assert_required_keys!(opts, :country, :emailaddress, :notify_url, :phone)
|
40
|
+
Merchant.new post(generate_uri(:merchants), opts)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.find(uid)
|
44
|
+
response = fetch generate_uri(:merchants, uid)
|
45
|
+
Merchant.new response
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.merchants
|
50
|
+
Merchant
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OnlinePaymentPlatform
|
4
|
+
class Client
|
5
|
+
class Transaction
|
6
|
+
include Methods
|
7
|
+
|
8
|
+
attr_reader :merchant_uid, :uid
|
9
|
+
attr_accessor :features
|
10
|
+
|
11
|
+
def initialize(merchant_uid, uid = nil)
|
12
|
+
@merchant_uid = merchant_uid
|
13
|
+
@uid = uid
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(opts = {})
|
17
|
+
assert_required_keys!(opts, :total_price, :products)
|
18
|
+
post generate_uri(:transactions), set_params(opts)
|
19
|
+
end
|
20
|
+
|
21
|
+
def find(uid)
|
22
|
+
response = fetch generate_uri(:transactions, uid)
|
23
|
+
object = Transaction.new merchant_uid, uid
|
24
|
+
object.features = response
|
25
|
+
|
26
|
+
return object
|
27
|
+
end
|
28
|
+
|
29
|
+
def refund!(opts = {})
|
30
|
+
assert_required_keys!(opts, :amount)
|
31
|
+
post generate_uri(:transactions, uid, :refunds), opts
|
32
|
+
end
|
33
|
+
|
34
|
+
def refunds
|
35
|
+
fetch generate_uri(:transactions, uid, :refunds)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def set_params(opts)
|
41
|
+
opts.merge! merchant_uid: merchant_uid
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Methods
|
4
|
+
def assert_required_keys!(options, *keys)
|
5
|
+
keys.each do |key|
|
6
|
+
raise 'Required key missing!' if options[key].nil?
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def assert_one_of!(options, *keys)
|
11
|
+
raise 'Missing one of required keys!' unless (options.keys & keys).any?
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_uri(*path)
|
15
|
+
encoded_uri = URI.encode(OnlinePaymentPlatform.configuration.base_uri + path.join('/'))
|
16
|
+
URI.parse encoded_uri
|
17
|
+
end
|
18
|
+
|
19
|
+
def post(uri, payload = {})
|
20
|
+
config = OnlinePaymentPlatform.configuration
|
21
|
+
|
22
|
+
req = Net::HTTP::Post.new(uri, { 'Content-Type': 'text/json' })
|
23
|
+
req['Authorization'] = "Bearer #{config.api_key}"
|
24
|
+
req.body = payload.to_json
|
25
|
+
|
26
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
27
|
+
http.request req
|
28
|
+
end
|
29
|
+
|
30
|
+
JSON.parse response.body
|
31
|
+
end
|
32
|
+
|
33
|
+
def fetch(uri)
|
34
|
+
config = OnlinePaymentPlatform.configuration
|
35
|
+
|
36
|
+
req = Net::HTTP::Get.new(uri)
|
37
|
+
req['Authorization'] = "Bearer #{config.api_key}"
|
38
|
+
|
39
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
40
|
+
http.request req
|
41
|
+
end
|
42
|
+
|
43
|
+
JSON.parse response.body
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/online_payment_platform/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'online_payment_platform'
|
7
|
+
spec.version = OnlinePaymentPlatform::VERSION
|
8
|
+
spec.authors = ['Dennis de Vulder']
|
9
|
+
spec.email = ['dennisdevulder@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'A ruby wrapper for OPP'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = 'https://github.com/advalley/onlinepaymentplatform'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.0.0')
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/advalley/onlinepaymentplatform/blob/main/CHANGELOG.md'
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_development_dependency 'rspec'
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: online_payment_platform
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dennis de Vulder
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: A ruby wrapper for OPP
|
28
|
+
email:
|
29
|
+
- dennisdevulder@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rubocop.yml"
|
36
|
+
- CHANGELOG.md
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- bin/console
|
43
|
+
- bin/setup
|
44
|
+
- lib/online_payment_platform.rb
|
45
|
+
- lib/online_payment_platform/client.rb
|
46
|
+
- lib/online_payment_platform/client/merchant.rb
|
47
|
+
- lib/online_payment_platform/client/status.rb
|
48
|
+
- lib/online_payment_platform/client/transaction.rb
|
49
|
+
- lib/online_payment_platform/methods.rb
|
50
|
+
- lib/online_payment_platform/version.rb
|
51
|
+
- online_payment_platform.gemspec
|
52
|
+
homepage: https://github.com/advalley/onlinepaymentplatform
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata:
|
56
|
+
homepage_uri: https://github.com/advalley/onlinepaymentplatform
|
57
|
+
source_code_uri: https://github.com/advalley/onlinepaymentplatform
|
58
|
+
changelog_uri: https://github.com/advalley/onlinepaymentplatform/blob/main/CHANGELOG.md
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 3.0.0
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubygems_version: 3.0.3
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: A ruby wrapper for OPP
|
78
|
+
test_files: []
|