googlepay 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/EXAMPLE.md +33 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +95 -0
- data/LICENSE.txt +21 -0
- data/README.md +103 -0
- data/Rakefile +6 -0
- data/bin/console +6 -0
- data/bin/setup +8 -0
- data/googlepay.gemspec +45 -0
- data/lib/googlepay.rb +32 -0
- data/lib/googlepay/event_ticket_class.rb +25 -0
- data/lib/googlepay/event_ticket_object.rb +36 -0
- data/lib/googlepay/version.rb +3 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1f51475c0105a2012c8ca798d6854274c78690fdc3f4df252c3f0571cc97b289
|
4
|
+
data.tar.gz: 445695231673fac543d2b97dce4cf0ab518455c897b45b683ae3c7ae46c99864
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f9d8926530c2feae952df277e32e53f2e4e0ca23f1a2bdb1def34e7111a450be8dcc8d06482c9db15003c09ecb7b412e99b38d66d603291dfa8f5fe748b3d7bb
|
7
|
+
data.tar.gz: a1c85b3d8e48fb82cbcede6ee87a720d5e3a0b3da8dd3646bccd3e5c1f2902dc5a9f742fb4ef8f6e1bca98fd64c32e7533785218523671647e19f40c670aba9b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
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 brittany.jill.martin@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 [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/EXAMPLE.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
### JSON EventTicketClass
|
2
|
+
|
3
|
+
parameters =
|
4
|
+
{
|
5
|
+
"kind": "walletobjects#eventTicketClass",
|
6
|
+
"id": "3388000000002437969.123456789",
|
7
|
+
"reviewStatus": "underReview",
|
8
|
+
"issuerName": "Your Company Name",
|
9
|
+
"eventName": {
|
10
|
+
"kind": "walletobjects#localizedString",
|
11
|
+
"translatedValues": [
|
12
|
+
{
|
13
|
+
"kind": "walletobjects#translatedString",
|
14
|
+
"language": "en-US",
|
15
|
+
"value": "Exciting Event"
|
16
|
+
} ],
|
17
|
+
"defaultValue": {
|
18
|
+
"kind": "walletobjects#translatedString",
|
19
|
+
"language": "en-US",
|
20
|
+
"value": "Ticket"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
### JSON EventTicketObject
|
26
|
+
|
27
|
+
parameters =
|
28
|
+
{
|
29
|
+
"classId": "3388000000002437969.1234567890",
|
30
|
+
"id": "3388000000002437969.123",
|
31
|
+
"state": "active",
|
32
|
+
"origin": "https://brittanymartin.dev"
|
33
|
+
}
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
googlepay (0.1.0)
|
5
|
+
googleauth
|
6
|
+
httparty
|
7
|
+
json
|
8
|
+
zeitwerk
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.7.0)
|
14
|
+
public_suffix (>= 2.0.2, < 5.0)
|
15
|
+
coderay (1.1.2)
|
16
|
+
crack (0.4.3)
|
17
|
+
safe_yaml (~> 1.0.0)
|
18
|
+
diff-lcs (1.3)
|
19
|
+
docile (1.3.2)
|
20
|
+
dotenv (2.7.5)
|
21
|
+
faraday (1.0.0)
|
22
|
+
multipart-post (>= 1.2, < 3)
|
23
|
+
googleauth (0.11.0)
|
24
|
+
faraday (>= 0.17.3, < 2.0)
|
25
|
+
jwt (>= 1.4, < 3.0)
|
26
|
+
memoist (~> 0.16)
|
27
|
+
multi_json (~> 1.11)
|
28
|
+
os (>= 0.9, < 2.0)
|
29
|
+
signet (~> 0.12)
|
30
|
+
hashdiff (1.0.1)
|
31
|
+
httparty (0.18.0)
|
32
|
+
mime-types (~> 3.0)
|
33
|
+
multi_xml (>= 0.5.2)
|
34
|
+
json (2.3.0)
|
35
|
+
jwt (2.2.1)
|
36
|
+
memoist (0.16.2)
|
37
|
+
method_source (1.0.0)
|
38
|
+
mime-types (3.3.1)
|
39
|
+
mime-types-data (~> 3.2015)
|
40
|
+
mime-types-data (3.2019.1009)
|
41
|
+
multi_json (1.14.1)
|
42
|
+
multi_xml (0.6.0)
|
43
|
+
multipart-post (2.1.1)
|
44
|
+
os (1.0.1)
|
45
|
+
pry (0.13.0)
|
46
|
+
coderay (~> 1.1)
|
47
|
+
method_source (~> 1.0)
|
48
|
+
public_suffix (4.0.3)
|
49
|
+
rake (10.5.0)
|
50
|
+
rspec (3.9.0)
|
51
|
+
rspec-core (~> 3.9.0)
|
52
|
+
rspec-expectations (~> 3.9.0)
|
53
|
+
rspec-mocks (~> 3.9.0)
|
54
|
+
rspec-core (3.9.1)
|
55
|
+
rspec-support (~> 3.9.1)
|
56
|
+
rspec-expectations (3.9.1)
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
+
rspec-support (~> 3.9.0)
|
59
|
+
rspec-mocks (3.9.1)
|
60
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
61
|
+
rspec-support (~> 3.9.0)
|
62
|
+
rspec-support (3.9.2)
|
63
|
+
safe_yaml (1.0.5)
|
64
|
+
signet (0.13.2)
|
65
|
+
addressable (~> 2.3)
|
66
|
+
faraday (>= 0.17.3, < 2.0)
|
67
|
+
jwt (>= 1.5, < 3.0)
|
68
|
+
multi_json (~> 1.10)
|
69
|
+
simplecov (0.18.5)
|
70
|
+
docile (~> 1.1)
|
71
|
+
simplecov-html (~> 0.11)
|
72
|
+
simplecov-html (0.12.2)
|
73
|
+
vcr (5.1.0)
|
74
|
+
webmock (3.8.3)
|
75
|
+
addressable (>= 2.3.6)
|
76
|
+
crack (>= 0.3.2)
|
77
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
78
|
+
zeitwerk (2.3.0)
|
79
|
+
|
80
|
+
PLATFORMS
|
81
|
+
ruby
|
82
|
+
|
83
|
+
DEPENDENCIES
|
84
|
+
bundler (~> 2.0)
|
85
|
+
dotenv
|
86
|
+
googlepay!
|
87
|
+
pry
|
88
|
+
rake (~> 10.0)
|
89
|
+
rspec (~> 3.0)
|
90
|
+
simplecov
|
91
|
+
vcr
|
92
|
+
webmock
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Brittany Martin
|
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,103 @@
|
|
1
|
+
# Googlepay
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
A Ruby interface to the Google Pay API. Currently focused on the Google Pay for Passes part of the API, with the intention of integrating with Google Pay for Payments in the future.
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'googlepay'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install googlepay
|
18
|
+
|
19
|
+
## Setup
|
20
|
+
|
21
|
+
In order to use the googlepay gem, you will need to have a Google Service account setup.
|
22
|
+
|
23
|
+
#### Access to the REST API
|
24
|
+
|
25
|
+
1. Sign up for a [Google Cloud Platform](https://cloud.google.com/) account.
|
26
|
+
2. Create a new project.
|
27
|
+
3. Within the new project, set up a [Service Account](https://cloud.google.com/iam/docs/service-accounts).
|
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
|
+
}
|
45
|
+
|
46
|
+
#### Tie your service account to your Google Pay API for Passes account
|
47
|
+
|
48
|
+
Visit [here](https://developers.google.com/pay/passes/guides/get-started/basic-setup/get-access-to-rest-api) to learn how to work with Google on getting registered for a Google Pay API for Passes account and to access the Google Pay API for Passes Merchant Center. Once registered in the Merchant Center, save your Issuer ID.
|
49
|
+
|
50
|
+
#### Enable the Google Pay API
|
51
|
+
|
52
|
+
Visit https://console.developers.google.com/apis/api/walletobjects.googleapis.com/overview?project={YOUR PROJECT} to enable the API for your project. Without doing so will cause this error:
|
53
|
+
|
54
|
+
Google Pay Passes API has not been used in project 615220349094 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/walletobjects.googleapis.com/overview?project={ID} then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
|
55
|
+
|
56
|
+
#### Use OAuth 2.0 for your Server to Server application
|
57
|
+
|
58
|
+
This gem takes care of this for you, thanks to [googleauth](https://github.com/googleapis/google-auth-library-ruby).
|
59
|
+
|
60
|
+
## Usage
|
61
|
+
|
62
|
+
### Event Tickets
|
63
|
+
|
64
|
+
JSON EventTicketClass must be created before EventTicketObjects can be created.
|
65
|
+
|
66
|
+
Refer to the [Google Pay for Passes Code Snippets](https://developers.google.com/pay/passes/guides/pass-verticals/event-tickets/code-snippets) to build a JSON Object. I have also included simplified examples in EXAMPLE.md and you can review the specs for uses.
|
67
|
+
|
68
|
+
#### Create/Update EventTicketClass
|
69
|
+
|
70
|
+
parameters = JSON Object
|
71
|
+
id = Googlepay::EventTicketClass.new(parameters)[:id]
|
72
|
+
|
73
|
+
Use the Issuer ID and a Unique ID formatted {Issuer ID.Unique ID} for the ID of the JSON object. If the ID exists already, the gem will update the EventTicketClass automatically.
|
74
|
+
|
75
|
+
More documentation [here](https://developers.google.com/pay/passes/rest/v1/eventticketclass).
|
76
|
+
|
77
|
+
#### Create EventTicketObject
|
78
|
+
|
79
|
+
Googlepay::EventTicketObject.new(parameters)
|
80
|
+
|
81
|
+
Use the Class ID and a Unique ID formatted {Issuer ID.Unique ID} for the ID of the JSON object. Include the array of domains to whitelist JWT saving functionality in the origin parameter. The Google Pay API for Passes button will not render when the origins field is not defined. You could potentially get an "Load denied by X-Frame-Options" or "Refused to display" messages in the browser console when the origins field is not defined.
|
82
|
+
|
83
|
+
More documentation [here](https://developers.google.com/pay/passes/rest/v1/eventticketobject).
|
84
|
+
|
85
|
+
## Development
|
86
|
+
|
87
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
88
|
+
|
89
|
+
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).
|
90
|
+
|
91
|
+
## Contributing
|
92
|
+
|
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.
|
94
|
+
|
95
|
+
## License
|
96
|
+
|
97
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
98
|
+
|
99
|
+
The googlepay gem is not affiliated with or endorsed by Google.
|
100
|
+
|
101
|
+
## Code of Conduct
|
102
|
+
|
103
|
+
Everyone interacting in the Googlepay project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/googlepay/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/googlepay.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "googlepay/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "googlepay"
|
8
|
+
spec.version = Googlepay::VERSION
|
9
|
+
spec.authors = ["Brittany Martin"]
|
10
|
+
spec.email = ["brittany.jill.martin@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Google Pay APIs help you build better checkout experiences."
|
13
|
+
spec.homepage = "https://github.com/regularlady/googlepay"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
22
|
+
else
|
23
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
24
|
+
"public gem pushes."
|
25
|
+
end
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
30
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
31
|
+
end
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
37
|
+
spec.add_development_dependency "pry"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
+
|
41
|
+
spec.add_dependency "googleauth"
|
42
|
+
spec.add_dependency "httparty"
|
43
|
+
spec.add_dependency "json"
|
44
|
+
spec.add_dependency "zeitwerk"
|
45
|
+
end
|
data/lib/googlepay.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'googleauth'
|
2
|
+
require 'httparty'
|
3
|
+
require 'pry'
|
4
|
+
require 'zeitwerk'
|
5
|
+
|
6
|
+
loader = Zeitwerk::Loader.for_gem
|
7
|
+
loader.setup
|
8
|
+
|
9
|
+
module Googlepay
|
10
|
+
|
11
|
+
SCOPE = 'https://www.googleapis.com/auth/wallet_object.issuer'
|
12
|
+
|
13
|
+
def self.token
|
14
|
+
fetch_token
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def self.fetch_token
|
20
|
+
authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
|
21
|
+
json_key_io: File.open("#{root}/gpay.json"),
|
22
|
+
scope: SCOPE
|
23
|
+
)
|
24
|
+
|
25
|
+
authorizer.fetch_access_token!['access_token']
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.root
|
29
|
+
File.expand_path '../..', __FILE__
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Googlepay
|
2
|
+
class EventTicketClass
|
3
|
+
|
4
|
+
EVENT_URL = 'https://www.googleapis.com/walletobjects/v1/eventTicketClass'
|
5
|
+
|
6
|
+
def initialize(parameters)
|
7
|
+
@parameters = parameters
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
result = HTTParty.post("#{EVENT_URL}?access_token=#{Googlepay.token}",
|
12
|
+
:body => @parameters.to_json,
|
13
|
+
:headers => { 'Content-Type' => 'application/json' } )
|
14
|
+
return result if result['error'].nil?
|
15
|
+
update if result['error']['code'] == 409
|
16
|
+
end
|
17
|
+
|
18
|
+
def update
|
19
|
+
HTTParty.put("#{EVENT_URL}/#{@parameters[:id]}?access_token=#{Googlepay.token}",
|
20
|
+
:body => @parameters.to_json,
|
21
|
+
:headers => { 'Content-Type' => 'application/json' } )
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Googlepay
|
2
|
+
class EventTicketObject
|
3
|
+
|
4
|
+
EVENT_URL = 'https://www.googleapis.com/walletobjects/v1/eventTicketObject?'
|
5
|
+
|
6
|
+
def initialize(parameters)
|
7
|
+
@parameters = parameters
|
8
|
+
end
|
9
|
+
|
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']
|
13
|
+
create_event_object(@parameters)
|
14
|
+
payload = {
|
15
|
+
"iss": json["client_email"],
|
16
|
+
"aud": 'google',
|
17
|
+
"typ": 'savetoandroidpay',
|
18
|
+
"iat": Time.now.utc.to_i,
|
19
|
+
"payload": {
|
20
|
+
'eventTicketObjects': [@parameters.dup.tap { |h| h.delete(:origin) }]
|
21
|
+
},
|
22
|
+
'origins': @parameters.fetch(:origin)
|
23
|
+
}
|
24
|
+
JWT.encode payload, rsa_private, 'RS256'
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def create_event_object(event_ticket)
|
30
|
+
result = HTTParty.post("#{EVENT_URL}access_token=#{Googlepay.token}",
|
31
|
+
:body => event_ticket.to_json,
|
32
|
+
:headers => { 'Content-Type' => 'application/json' } )
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: googlepay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brittany Martin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-23 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: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
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: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
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.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: googleauth
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: httparty
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: json
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: zeitwerk
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- brittany.jill.martin@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".travis.yml"
|
135
|
+
- CODE_OF_CONDUCT.md
|
136
|
+
- EXAMPLE.md
|
137
|
+
- Gemfile
|
138
|
+
- Gemfile.lock
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- bin/console
|
143
|
+
- bin/setup
|
144
|
+
- googlepay.gemspec
|
145
|
+
- lib/googlepay.rb
|
146
|
+
- lib/googlepay/event_ticket_class.rb
|
147
|
+
- lib/googlepay/event_ticket_object.rb
|
148
|
+
- lib/googlepay/version.rb
|
149
|
+
homepage: https://github.com/regularlady/googlepay
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata:
|
153
|
+
homepage_uri: https://github.com/regularlady/googlepay
|
154
|
+
source_code_uri: https://github.com/regularlady/googlepay
|
155
|
+
changelog_uri: https://github.com/regularlady/googlepay
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubygems_version: 3.1.2
|
172
|
+
signing_key:
|
173
|
+
specification_version: 4
|
174
|
+
summary: Google Pay APIs help you build better checkout experiences.
|
175
|
+
test_files: []
|