googlepay 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f51475c0105a2012c8ca798d6854274c78690fdc3f4df252c3f0571cc97b289
4
- data.tar.gz: 445695231673fac543d2b97dce4cf0ab518455c897b45b683ae3c7ae46c99864
3
+ metadata.gz: 4bbf071ef9e623e1dde9f543d6e64c8787609b511879b00fbfab992744b13d47
4
+ data.tar.gz: 35497c496d0118dc6b4a55e33725ed29aa3503c7d6d63764ae8d30abdd1a35a9
5
5
  SHA512:
6
- metadata.gz: f9d8926530c2feae952df277e32e53f2e4e0ca23f1a2bdb1def34e7111a450be8dcc8d06482c9db15003c09ecb7b412e99b38d66d603291dfa8f5fe748b3d7bb
7
- data.tar.gz: a1c85b3d8e48fb82cbcede6ee87a720d5e3a0b3da8dd3646bccd3e5c1f2902dc5a9f742fb4ef8f6e1bca98fd64c32e7533785218523671647e19f40c670aba9b
6
+ metadata.gz: a8c0ee0e6cee686574fde73d2be89ee87e9344d1e73d3c928681a3cc0315bd314ef76a026bc560eb4098ebdf85a495bbf273fa4ab751fa3a6f5669cdef3dc415
7
+ data.tar.gz: 1cb3a80144ad2cd5edf59042b4954013c33f62a268b703b3083e720243d3cb3e8a6b5c68d6795dedff23c3ee40f4d570c586cf82ac423837eae4be47cbbb3e2a
data/.gitignore CHANGED
@@ -11,4 +11,4 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
 
14
- gpay.json
14
+ .env
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- googlepay (0.1.0)
4
+ googlepay (0.2.0)
5
5
  googleauth
6
6
  httparty
7
7
  json
@@ -18,17 +18,17 @@ GEM
18
18
  diff-lcs (1.3)
19
19
  docile (1.3.2)
20
20
  dotenv (2.7.5)
21
- faraday (1.0.0)
21
+ faraday (1.0.1)
22
22
  multipart-post (>= 1.2, < 3)
23
- googleauth (0.11.0)
23
+ googleauth (0.13.0)
24
24
  faraday (>= 0.17.3, < 2.0)
25
25
  jwt (>= 1.4, < 3.0)
26
26
  memoist (~> 0.16)
27
27
  multi_json (~> 1.11)
28
28
  os (>= 0.9, < 2.0)
29
- signet (~> 0.12)
29
+ signet (~> 0.14)
30
30
  hashdiff (1.0.1)
31
- httparty (0.18.0)
31
+ httparty (0.18.1)
32
32
  mime-types (~> 3.0)
33
33
  multi_xml (>= 0.5.2)
34
34
  json (2.3.0)
@@ -37,11 +37,11 @@ GEM
37
37
  method_source (1.0.0)
38
38
  mime-types (3.3.1)
39
39
  mime-types-data (~> 3.2015)
40
- mime-types-data (3.2019.1009)
40
+ mime-types-data (3.2020.0512)
41
41
  multi_json (1.14.1)
42
42
  multi_xml (0.6.0)
43
43
  multipart-post (2.1.1)
44
- os (1.0.1)
44
+ os (1.1.0)
45
45
  pry (0.13.0)
46
46
  coderay (~> 1.1)
47
47
  method_source (~> 1.0)
@@ -61,7 +61,7 @@ GEM
61
61
  rspec-support (~> 3.9.0)
62
62
  rspec-support (3.9.2)
63
63
  safe_yaml (1.0.5)
64
- signet (0.13.2)
64
+ signet (0.14.0)
65
65
  addressable (~> 2.3)
66
66
  faraday (>= 0.17.3, < 2.0)
67
67
  jwt (>= 1.5, < 3.0)
@@ -75,7 +75,7 @@ GEM
75
75
  addressable (>= 2.3.6)
76
76
  crack (>= 0.3.2)
77
77
  hashdiff (>= 0.4.0, < 2.0.0)
78
- zeitwerk (2.3.0)
78
+ zeitwerk (2.3.1)
79
79
 
80
80
  PLATFORMS
81
81
  ruby
data/README.md CHANGED
@@ -26,22 +26,35 @@ In order to use the googlepay gem, you will need to have a Google Service accoun
26
26
  2. Create a new project.
