expresscheckout 0.1.5
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 +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/expresscheckout.gemspec +33 -0
- data/lib/Cards.rb +116 -0
- data/lib/Orders.rb +345 -0
- data/lib/Payments.rb +100 -0
- data/lib/Test.rb +119 -0
- data/lib/expresscheckout/version.rb +3 -0
- data/lib/expresscheckout.rb +12 -0
- data/lib/util.rb +36 -0
- metadata +110 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: f2911f083bf551ec6ea823f7c7e51a9550640618
|
|
4
|
+
data.tar.gz: 554f843e45ea181479b224cb15ef3a014289676f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 45df3a1113adaba0a7d720791971d3ac19d5c4755a8f14638b5beac1fc05c0e3b2aa1584b2f63c1f55cfe0138883661d7d1c727e151b9eb6c1537bdd1ef49317
|
|
7
|
+
data.tar.gz: 4930e17109385464d634759ff372cb15fd98ffd9275b583c4b3dfcd4c502fba3a728d6fcc1b4b4eed35da31d71ea682cafd6846fe78fca00f613d578103419ad
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at shreyas.chandrakaladharan@juspay.in. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Shreyas
|
|
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,39 @@
|
|
|
1
|
+
# Expresscheckout
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/expresscheckout`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'expresscheckout'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute:
|
|
15
|
+
|
|
16
|
+
$ bundle
|
|
17
|
+
|
|
18
|
+
Or install it yourself as:
|
|
19
|
+
|
|
20
|
+
$ gem install expresscheckout
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
28
|
+
|
|
29
|
+
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).
|
|
30
|
+
|
|
31
|
+
## Contributing
|
|
32
|
+
|
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/expresscheckout. 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.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
39
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "expresscheckout"
|
|
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
|
data/bin/setup
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'expresscheckout/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "expresscheckout"
|
|
8
|
+
spec.version = Expresscheckout::VERSION
|
|
9
|
+
spec.authors = ["Juspay"]
|
|
10
|
+
spec.email = ["ec@juspay.in"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Juspay ExpressCheckout's Ruby API}
|
|
13
|
+
spec.description = %q{Juspay ExpressCheckout's Ruby API}
|
|
14
|
+
spec.homepage = "https://www.juspay.in"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib","lib/Orders.rb","lib/expresscheckout.rb","lib/Payments.rb","lib/Cards.rb","lib/Test.rb","lib/util.rb",]
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
32
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
33
|
+
end
|
data/lib/Cards.rb
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
require_relative 'util'
|
|
2
|
+
|
|
3
|
+
class Cards
|
|
4
|
+
|
|
5
|
+
# noinspection ALL
|
|
6
|
+
class Card
|
|
7
|
+
|
|
8
|
+
attr_reader :fingerprint, :expired, :type, :deleted, :exp_month, :number, :exp_year, :name, :token, :brand, :isin, :reference, :nickname, :issuer
|
|
9
|
+
|
|
10
|
+
def initialize(options = {})
|
|
11
|
+
@name = get_arg(options, 'name_on_card')
|
|
12
|
+
@exp_year = get_arg(options, 'card_exp_year')
|
|
13
|
+
@reference = get_arg(options, 'card_reference')
|
|
14
|
+
@exp_month = get_arg(options, 'card_exp_month')
|
|
15
|
+
@expired = get_arg(options, 'expired')
|
|
16
|
+
@fingerprint = get_arg(options, 'card_fingerprint')
|
|
17
|
+
@isin = get_arg(options, 'card_isin')
|
|
18
|
+
@type = get_arg(options, 'card_type')
|
|
19
|
+
@issuer = get_arg(options, 'card_issuer')
|
|
20
|
+
@brand = get_arg(options, 'card_brand')
|
|
21
|
+
@token = get_arg(options, 'card_token')
|
|
22
|
+
@nickname = get_arg(options, 'nickname')
|
|
23
|
+
@number = get_arg(options, 'card_number')
|
|
24
|
+
@deleted = get_arg(options, 'deleted')
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def Cards.add(options={})
|
|
30
|
+
method = 'POST'
|
|
31
|
+
url = '/card/add'
|
|
32
|
+
parameters = {}
|
|
33
|
+
required_args = {}
|
|
34
|
+
Array[:merchant_id, :customer_id, :customer_email, :card_number, :card_exp_year, :card_exp_month].each do |key|
|
|
35
|
+
required_args.store(key,'False')
|
|
36
|
+
end
|
|
37
|
+
options.each do |key, value|
|
|
38
|
+
parameters.store(key,value)
|
|
39
|
+
required_args[key] = 'True'
|
|
40
|
+
end
|
|
41
|
+
Array[:merchant_id, :customer_id, :customer_email, :card_number, :card_exp_year, :card_exp_month].each do |key|
|
|
42
|
+
if required_args[key] == 'False'
|
|
43
|
+
raise "ERROR: #{key} is a required argument for Cards.add"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
parameters.each do |key, _|
|
|
47
|
+
unless Array[:merchant_id, :customer_id, :customer_email, :card_number, :card_exp_year,
|
|
48
|
+
:card_exp_month, :name_on_card, :nickname].include?(key)
|
|
49
|
+
puts " #{key} is an invalid argument for Cards.add"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
response = request(method,url,options)
|
|
53
|
+
card = Card.new(response.body)
|
|
54
|
+
return card
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def Cards.list(options={})
|
|
58
|
+
method = 'GET'
|
|
59
|
+
url = '/card/list'
|
|
60
|
+
parameters = {}
|
|
61
|
+
required_args = {}
|
|
62
|
+
Array[:customer_id].each do |key|
|
|
63
|
+
required_args.store(key,'False')
|
|
64
|
+
end
|
|
65
|
+
options.each do |key, value|
|
|
66
|
+
parameters.store(key,value)
|
|
67
|
+
required_args[key] = 'True'
|
|
68
|
+
end
|
|
69
|
+
Array[:customer_id].each do |key|
|
|
70
|
+
if required_args[key] == 'False'
|
|
71
|
+
raise "ERROR: #{key} is a required argument for Cards.list"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
parameters.each do |key, _|
|
|
75
|
+
unless Array[:customer_id].include?(key)
|
|
76
|
+
puts " #{key} is an invalid argument for Cards.list"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
response = Array(request(method,url,options).body['cards'])
|
|
80
|
+
cards = []
|
|
81
|
+
i=0
|
|
82
|
+
while i != response.count
|
|
83
|
+
card = Card.new(response[i])
|
|
84
|
+
cards.push(card)
|
|
85
|
+
i+=1
|
|
86
|
+
end
|
|
87
|
+
return cards
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def Cards.delete(options={})
|
|
91
|
+
method = 'POST'
|
|
92
|
+
url = '/card/delete'
|
|
93
|
+
parameters = {}
|
|
94
|
+
required_args = {}
|
|
95
|
+
Array[:card_token].each do |key|
|
|
96
|
+
required_args.store(key,'False')
|
|
97
|
+
end
|
|
98
|
+
options.each do |key, value|
|
|
99
|
+
parameters.store(key,value)
|
|
100
|
+
required_args[key] = 'True'
|
|
101
|
+
end
|
|
102
|
+
Array[:card_token].each do |key|
|
|
103
|
+
if required_args[key] == 'False'
|
|
104
|
+
raise "ERROR: #{key} is a required argument for Cards.delete"
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
parameters.each do |key, _|
|
|
108
|
+
unless Array[:card_token].include?(key)
|
|
109
|
+
puts " #{key} is an invalid argument for Cards.delete"
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
response = request(method,url,options)
|
|
113
|
+
card = Card.new(response.body)
|
|
114
|
+
return card
|
|
115
|
+
end
|
|
116
|
+
end
|
data/lib/Orders.rb
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
require_relative 'util'
|
|
2
|
+
require_relative 'Cards'
|
|
3
|
+
|
|
4
|
+
class Orders
|
|
5
|
+
|
|
6
|
+
@all_input_params = Array[:order_id, :amount, :currency, :customer_id, :customer_email, :customer_phone,
|
|
7
|
+
:description, :product_id, :gateway_id, :return_url, :billing_address_first_name,
|
|
8
|
+
:billing_address_last_name, :billing_address_line1, :billing_address_line2,
|
|
9
|
+
:billing_address_line3, :billing_address_city, :billing_address_state,
|
|
10
|
+
:billing_address_country, :billing_address_postal_code, :billing_address_phone,
|
|
11
|
+
:billing_address_country_code_iso, :shipping_address_first_name,
|
|
12
|
+
:shipping_address_last_name, :shipping_address_line1, :shipping_address_line2,
|
|
13
|
+
:shipping_address_line3, :shipping_address_city, :shipping_address_state,
|
|
14
|
+
:shipping_address_country, :shipping_address_postal_code, :shipping_address_phone,
|
|
15
|
+
:shipping_address_country_code_iso, :udf1, :udf2, :udf3, :udf4, :udf5, :udf6, :udf7,
|
|
16
|
+
:udf8, :udf9, :udf10]
|
|
17
|
+
|
|
18
|
+
# noinspection ALL
|
|
19
|
+
class Order
|
|
20
|
+
|
|
21
|
+
attr_reader :order_id, :product_id, :billing_address, :udf10, :refunds, :return_url, :bank_error_code, :merchant_id, :amount, :shipping_address, :gateway_id, :customer_id, :gateway_response, :amount_refunded, :udf7, :customer_email, :udf8, :udf9, :txn_id, :udf3, :udf4, :description, :udf5, :bank_error_message, :udf6, :udf1, :udf2, :status, :customer_phone, :currency, :refunded, :status_id
|
|
22
|
+
class Address
|
|
23
|
+
|
|
24
|
+
attr_reader :state, :line1, :country, :country_code_iso, :type, :line3, :postal_code, :line2, :first_name, :last_name, :city, :phone
|
|
25
|
+
|
|
26
|
+
def initialize(address_type, options = {})
|
|
27
|
+
@type = address_type
|
|
28
|
+
@first_name = get_arg(options, (@type + '_address_first_name'))
|
|
29
|
+
@last_name = get_arg(options, (@type + '_address_last_name'))
|
|
30
|
+
@line1 = get_arg(options, (@type + '_address_line1'))
|
|
31
|
+
@line2 = get_arg(options, (@type + '_address_line2'))
|
|
32
|
+
@line3 = get_arg(options, (@type + '_address_line3'))
|
|
33
|
+
@city = get_arg(options, (@type + '_address_city'))
|
|
34
|
+
@state = get_arg(options, (@type + '_address_state'))
|
|
35
|
+
@country = get_arg(options, (@type + '_address_country'))
|
|
36
|
+
@postal_code = get_arg(options, (@type + '_address_postal_code'))
|
|
37
|
+
@phone = get_arg(options, (@type + '_address_phone'))
|
|
38
|
+
@country_code_iso = get_arg(options, (@type + '_address_country_code_iso'))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class Refund
|
|
44
|
+
|
|
45
|
+
attr_reader :amount, :created, :id, :ref, :status
|
|
46
|
+
|
|
47
|
+
def initialize(options = {})
|
|
48
|
+
@id = get_arg(options, 'refund_id')
|
|
49
|
+
@ref = get_arg(options, 'ref')
|
|
50
|
+
@amount = get_arg(options, 'amount')
|
|
51
|
+
@created = get_arg(options, 'created')
|
|
52
|
+
@status = get_arg(options, 'status')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class GatewayResponse
|
|
58
|
+
|
|
59
|
+
attr_reader :rrn, :epg_txn_id, :resp_message, :auth_id_code, :resp_code, :txn_id
|
|
60
|
+
|
|
61
|
+
def initialize(options = {})
|
|
62
|
+
@rrn = get_arg(options, 'rrn')
|
|
63
|
+
@epg_txn_id = get_arg(options, 'epg_txn_id')
|
|
64
|
+
@auth_id_code = get_arg(options, 'auth_id_code')
|
|
65
|
+
@txn_id = get_arg(options, 'txn_id')
|
|
66
|
+
@resp_code = get_arg(options, 'resp_code')
|
|
67
|
+
@resp_message = get_arg(options, 'resp_message')
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def initialize(options = {})
|
|
73
|
+
|
|
74
|
+
if check_param(options,"billing_address")
|
|
75
|
+
billing_address = Address.new("billing", options)
|
|
76
|
+
else
|
|
77
|
+
billing_address = nil
|
|
78
|
+
end
|
|
79
|
+
if check_param(options,"shiiping_address")
|
|
80
|
+
shipping_address = Address.new("shipping", options)
|
|
81
|
+
else
|
|
82
|
+
shipping_address = nil
|
|
83
|
+
end
|
|
84
|
+
if check_param(options,"cards")
|
|
85
|
+
card = Cards::Card.new(get_arg(options, 'card'))
|
|
86
|
+
else
|
|
87
|
+
card = nil
|
|
88
|
+
end
|
|
89
|
+
if get_arg(options,"payment_gateway_response") != nil
|
|
90
|
+
gateway_response = GatewayResponse.new(get_arg(options, 'payment_gateway_response'))
|
|
91
|
+
else
|
|
92
|
+
gateway_response = nil
|
|
93
|
+
end
|
|
94
|
+
refunds_array = Array(get_arg(options,'refunds'))
|
|
95
|
+
if refunds_array.length != 0
|
|
96
|
+
refunds = []
|
|
97
|
+
i=0
|
|
98
|
+
while i < refunds_array.count()
|
|
99
|
+
refund = refunds_array[i]
|
|
100
|
+
refund_obj = Refund.new(refund)
|
|
101
|
+
refunds.push(refund_obj)
|
|
102
|
+
i+=1
|
|
103
|
+
end
|
|
104
|
+
else
|
|
105
|
+
refunds = nil
|
|
106
|
+
end
|
|
107
|
+
@merchant_id = get_arg(options, 'merchant_id')
|
|
108
|
+
@order_id = get_arg(options, 'order_id')
|
|
109
|
+
@status = get_arg(options, 'status')
|
|
110
|
+
@status_id = get_arg(options, 'status_id')
|
|
111
|
+
@amount = get_arg(options, 'amount')
|
|
112
|
+
@currency = get_arg(options, 'currency')
|
|
113
|
+
@customer_id = get_arg(options, 'customer_id')
|
|
114
|
+
@customer_email = get_arg(options, 'customer_email')
|
|
115
|
+
@customer_phone = get_arg(options, 'customer_phone')
|
|
116
|
+
@product_id = get_arg(options, 'product_id')
|
|
117
|
+
@return_url = get_arg(options, 'return_url')
|
|
118
|
+
@description = get_arg(options, 'description')
|
|
119
|
+
@billing_address = billing_address
|
|
120
|
+
@shipping_address = shipping_address
|
|
121
|
+
@udf1 = get_arg(options, 'udf1')
|
|
122
|
+
@udf2 = get_arg(options, 'udf2')
|
|
123
|
+
@udf3 = get_arg(options, 'udf3')
|
|
124
|
+
@udf4 = get_arg(options, 'udf4')
|
|
125
|
+
@udf5 = get_arg(options, 'udf5')
|
|
126
|
+
@udf6 = get_arg(options, 'udf6')
|
|
127
|
+
@udf7 = get_arg(options, 'udf7')
|
|
128
|
+
@udf8 = get_arg(options, 'udf8')
|
|
129
|
+
@udf9 = get_arg(options, 'udf9')
|
|
130
|
+
@udf10 = get_arg(options, 'udf10')
|
|
131
|
+
@txn_id = get_arg(options, 'txn_id')
|
|
132
|
+
@gateway_id = get_arg(options, 'gateway_id')
|
|
133
|
+
@bank_error_code = get_arg(options, 'bank_error_code')
|
|
134
|
+
@bank_error_message = get_arg(options, 'bank_error_message')
|
|
135
|
+
@refunded = get_arg(options, 'refunded')
|
|
136
|
+
@amount_refunded = get_arg(options, 'amount_refunded')
|
|
137
|
+
@card = card
|
|
138
|
+
@gateway_response = gateway_response
|
|
139
|
+
@refunds = refunds
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def Orders.create(options={})
|
|
145
|
+
method = 'POST'
|
|
146
|
+
url = '/order/create'
|
|
147
|
+
parameters = {}
|
|
148
|
+
required_args = {}
|
|
149
|
+
Array[:order_id,:amount].each do |key|
|
|
150
|
+
required_args.store(key,'False')
|
|
151
|
+
end
|
|
152
|
+
options.each do |key, value|
|
|
153
|
+
parameters.store(key,value)
|
|
154
|
+
required_args[key] = 'True'
|
|
155
|
+
end
|
|
156
|
+
Array[:order_id,:amount].each do |key|
|
|
157
|
+
if required_args[key] == 'False'
|
|
158
|
+
raise "ERROR: #{key} is a required argument for Orders.create"
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
parameters.each do |key, _|
|
|
162
|
+
unless @all_input_params.include?(key)
|
|
163
|
+
puts " #{key} is an invalid argument for Orders.create"
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
if parameters[:amount].class != Fixnum and parameters[:amount].class != Float
|
|
167
|
+
raise "ERROR: 'amount' should be of type Fixnum or FLoat"
|
|
168
|
+
end
|
|
169
|
+
response = request(method,url,options)
|
|
170
|
+
order = Order.new(response.body)
|
|
171
|
+
return order
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def Orders.get_status(options={})
|
|
175
|
+
method = 'GET'
|
|
176
|
+
url = '/order/status'
|
|
177
|
+
parameters = {}
|
|
178
|
+
required_args = {}
|
|
179
|
+
Array[:order_id].each do |key|
|
|
180
|
+
required_args.store(key,'False')
|
|
181
|
+
end
|
|
182
|
+
options.each do |key, value|
|
|
183
|
+
parameters.store(key,value)
|
|
184
|
+
required_args[key] = 'True'
|
|
185
|
+
end
|
|
186
|
+
Array[:order_id].each do |key|
|
|
187
|
+
if required_args[key] == 'False'
|
|
188
|
+
raise "ERROR: #{key} is a required argument for Orders.get_status"
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
parameters.each do |key, _|
|
|
192
|
+
unless Array[:order_id].include?(key)
|
|
193
|
+
puts " #{key} is an invalid argument for Orders.get_status"
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
response = request(method,url,options)
|
|
197
|
+
order = Order.new(response.body)
|
|
198
|
+
return order
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def Orders.list(options={})
|
|
202
|
+
method = 'GET'
|
|
203
|
+
url = '/order/list'
|
|
204
|
+
parameters = {}
|
|
205
|
+
required_args = {}
|
|
206
|
+
Array[].each do |key|
|
|
207
|
+
required_args.store(key,'False')
|
|
208
|
+
end
|
|
209
|
+
options.each do |key, value|
|
|
210
|
+
parameters.store(key,value)
|
|
211
|
+
required_args[key] = 'True'
|
|
212
|
+
end
|
|
213
|
+
Array[].each do |key|
|
|
214
|
+
if required_args[key] == 'False'
|
|
215
|
+
raise "ERROR: #{key} is a required argument for Orders.list"
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
parameters.each do |key, _|
|
|
219
|
+
unless Array[:'created.gt', :'created.gt', :'created.lt', :'created.ge', :'created.le', :count, :offset].include?(key)
|
|
220
|
+
puts " #{key} is an invalid argument for Orders.get_status"
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
parameters.each do |key,_|
|
|
224
|
+
if key == :'created.gt'
|
|
225
|
+
if parameters[:'created.gt'].class != Fixnum
|
|
226
|
+
puts 'created.gt should be of type Numeric\n'
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
if key == :'created.lt'
|
|
230
|
+
if parameters[:'created.lt'].class != Fixnum
|
|
231
|
+
puts 'lt should be of type Numeric\n'
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
if key == :'created.ge'
|
|
235
|
+
if parameters[:'created.ge'].class != Fixnum
|
|
236
|
+
puts 'created.ge should be of type Numeric\n'
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
if key == :'created.le'
|
|
240
|
+
if parameters[:'created.le'].class != Fixnum
|
|
241
|
+
puts 'created.le should be of type Numeric\n'
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
if key == :count
|
|
245
|
+
if parameters[:count].class != Fixnum
|
|
246
|
+
puts 'count should be of type Numeric\n'
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
if key == :offset
|
|
250
|
+
if parameters[:offset].class != Fixnum
|
|
251
|
+
puts 'offset should be of type Numeric\n'
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
response = request(method,url,options).body
|
|
256
|
+
orders = {count: response['count'],total: response['total'], offset: response['offset'] }
|
|
257
|
+
list = []
|
|
258
|
+
i=0
|
|
259
|
+
while i < response['count']
|
|
260
|
+
order = Order.new(response['list'][i])
|
|
261
|
+
list.push(order)
|
|
262
|
+
i+=1
|
|
263
|
+
end
|
|
264
|
+
orders[:list] = list
|
|
265
|
+
return orders
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def Orders.update(options={})
|
|
269
|
+
method = 'POST'
|
|
270
|
+
url = '/order/create'
|
|
271
|
+
parameters = {}
|
|
272
|
+
required_args = {}
|
|
273
|
+
Array[:order_id].each do |key|
|
|
274
|
+
required_args.store(key,'False')
|
|
275
|
+
end
|
|
276
|
+
options.each do |key, value|
|
|
277
|
+
parameters.store(key,value)
|
|
278
|
+
required_args[key] = 'True'
|
|
279
|
+
end
|
|
280
|
+
Array[:order_id].each do |key|
|
|
281
|
+
if required_args[key] == 'False'
|
|
282
|
+
raise "ERROR: #{key} is a required argument for Orders.update"
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
parameters.each do |key, _|
|
|
286
|
+
unless @all_input_params.include?(key)
|
|
287
|
+
puts " #{key} is an invalid argument for Orders.create"
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
parameters.each do |key,_|
|
|
291
|
+
if key == :currency
|
|
292
|
+
puts 'currency cannot be changed\n'
|
|
293
|
+
end
|
|
294
|
+
if key == :customer_id
|
|
295
|
+
puts 'customer_id cannot be changed\n'
|
|
296
|
+
end
|
|
297
|
+
if key == :customer_email
|
|
298
|
+
puts 'customer_email cannot be changed\n'
|
|
299
|
+
end
|
|
300
|
+
if key == :customer_phone
|
|
301
|
+
puts 'customer_phone cannot be changed\n'
|
|
302
|
+
end
|
|
303
|
+
if key == :description
|
|
304
|
+
puts 'description cannot be changed\n'
|
|
305
|
+
end
|
|
306
|
+
if key == :product_id
|
|
307
|
+
puts 'product_id cannot be changed\n'
|
|
308
|
+
end
|
|
309
|
+
if key == :return_url
|
|
310
|
+
puts 'return_url cannot be changed\n'
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
response = request(method,url,options)
|
|
314
|
+
order = Order.new(response.body)
|
|
315
|
+
return order
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def Orders.refund(options={})
|
|
319
|
+
method = 'POST'
|
|
320
|
+
url = '/order/refund'
|
|
321
|
+
parameters = {}
|
|
322
|
+
required_args = {}
|
|
323
|
+
Array[:unique_request_id,:order_id].each do |key|
|
|
324
|
+
required_args.store(key,'False')
|
|
325
|
+
end
|
|
326
|
+
options.each do |key, value|
|
|
327
|
+
parameters.store(key,value)
|
|
328
|
+
required_args[key] = 'True'
|
|
329
|
+
end
|
|
330
|
+
Array[:unique_request_id,:order_id].each do |key|
|
|
331
|
+
if required_args[key] == 'False'
|
|
332
|
+
raise "ERROR: #{key} is a required argument for Orders.refund"
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
parameters.each do |key, _|
|
|
336
|
+
unless Array[:unique_request_id,:order_id, :amount].include?(key)
|
|
337
|
+
puts " #{key} is an invalid argument for Orders.create"
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
response = request(method,url,options)
|
|
341
|
+
order = Order.new(response.body)
|
|
342
|
+
return order
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
end
|
data/lib/Payments.rb
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
require_relative 'util'
|
|
2
|
+
|
|
3
|
+
class Payments
|
|
4
|
+
|
|
5
|
+
class Transaction
|
|
6
|
+
|
|
7
|
+
attr_reader :order_id, :payment, :status, :txn_id
|
|
8
|
+
class Payment
|
|
9
|
+
attr_reader :authentication
|
|
10
|
+
def initialize(options={})
|
|
11
|
+
auth = Authentication.new(get_arg(options,'authentication'))
|
|
12
|
+
@authentication = auth
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Authentication
|
|
16
|
+
attr_reader :url, :method, :params
|
|
17
|
+
def initialize(options={})
|
|
18
|
+
@method = get_arg(options, 'method')
|
|
19
|
+
@url = get_arg(options, 'url')
|
|
20
|
+
@params = get_arg(options, 'params')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
def initialize(options={})
|
|
26
|
+
@order_id = get_arg(options, 'order_id')
|
|
27
|
+
@txn_id = get_arg(options, 'txn_id')
|
|
28
|
+
@status = get_arg(options, 'status')
|
|
29
|
+
@payment = Payment.new(get_arg(options, 'payment'))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def Payments.create_card_payment(options={})
|
|
35
|
+
method = 'POST'
|
|
36
|
+
url = '/txns'
|
|
37
|
+
parameters = {}
|
|
38
|
+
required_args = {}
|
|
39
|
+
Array[:order_id, :merchant_id, :payment_method_type, :card_token, :card_number, :name_on_card,
|
|
40
|
+
:card_exp_year, :card_exp_month, :card_security_code, :save_to_locker, :redirect_after_payment,
|
|
41
|
+
:format].each do |key|
|
|
42
|
+
required_args.store(key,'False')
|
|
43
|
+
end
|
|
44
|
+
options.each do |key, value|
|
|
45
|
+
parameters.store(key,value)
|
|
46
|
+
required_args[key] = 'True'
|
|
47
|
+
end
|
|
48
|
+
Array[:order_id, :merchant_id, :payment_method_type, :card_token, :card_number, :name_on_card,
|
|
49
|
+
:card_exp_year, :card_exp_month, :card_security_code, :save_to_locker, :redirect_after_payment,
|
|
50
|
+
:format].each do |key|
|
|
51
|
+
if required_args[key] == 'False'
|
|
52
|
+
raise "ERROR: #{key} is a required argument for Payments.create_card_payment"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
parameters.each do |key, _|
|
|
56
|
+
unless Array[:order_id, :merchant_id, :payment_method_type, :payment_method, :card_token, :card_number, :name_on_card,
|
|
57
|
+
:card_exp_year, :card_exp_month, :card_security_code, :save_to_locker, :redirect_after_payment,
|
|
58
|
+
:format].include?(key)
|
|
59
|
+
puts " #{key} is an invalid argument for Payments.create_card_payment"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
if parameters[:save_to_locker] != true and parameters[:save_to_locker] != false
|
|
63
|
+
raise "ERROR: 'save_to_locker' should be true or false"
|
|
64
|
+
end
|
|
65
|
+
if parameters[:redirect_after_payment] != true and parameters[:redirect_after_payment] != false
|
|
66
|
+
raise "ERROR: 'redirect_after_payment' should be true or false"
|
|
67
|
+
end
|
|
68
|
+
response = request(method,url,options)
|
|
69
|
+
payment = Transaction.new(response.body)
|
|
70
|
+
return payment
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def Payments.create_net_banking_payment(options={})
|
|
74
|
+
method = 'POST'
|
|
75
|
+
url = '/txns'
|
|
76
|
+
parameters = {}
|
|
77
|
+
required_args = {}
|
|
78
|
+
Array[:order_id, :merchant_id, :payment_method_type, :payment_method, :redirect_after_payment, :format].each do |key|
|
|
79
|
+
required_args.store(key,'False')
|
|
80
|
+
end
|
|
81
|
+
options.each do |key, value|
|
|
82
|
+
parameters.store(key,value)
|
|
83
|
+
required_args[key] = 'True'
|
|
84
|
+
end
|
|
85
|
+
Array[:order_id, :merchant_id, :payment_method_type, :payment_method, :redirect_after_payment, :format].each do |key|
|
|
86
|
+
if required_args[key] == 'False'
|
|
87
|
+
raise "ERROR: #{key} is a required argument for Payments.create_net_banking_payment"
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
parameters.each do |key, _|
|
|
91
|
+
unless Array[:order_id, :merchant_id, :payment_method_type, :payment_method, :redirect_after_payment, :format].include?(key)
|
|
92
|
+
puts " #{key} is an invalid argument for Payments.create_net_banking_payment"
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
response = request(method,url,options)
|
|
96
|
+
payment = Transaction.new(response.body)
|
|
97
|
+
return payment
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|
data/lib/Test.rb
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
require_relative 'Orders'
|
|
2
|
+
require_relative 'Cards'
|
|
3
|
+
require_relative 'Payments'
|
|
4
|
+
require 'minitest/autorun'
|
|
5
|
+
require 'pp'
|
|
6
|
+
|
|
7
|
+
def pp(obj)
|
|
8
|
+
text = obj.pretty_inspect
|
|
9
|
+
output = ''
|
|
10
|
+
text.each_line do |line|
|
|
11
|
+
unless line.include?('=nil') or line.include?('=""')
|
|
12
|
+
output += line
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
puts output
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Test < Minitest::Test
|
|
19
|
+
|
|
20
|
+
$api_key = '4168A8A476B84DBCAF409C24F379BAC5'
|
|
21
|
+
$environment = 'production'
|
|
22
|
+
|
|
23
|
+
def setup
|
|
24
|
+
@timestamp = Time.now.to_i
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_orders
|
|
28
|
+
# Test for create
|
|
29
|
+
order = Orders.create(order_id:@timestamp, amount:1000)
|
|
30
|
+
assert_equal('CREATED', order.status)
|
|
31
|
+
#pp order
|
|
32
|
+
|
|
33
|
+
# Test for get_status
|
|
34
|
+
status = Orders.get_status(order_id:@timestamp)
|
|
35
|
+
assert_equal(Float(status.order_id), @timestamp)
|
|
36
|
+
#pp status
|
|
37
|
+
|
|
38
|
+
# Test for list
|
|
39
|
+
order_list = Orders.list
|
|
40
|
+
refute_nil(order_list)
|
|
41
|
+
#pp order_list
|
|
42
|
+
|
|
43
|
+
# Test for update
|
|
44
|
+
updated_order = Orders.update(order_id:@timestamp, amount:500)
|
|
45
|
+
status = Orders.get_status(order_id:@timestamp)
|
|
46
|
+
assert_equal(status.amount, updated_order.amount)
|
|
47
|
+
#pp updated_order
|
|
48
|
+
|
|
49
|
+
# Test for refund
|
|
50
|
+
refunded_order = Orders.refund(unique_request_id: @timestamp, order_id: 1465833326,amount: 10)
|
|
51
|
+
#pp refunded_order
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.delete_all_cards
|
|
55
|
+
card_list = Cards.list(:customer_id=>'user')
|
|
56
|
+
card_list.each do |card|
|
|
57
|
+
Cards.delete(:card_token=>card.token)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_cards
|
|
62
|
+
|
|
63
|
+
# Test for add
|
|
64
|
+
card = Cards.add(merchant_id:'shreyas', customer_id:'user', customer_email:'abc@xyz.com',
|
|
65
|
+
card_number:@timestamp*(10**6), card_exp_year:'20', card_exp_month:'12')
|
|
66
|
+
refute_nil(card.reference)
|
|
67
|
+
refute_nil(card.token)
|
|
68
|
+
refute_nil(card.fingerprint)
|
|
69
|
+
#pp card
|
|
70
|
+
# Test for delete
|
|
71
|
+
deleted_card = Cards.delete(card_token:card.token)
|
|
72
|
+
assert(true,deleted_card.deleted)
|
|
73
|
+
#pp deleted_card
|
|
74
|
+
# Test for list
|
|
75
|
+
#Test.delete_all_cards
|
|
76
|
+
Cards.add(merchant_id:'shreyas', customer_id:'user', customer_email:'abc@xyz.com',
|
|
77
|
+
card_number:@timestamp * (10 ** 6), card_exp_year:'20', card_exp_month:'12')
|
|
78
|
+
Cards.add(merchant_id:'shreyas', customer_id:'user', customer_email:'abc@xyz.com',
|
|
79
|
+
card_number:@timestamp * (10 ** 6)+1, card_exp_year:'20', card_exp_month:'12')
|
|
80
|
+
card_list = Cards.list(customer_id:'user')
|
|
81
|
+
refute_nil(card_list)
|
|
82
|
+
assert_equal(card_list.length, 2)
|
|
83
|
+
#pp card_list
|
|
84
|
+
Test.delete_all_cards
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_payments
|
|
88
|
+
|
|
89
|
+
# Test for create_card_payment
|
|
90
|
+
payment = Payments.create_card_payment(
|
|
91
|
+
order_id:1465893617,
|
|
92
|
+
merchant_id:'juspay_recharge',
|
|
93
|
+
payment_method_type:'CARD',
|
|
94
|
+
card_token:'68d6b0c6-6e77-473f-a05c-b460ef983fd8',
|
|
95
|
+
redirect_after_payment:false,
|
|
96
|
+
format:'json',
|
|
97
|
+
card_number:'5243681100075285',
|
|
98
|
+
name_on_card:'Customer',
|
|
99
|
+
card_exp_year:'20',
|
|
100
|
+
card_exp_month:'12',
|
|
101
|
+
card_security_code:'123',
|
|
102
|
+
save_to_locker:false)
|
|
103
|
+
refute_nil(payment.txn_id)
|
|
104
|
+
assert_equal(payment.status, 'PENDING_VBV')
|
|
105
|
+
pp payment
|
|
106
|
+
# Test for create_net_banking_payment
|
|
107
|
+
payment = Payments.create_net_banking_payment(
|
|
108
|
+
order_id:1465893617,
|
|
109
|
+
merchant_id:'juspay_recharge',
|
|
110
|
+
payment_method_type:'NB',
|
|
111
|
+
payment_method:'NB_ICICI',
|
|
112
|
+
redirect_after_payment:false,
|
|
113
|
+
format:'json')
|
|
114
|
+
refute_nil(payment.txn_id)
|
|
115
|
+
assert_equal(payment.status, 'PENDING_VBV')
|
|
116
|
+
pp payment
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require "expresscheckout/version"
|
|
2
|
+
|
|
3
|
+
module Expresscheckout
|
|
4
|
+
require 'unirest'
|
|
5
|
+
require_relative 'Orders'
|
|
6
|
+
require_relative 'Cards'
|
|
7
|
+
require_relative 'Payments'
|
|
8
|
+
|
|
9
|
+
$api_key = ''
|
|
10
|
+
$environment = 'production'
|
|
11
|
+
$version= {:JuspayAPILibrary=>'Ruby v1.0'}
|
|
12
|
+
end
|
data/lib/util.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require_relative 'expresscheckout'
|
|
2
|
+
|
|
3
|
+
def request(method,url,parameters={})
|
|
4
|
+
if $environment == 'production'
|
|
5
|
+
$server = 'https://api.juspay.in'
|
|
6
|
+
elsif $environment == 'staging'
|
|
7
|
+
$server = 'https://sandbox.juspay.in'
|
|
8
|
+
else
|
|
9
|
+
raise 'ERROR: environment variable can be "production" or "staging"'
|
|
10
|
+
end
|
|
11
|
+
if method == 'GET'
|
|
12
|
+
response = Unirest.get $server+url, headers: $version, auth:{:user=>$api_key, :password=>''}, parameters: parameters
|
|
13
|
+
else
|
|
14
|
+
response = Unirest.post $server +url, headers: $version, auth:{:user=>$api_key, :password=>''}, parameters: parameters
|
|
15
|
+
end
|
|
16
|
+
response
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def get_arg(options = {}, param)
|
|
20
|
+
if options == NIL
|
|
21
|
+
NIL
|
|
22
|
+
elsif options.key?(param)
|
|
23
|
+
options[param]
|
|
24
|
+
else
|
|
25
|
+
NIL
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def check_param(options = {}, param)
|
|
30
|
+
options.each do |key,_|
|
|
31
|
+
if key.include?(param)
|
|
32
|
+
return true
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
false
|
|
36
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: expresscheckout
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.5
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Juspay
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-06-14 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.12'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.12'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: minitest
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '5.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '5.0'
|
|
55
|
+
description: Juspay ExpressCheckout's Ruby API
|
|
56
|
+
email:
|
|
57
|
+
- ec@juspay.in
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".travis.yml"
|
|
64
|
+
- CODE_OF_CONDUCT.md
|
|
65
|
+
- Gemfile
|
|
66
|
+
- LICENSE.txt
|
|
67
|
+
- README.md
|
|
68
|
+
- Rakefile
|
|
69
|
+
- bin/console
|
|
70
|
+
- bin/setup
|
|
71
|
+
- expresscheckout.gemspec
|
|
72
|
+
- lib/Cards.rb
|
|
73
|
+
- lib/Orders.rb
|
|
74
|
+
- lib/Payments.rb
|
|
75
|
+
- lib/Test.rb
|
|
76
|
+
- lib/expresscheckout.rb
|
|
77
|
+
- lib/expresscheckout/version.rb
|
|
78
|
+
- lib/util.rb
|
|
79
|
+
homepage: https://www.juspay.in
|
|
80
|
+
licenses:
|
|
81
|
+
- MIT
|
|
82
|
+
metadata:
|
|
83
|
+
allowed_push_host: https://rubygems.org
|
|
84
|
+
post_install_message:
|
|
85
|
+
rdoc_options: []
|
|
86
|
+
require_paths:
|
|
87
|
+
- lib
|
|
88
|
+
- lib/Orders.rb
|
|
89
|
+
- lib/expresscheckout.rb
|
|
90
|
+
- lib/Payments.rb
|
|
91
|
+
- lib/Cards.rb
|
|
92
|
+
- lib/Test.rb
|
|
93
|
+
- lib/util.rb
|
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
- - ">="
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0'
|
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
requirements: []
|
|
105
|
+
rubyforge_project:
|
|
106
|
+
rubygems_version: 2.5.1
|
|
107
|
+
signing_key:
|
|
108
|
+
specification_version: 4
|
|
109
|
+
summary: Juspay ExpressCheckout's Ruby API
|
|
110
|
+
test_files: []
|