pedicel-pay 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/Dockerfile +9 -0
  3. data/Gemfile +3 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +99 -0
  6. data/pedicel-pay.gemspec +26 -0
  7. metadata +118 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bdb70920d44fc3ca94c23bf72503189c8a382675aab89f1f3247a59b05ef353f
4
+ data.tar.gz: a014ce297bc24449810a25cdae9fd29fc39344a6bf4cbf5180aa55b1d1f40a91
5
+ SHA512:
6
+ metadata.gz: e6ca39b5d3b99fe056eb145f62b01b976924ef2e1de997671925f0975388319965d2a5a34c5eede178c83f4fee84564ff27b823db3caa2bad129867f3a4f265b
7
+ data.tar.gz: 966fdf5fbab66e081952e3014498fd689f28b165b5a522ba3c642920838115178954d1e2954de4adcffe60ecaa46cf5de32942c60f3832c9b79736a300ed9193
data/Dockerfile ADDED
@@ -0,0 +1,9 @@
1
+ FROM ruby:2.4-alpine
2
+
3
+ LABEL maintainer="Clearhaus"
4
+
5
+ WORKDIR /opt/pedicel-pay
6
+ COPY . /opt/pedicel-pay
7
+ RUN bundle install
8
+
9
+ ENTRYPOINT ["/opt/pedicel-pay/exe/pedicel-pay"]
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Clearhaus A/S
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,99 @@
1
+ # PedicelPay
2
+
3
+ A tool to handle the server and client side of Apple Pay. It consist of both a
4
+ CLI part and a Ruby library e.g. for testing purposes.
5
+
6
+ ## Usage (CLI)
7
+
8
+ ### Setup a backend and a client
9
+
10
+ 1. Generate a backend (Apple side of Apple Pay):
11
+
12
+ $ pedicel-pay generate-backend
13
+
14
+ Creates these files:
15
+ * `ca.key`
16
+ * `ca-certificate.pem`
17
+ * `intermediate.key`
18
+ * `intermediate-certificate.pem`
19
+ * `leaf.key`
20
+ * `leaf-certificate.pem`
21
+
22
+ 2. Generate a client (merchant side of Apple Pay):
23
+
24
+ $ pedicel-pay generate-client
25
+
26
+ Creates `client.key` and `client-certificate.pem`.
27
+
28
+
29
+ ### Create tokens
30
+
31
+ $ pedicel-pay generate-token \
32
+ --pan=4111111111111111 \
33
+ --expiry=$(date -d 'next year' +%y%m%d) \
34
+ --amount=1234 \
35
+ --currency=978
36
+
37
+ Specify some values, sample remaining:
38
+
39
+ $ pedicel-pay generate-token \
40
+ --pan=4111111111111111 \
41
+ --sample
42
+
43
+ ### Decrypt tokens
44
+
45
+ $ echo $TOKEN | pedicel-pay decrypt-token
46
+
47
+
48
+ ## Usage (Ruby)
49
+
50
+ ### Setup a backend and a client
51
+
52
+ ```ruby
53
+ backend = PedicelPay::Backend.generate
54
+ client = backend.generate_client
55
+ ```
56
+
57
+ ### Create tokens
58
+
59
+ Sample data
60
+
61
+ ```ruby
62
+ token = PedicelPay::Token.new.sample
63
+ backend.encrypt(token: token, recipient: client)
64
+ backend.sign(token)
65
+ puts token.to_json
66
+ ```
67
+
68
+ or decide:
69
+
70
+ ```ruby
71
+ token = PedicelPay::Token.new
72
+
73
+ token.unencrypted_data.pan = '4111111111111111'
74
+ token.unencrypted_data.currency = '987' # EUR
75
+ token.unencrypted_data.amount = 1234 # 12.34 EUR
76
+ token.sample # Sample remaining.
77
+
78
+ backend.encrypt(token: token, recipient: client)
79
+ backend.sign(token)
80
+ puts token.to_json
81
+ ```
82
+
83
+ The JSON formatted Payment Token; refer to
84
+ https://developer.apple.com/library/content/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html
85
+
86
+
87
+ ### Decrypt tokens
88
+
89
+ Using the `client` (if it knows the CA cert):
90
+
91
+ ```ruby
92
+ client.decrypt(JSON.parse(token.to_json))
93
+ ```
94
+
95
+ To decrypt the token data by hand, use these values:
96
+ * The client's secret key `client.key`.
97
+ * The merchant ID `client.merchant_id` or client's certificate (containing the
98
+ merchant ID) `client.certificate`.
99
+ * Use `backend.ca_certificate` as Apple Root CA G3 certificate.
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'pedicel-pay/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'pedicel-pay'
8
+ s.version = PedicelPay::VERSION
9
+ s.author = 'Clearhaus A/S'
10
+ s.email = 'hello@clearhaus.com'
11
+
12
+ s.summary = 'Backend and client part of Apple Pay'
13
+ s.homepage = 'https://github.com/clearhaus/pedicel-pay'
14
+ s.license = 'MIT'
15
+
16
+ s.files = `ls`.split.reject {|f| f.match(/^spec\//) }
17
+ s.bindir = 'exe'
18
+ s.executables = s.files.grep(/^exe\//) { |f| File.basename(f) }
19
+ s.require_paths = ['lib']
20
+
21
+ s.add_development_dependency 'bundler', '~> 1.16'
22
+ s.add_development_dependency 'pry'
23
+ s.add_runtime_dependency 'pedicel', '~> 0.0.2'
24
+ s.add_runtime_dependency 'thor'
25
+ s.add_runtime_dependency 'openssl' # for ruby <= 2.3
26
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pedicel-pay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Clearhaus A/S
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pedicel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: openssl
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email: hello@clearhaus.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - Dockerfile
90
+ - Gemfile
91
+ - LICENSE.txt
92
+ - README.md
93
+ - pedicel-pay.gemspec
94
+ homepage: https://github.com/clearhaus/pedicel-pay
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.7.4
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Backend and client part of Apple Pay
118
+ test_files: []