27
27
  3. Within the new project, set up a [Service Account](https://cloud.google.com/iam/docs/service-accounts).
28
28
  4. Click on Actions on your new Service Account, Create Key, generate a JSON key and download.
29
- 5. Add the file into the root of your project, renaming it to gpay.json.
30
-
31
- The format should look like:
32
-
33
- {
34
- "type": "service_account",
35
- "project_id": "",
36
- "private_key_id": "",
37
- "private_key": "",
38
- "client_email": "",
39
- "client_id": "",
40
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
41
- "token_uri": "https://oauth2.googleapis.com/token",
42
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
43
- "client_x509_cert_url": ""
44
- }
29
+ 5. Add the file into an initializer in your project.
30
+
31
+ Example: initializers/googlepay.rb
32
+
33
+ require 'googlepay'
34
+
35
+ Googlepay.configure do |config|
36
+ config.service_account = {
37
+ "type": "service_account",
38
+ "project_id": "",
39
+ "private_key_id": "",
40
+ "private_key": "",
41
+ "client_email": "",
42
+ "client_id": "",
43
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
44
+ "token_uri": "https://oauth2.googleapis.com/token",
45
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
46
+ "client_x509_cert_url": ""
47
+ }
48
+ end
49
+
50
+ preferably by storing them as an ENV VAR in YAML format.
51
+
52
+ require 'googlepay'
53
+
54
+ Googlepay.configure do |config|
55
+ config.service_account = Rails.application.credentials.service_account
56
+ #config.service_account = ENV['SERVICE_ACCOUNT']
57
+ end
45
58
 
46
59
  #### Tie your service account to your Google Pay API for Passes account
47
60
 
@@ -90,7 +103,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
90
103
 
91
104
  ## Contributing
92
105
 
93
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/googlepay. 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.
106
+ Bug reports and pull requests are welcome on GitHub at https://github.com/regularlady/googlepay. 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.
94
107
 
95
108
  ## License
96
109
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  lib = File.expand_path("../lib", __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -9,7 +10,7 @@ Gem::Specification.new do |spec|
9
10
  spec.authors = ["Brittany Martin"]
10
11
  spec.email = ["brittany.jill.martin@gmail.com"]
11
12
 
12
- spec.summary = "Google Pay APIs help you build better checkout experiences."
13
+ spec.summary = "An engaging way to offer passes, loyalty programs, and more with Google Pay."
13
14
  spec.homepage = "https://github.com/regularlady/googlepay"
14
15
  spec.license = "MIT"
15
16
 
@@ -32,6 +33,7 @@ Gem::Specification.new do |spec|
32
33
  spec.bindir = "exe"
33
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
35
  spec.require_paths = ["lib"]
36
+ spec.required_ruby_version = ">= 2.2.0"
35
37
 
36
38
  spec.add_development_dependency "bundler", "~> 2.0"
37
39
  spec.add_development_dependency "pry"
@@ -1,6 +1,6 @@
1
1
  require 'googleauth'
2
2
  require 'httparty'
3
- require 'pry'
3
+ require 'tempfile'
4
4
  require 'zeitwerk'
5
5
 
6
6
  loader = Zeitwerk::Loader.for_gem
@@ -14,14 +14,33 @@ module Googlepay
14
14
  fetch_token
15
15
  end
16
16
 
17
+ class << self
18
+ attr_accessor :configuration
19
+ end
20
+
21
+ def self.configuration
22
+ @configuration ||= Configuration.new
23
+ end
24
+
25
+ def self.reset
26
+ @configuration = Configuration.new
27
+ end
28
+
29
+ def self.configure
30
+ yield(configuration)
31
+ end
32
+
17
33
  private
18
34
 
19
35
  def self.fetch_token
36
+ json_key = Tempfile.new
37
+ json_key.write(Googlepay.configuration.service_account.to_json)
38
+ json_key.rewind
20
39
  authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
21
- json_key_io: File.open("#{root}/gpay.json"),
40
+ json_key_io: json_key,
22
41
  scope: SCOPE
23
42
  )
24
-
43
+ json_key.close
25
44
  authorizer.fetch_access_token!['access_token']
26
45
  end
27
46
 
@@ -0,0 +1,9 @@
1
+ module Googlepay
2
+ class Configuration
3
+ attr_accessor :service_account
4
+
5
+ def initialize
6
+ @service_account = nil
7
+ end
8
+ end
9
+ end
@@ -8,11 +8,10 @@ module Googlepay
8
8
  end
9
9
 
10
10
  def create
11
- json = JSON.parse(File.read(File.open("#{Googlepay.root}/gpay.json")))
12
- rsa_private = OpenSSL::PKey::RSA.new json['private_key']
11
+ rsa_private = OpenSSL::PKey::RSA.new Googlepay.configuration.service_account[:private_key]
13
12
  create_event_object(@parameters)
14
13
  payload = {
15
- "iss": json["client_email"],
14
+ "iss": Googlepay.configuration.service_account[:client_email],
16
15
  "aud": 'google',
17
16
  "typ": 'savetoandroidpay',
18
17
  "iat": Time.now.utc.to_i,
@@ -1,3 +1,3 @@
1
1
  module Googlepay
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlepay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brittany Martin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-23 00:00:00.000000000 Z
11
+ date: 2020-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,6 +143,7 @@ files:
143
143
  - bin/setup
144
144
  - googlepay.gemspec
145
145
  - lib/googlepay.rb
146
+ - lib/googlepay/configuration.rb
146
147
  - lib/googlepay/event_ticket_class.rb
147
148
  - lib/googlepay/event_ticket_object.rb
148
149
  - lib/googlepay/version.rb
@@ -161,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
162
  requirements:
162
163
  - - ">="
163
164
  - !ruby/object:Gem::Version
164
- version: '0'
165
+ version: 2.2.0
165
166
  required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
168
  - - ">="
@@ -171,5 +172,5 @@ requirements: []
171
172
  rubygems_version: 3.1.2
172
173
  signing_key:
173
174
  specification_version: 4
174
- summary: Google Pay APIs help you build better checkout experiences.
175
+ summary: An engaging way to offer passes, loyalty programs, and more with Google Pay.
175
176
  test_files: []