spree_razorpay 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +280 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +19 -0
- data/app/assets/images/PayWithRzp.png +0 -0
- data/app/assets/stylesheets/spree/razorpay.scss +12 -0
- data/app/controllers/spree/razorpay_controller.rb +25 -0
- data/app/models/spree/gateway/razorpay_gateway.rb +38 -0
- data/app/models/spree/order_decorator.rb +48 -0
- data/app/models/spree/razorpay_checkout.rb +4 -0
- data/app/views/spree/admin/payments/source_views/_razorpay.html.erb +0 -0
- data/app/views/spree/checkout/payment/_razorpay.html.erb +56 -0
- data/app/views/spree/razorpay/create.html.erb +0 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20180902203415_create_spree_razorpay_checkouts.rb +18 -0
- data/lib/generators/spree_razorpay/install/install_generator.rb +31 -0
- data/lib/spree_razorpay.rb +6 -0
- data/lib/spree_razorpay/engine.rb +26 -0
- data/lib/spree_razorpay/version.rb +3 -0
- data/spree_razorpay.gemspec +41 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 051b900ff5b5e78473d8b8ee848d2e48552004bf622b813c2b981ab23a023b36
|
4
|
+
data.tar.gz: df238fcfa7611495f6a2d274857974c0a2fbc027fc6ea20723b9bc3d88716c18
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c58ab0facd91c0d9528357445e470de1ceba1e7ec111a39aba9eb5cffba6fe465d9208184ec5231512d1b2d898122b1d75998cec7866e712d7f1c32ed059e9cc
|
7
|
+
data.tar.gz: 0621a50d2715e3fdb453fed107bc6e87209d25f5fa82ac8c2ea76a38184b23b85cb946d195013fdd6bc05d83441fb2349fa4625ed162fdbe30287bec191ed0ff
|
data/.gitignore
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 neeraj.kumar@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/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gem 'razorpay'
|
4
|
+
gem 'rspec'
|
5
|
+
gem 'vcr'
|
6
|
+
gem 'webmock'
|
7
|
+
gem 'spree_core'
|
8
|
+
|
9
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
10
|
+
|
11
|
+
# Specify your gem's dependencies in spree-razorpay.gemspec
|
12
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
spree_razorpay (0.1.4)
|
5
|
+
razorpay
|
6
|
+
spree_core
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actioncable (5.2.0)
|
12
|
+
actionpack (= 5.2.0)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
actionmailer (5.2.0)
|
16
|
+
actionpack (= 5.2.0)
|
17
|
+
actionview (= 5.2.0)
|
18
|
+
activejob (= 5.2.0)
|
19
|
+
mail (~> 2.5, >= 2.5.4)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
actionpack (5.2.0)
|
22
|
+
actionview (= 5.2.0)
|
23
|
+
activesupport (= 5.2.0)
|
24
|
+
rack (~> 2.0)
|
25
|
+
rack-test (>= 0.6.3)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
28
|
+
actionview (5.2.0)
|
29
|
+
activesupport (= 5.2.0)
|
30
|
+
builder (~> 3.1)
|
31
|
+
erubi (~> 1.4)
|
32
|
+
rails-dom-testing (~> 2.0)
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
34
|
+
activejob (5.2.0)
|
35
|
+
activesupport (= 5.2.0)
|
36
|
+
globalid (>= 0.3.6)
|
37
|
+
activemerchant (1.83.0)
|
38
|
+
activesupport (>= 4.2, < 6.x)
|
39
|
+
builder (>= 2.1.2, < 4.0.0)
|
40
|
+
i18n (>= 0.6.9)
|
41
|
+
nokogiri (~> 1.4)
|
42
|
+
activemodel (5.2.0)
|
43
|
+
activesupport (= 5.2.0)
|
44
|
+
activerecord (5.2.0)
|
45
|
+
activemodel (= 5.2.0)
|
46
|
+
activesupport (= 5.2.0)
|
47
|
+
arel (>= 9.0)
|
48
|
+
activestorage (5.2.0)
|
49
|
+
actionpack (= 5.2.0)
|
50
|
+
activerecord (= 5.2.0)
|
51
|
+
marcel (~> 0.3.1)
|
52
|
+
activesupport (5.2.0)
|
53
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
54
|
+
i18n (>= 0.7, < 2)
|
55
|
+
minitest (~> 5.1)
|
56
|
+
tzinfo (~> 1.1)
|
57
|
+
acts-as-taggable-on (6.0.0)
|
58
|
+
activerecord (~> 5.0)
|
59
|
+
acts_as_list (0.9.16)
|
60
|
+
activerecord (>= 3.0)
|
61
|
+
addressable (2.5.2)
|
62
|
+
public_suffix (>= 2.0.2, < 4.0)
|
63
|
+
arel (9.0.0)
|
64
|
+
awesome_nested_set (3.1.4)
|
65
|
+
activerecord (>= 4.0.0, < 5.3)
|
66
|
+
builder (3.2.3)
|
67
|
+
camertron-eprun (1.1.1)
|
68
|
+
cancancan (2.2.0)
|
69
|
+
carmen (1.0.2)
|
70
|
+
activesupport (>= 3.0.0)
|
71
|
+
cldr-plurals-runtime-rb (1.0.1)
|
72
|
+
climate_control (0.2.0)
|
73
|
+
concurrent-ruby (1.0.5)
|
74
|
+
crack (0.4.3)
|
75
|
+
safe_yaml (~> 1.0.0)
|
76
|
+
crass (1.0.4)
|
77
|
+
css_parser (1.6.0)
|
78
|
+
addressable
|
79
|
+
deface (1.3.0)
|
80
|
+
nokogiri (~> 1.6)
|
81
|
+
polyglot
|
82
|
+
rails (>= 4.1)
|
83
|
+
rainbow (>= 2.1.0)
|
84
|
+
diff-lcs (1.3)
|
85
|
+
erubi (1.7.1)
|
86
|
+
ffaker (2.10.0)
|
87
|
+
friendly_id (5.2.4)
|
88
|
+
activerecord (>= 4.0.0)
|
89
|
+
globalid (0.4.1)
|
90
|
+
activesupport (>= 4.2.0)
|
91
|
+
hashdiff (0.3.7)
|
92
|
+
highline (1.6.21)
|
93
|
+
htmlentities (4.3.4)
|
94
|
+
httparty (0.16.2)
|
95
|
+
multi_xml (>= 0.5.2)
|
96
|
+
i18n (1.0.1)
|
97
|
+
concurrent-ruby (~> 1.0)
|
98
|
+
kaminari (1.0.1)
|
99
|
+
activesupport (>= 4.1.0)
|
100
|
+
kaminari-actionview (= 1.0.1)
|
101
|
+
kaminari-activerecord (= 1.0.1)
|
102
|
+
kaminari-core (= 1.0.1)
|
103
|
+
kaminari-actionview (1.0.1)
|
104
|
+
actionview
|
105
|
+
kaminari-core (= 1.0.1)
|
106
|
+
kaminari-activerecord (1.0.1)
|
107
|
+
activerecord
|
108
|
+
kaminari-core (= 1.0.1)
|
109
|
+
kaminari-core (1.0.1)
|
110
|
+
loofah (2.2.2)
|
111
|
+
crass (~> 1.0.2)
|
112
|
+
nokogiri (>= 1.5.9)
|
113
|
+
mail (2.7.0)
|
114
|
+
mini_mime (>= 0.1.1)
|
115
|
+
marcel (0.3.2)
|
116
|
+
mimemagic (~> 0.3.2)
|
117
|
+
method_source (0.9.0)
|
118
|
+
mime-types (3.2.2)
|
119
|
+
mime-types-data (~> 3.2015)
|
120
|
+
mime-types-data (3.2018.0812)
|
121
|
+
mimemagic (0.3.2)
|
122
|
+
mini_magick (4.8.0)
|
123
|
+
mini_mime (1.0.1)
|
124
|
+
mini_portile2 (2.3.0)
|
125
|
+
minitest (5.11.3)
|
126
|
+
monetize (1.9.0)
|
127
|
+
money (~> 6.12)
|
128
|
+
money (6.12.0)
|
129
|
+
i18n (>= 0.6.4, < 1.1)
|
130
|
+
multi_xml (0.6.0)
|
131
|
+
nio4r (2.3.1)
|
132
|
+
nokogiri (1.8.4)
|
133
|
+
mini_portile2 (~> 2.3.0)
|
134
|
+
paperclip (6.0.0)
|
135
|
+
activemodel (>= 4.2.0)
|
136
|
+
activesupport (>= 4.2.0)
|
137
|
+
mime-types
|
138
|
+
mimemagic (~> 0.3.0)
|
139
|
+
terrapin (~> 0.6.0)
|
140
|
+
paranoia (2.4.1)
|
141
|
+
activerecord (>= 4.0, < 5.3)
|
142
|
+
polyamorous (1.3.3)
|
143
|
+
activerecord (>= 3.0)
|
144
|
+
polyglot (0.3.5)
|
145
|
+
premailer (1.11.1)
|
146
|
+
addressable
|
147
|
+
css_parser (>= 1.6.0)
|
148
|
+
htmlentities (>= 4.0.0)
|
149
|
+
premailer-rails (1.10.2)
|
150
|
+
actionmailer (>= 3, < 6)
|
151
|
+
premailer (~> 1.7, >= 1.7.9)
|
152
|
+
public_suffix (3.0.3)
|
153
|
+
rack (2.0.5)
|
154
|
+
rack-test (1.1.0)
|
155
|
+
rack (>= 1.0, < 3)
|
156
|
+
rails (5.2.0)
|
157
|
+
actioncable (= 5.2.0)
|
158
|
+
actionmailer (= 5.2.0)
|
159
|
+
actionpack (= 5.2.0)
|
160
|
+
actionview (= 5.2.0)
|
161
|
+
activejob (= 5.2.0)
|
162
|
+
activemodel (= 5.2.0)
|
163
|
+
activerecord (= 5.2.0)
|
164
|
+
activestorage (= 5.2.0)
|
165
|
+
activesupport (= 5.2.0)
|
166
|
+
bundler (>= 1.3.0)
|
167
|
+
railties (= 5.2.0)
|
168
|
+
sprockets-rails (>= 2.0.0)
|
169
|
+
rails-dom-testing (2.0.3)
|
170
|
+
activesupport (>= 4.2.0)
|
171
|
+
nokogiri (>= 1.6)
|
172
|
+
rails-html-sanitizer (1.0.4)
|
173
|
+
loofah (~> 2.2, >= 2.2.2)
|
174
|
+
railties (5.2.0)
|
175
|
+
actionpack (= 5.2.0)
|
176
|
+
activesupport (= 5.2.0)
|
177
|
+
method_source
|
178
|
+
rake (>= 0.8.7)
|
179
|
+
thor (>= 0.18.1, < 2.0)
|
180
|
+
rainbow (3.0.0)
|
181
|
+
rake (10.5.0)
|
182
|
+
ransack (1.8.8)
|
183
|
+
actionpack (>= 3.0)
|
184
|
+
activerecord (>= 3.0)
|
185
|
+
activesupport (>= 3.0)
|
186
|
+
i18n
|
187
|
+
polyamorous (~> 1.3.2)
|
188
|
+
razorpay (2.3.0)
|
189
|
+
httparty (~> 0.14)
|
190
|
+
responders (2.4.0)
|
191
|
+
actionpack (>= 4.2.0, < 5.3)
|
192
|
+
railties (>= 4.2.0, < 5.3)
|
193
|
+
rspec (3.8.0)
|
194
|
+
rspec-core (~> 3.8.0)
|
195
|
+
rspec-expectations (~> 3.8.0)
|
196
|
+
rspec-mocks (~> 3.8.0)
|
197
|
+
rspec-core (3.8.0)
|
198
|
+
rspec-support (~> 3.8.0)
|
199
|
+
rspec-expectations (3.8.1)
|
200
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
201
|
+
rspec-support (~> 3.8.0)
|
202
|
+
rspec-mocks (3.8.0)
|
203
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
204
|
+
rspec-support (~> 3.8.0)
|
205
|
+
rspec-support (3.8.0)
|
206
|
+
safe_yaml (1.0.4)
|
207
|
+
spree_core (3.6.3)
|
208
|
+
activemerchant (~> 1.67)
|
209
|
+
acts-as-taggable-on (~> 6.0)
|
210
|
+
acts_as_list (~> 0.8)
|
211
|
+
awesome_nested_set (~> 3.1.3)
|
212
|
+
cancancan (~> 2.0)
|
213
|
+
carmen (~> 1.0.0)
|
214
|
+
deface (~> 1.0)
|
215
|
+
ffaker (~> 2.2)
|
216
|
+
friendly_id (~> 5.2.1)
|
217
|
+
highline (~> 1.6.18)
|
218
|
+
kaminari (~> 1.0.1)
|
219
|
+
mini_magick (~> 4.8.0)
|
220
|
+
monetize (~> 1.1)
|
221
|
+
paperclip (~> 6.0.0)
|
222
|
+
paranoia (~> 2.4.1)
|
223
|
+
premailer-rails
|
224
|
+
rails (= 5.2.0)
|
225
|
+
ransack (~> 1.8.0)
|
226
|
+
responders
|
227
|
+
sprockets-rails
|
228
|
+
state_machines-activerecord (~> 0.5)
|
229
|
+
stringex
|
230
|
+
twitter_cldr (~> 4.3)
|
231
|
+
sprockets (3.7.2)
|
232
|
+
concurrent-ruby (~> 1.0)
|
233
|
+
rack (> 1, < 3)
|
234
|
+
sprockets-rails (3.2.1)
|
235
|
+
actionpack (>= 4.0)
|
236
|
+
activesupport (>= 4.0)
|
237
|
+
sprockets (>= 3.0.0)
|
238
|
+
state_machines (0.5.0)
|
239
|
+
state_machines-activemodel (0.5.1)
|
240
|
+
activemodel (>= 4.1, < 6.0)
|
241
|
+
state_machines (>= 0.5.0)
|
242
|
+
state_machines-activerecord (0.5.1)
|
243
|
+
activerecord (>= 4.1, < 6.0)
|
244
|
+
state_machines-activemodel (>= 0.5.0)
|
245
|
+
stringex (2.8.4)
|
246
|
+
terrapin (0.6.0)
|
247
|
+
climate_control (>= 0.0.3, < 1.0)
|
248
|
+
thor (0.20.0)
|
249
|
+
thread_safe (0.3.6)
|
250
|
+
twitter_cldr (4.4.3)
|
251
|
+
camertron-eprun
|
252
|
+
cldr-plurals-runtime-rb (~> 1.0)
|
253
|
+
tzinfo
|
254
|
+
tzinfo (1.2.5)
|
255
|
+
thread_safe (~> 0.1)
|
256
|
+
vcr (4.0.0)
|
257
|
+
webmock (3.4.2)
|
258
|
+
addressable (>= 2.3.6)
|
259
|
+
crack (>= 0.3.2)
|
260
|
+
hashdiff
|
261
|
+
websocket-driver (0.7.0)
|
262
|
+
websocket-extensions (>= 0.1.0)
|
263
|
+
websocket-extensions (0.1.3)
|
264
|
+
|
265
|
+
PLATFORMS
|
266
|
+
ruby
|
267
|
+
|
268
|
+
DEPENDENCIES
|
269
|
+
bundler (~> 1.16)
|
270
|
+
minitest (~> 5.0)
|
271
|
+
rake (~> 10.0)
|
272
|
+
razorpay
|
273
|
+
rspec
|
274
|
+
spree_core
|
275
|
+
spree_razorpay!
|
276
|
+
vcr
|
277
|
+
webmock
|
278
|
+
|
279
|
+
BUNDLED WITH
|
280
|
+
1.16.5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Neeraj Kumar
|
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,50 @@
|
|
1
|
+
# SpreeRazorpay
|
2
|
+
|
3
|
+
Razorpay payment gateway integration for Spree
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'spree_razorpay'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install spree_razorpay
|
20
|
+
|
21
|
+
Add migrations from extension:
|
22
|
+
|
23
|
+
$ rails g spree_razorpay:install
|
24
|
+
|
25
|
+
Restart your server
|
26
|
+
|
27
|
+
Add new payment method with provider
|
28
|
+
|
29
|
+
Spree::Gateway::RazorpayGateway
|
30
|
+
|
31
|
+
Get **Key ID** and **Key Secret** from your razorpay sandbox account. If you don't have it you can sign up and get from
|
32
|
+
[https://dashboard.razorpay.com/#/app/keys](https://dashboard.razorpay.com/#/app/keys).
|
33
|
+
|
34
|
+
## Development
|
35
|
+
|
36
|
+
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.
|
37
|
+
|
38
|
+
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).
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/neerajkumar/spree-razorpay. 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.
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
47
|
+
|
48
|
+
## Code of Conduct
|
49
|
+
|
50
|
+
Everyone interacting in the SpreeRazorpay project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/neerajkumar/spree-razorpay/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :test
|
11
|
+
|
12
|
+
desc 'Generates a dummy app for testing'
|
13
|
+
task :test_app do
|
14
|
+
ENV['LIB_NAME'] = 'spree_razorpay'
|
15
|
+
Rake::Task['extension:test_app'].invoke
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'spree/testing_support/extension_rake'
|
19
|
+
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
.razorpay-payment-button {
|
2
|
+
background: url(asset_path('PayWithRzp.png')) center no-repeat;
|
3
|
+
background-size: contain;
|
4
|
+
box-shadow: none;
|
5
|
+
border: none;
|
6
|
+
outline: none;
|
7
|
+
font-size: 0;
|
8
|
+
height: 36px;
|
9
|
+
width: 230px;
|
10
|
+
padding: 0;
|
11
|
+
cursor: pointer;
|
12
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Spree
|
2
|
+
class RazorpayController < StoreController
|
3
|
+
|
4
|
+
skip_before_action :verify_authenticity_token
|
5
|
+
|
6
|
+
def create
|
7
|
+
response_status = Spree::Order.process_razorpayment(params, current_order)
|
8
|
+
@order = current_order
|
9
|
+
if response_status == 'captured'
|
10
|
+
@order.next
|
11
|
+
@message = Spree.t(:order_processed_successfully)
|
12
|
+
@current_order = nil
|
13
|
+
flash.notice = Spree.t(:order_processed_successfully)
|
14
|
+
flash['order_completed'] = true
|
15
|
+
@error = false
|
16
|
+
@redirect_path = order_path(@order)
|
17
|
+
else
|
18
|
+
@order.update_attributes(payment_state: "failed")
|
19
|
+
@error = true
|
20
|
+
@message = "There was an error processing your payment"
|
21
|
+
@redirect_path = checkout_state_path(@order.state)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Spree
|
2
|
+
class Gateway::RazorpayGateway < Gateway
|
3
|
+
preference :key_id, :string
|
4
|
+
preference :key_secret, :string
|
5
|
+
preference :merchant_name, :string
|
6
|
+
preference :merchant_description, :text
|
7
|
+
preference :merchant_address, :string
|
8
|
+
preference :theme_color, :string, default: '#F37254'
|
9
|
+
|
10
|
+
def supports?(source)
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def provider_class
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def provider
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def auto_capture?
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
def method_type
|
27
|
+
'razorpay'
|
28
|
+
end
|
29
|
+
|
30
|
+
def purchase(amount, transaction_details, gateway_options={})
|
31
|
+
ActiveMerchant::Billing::Response.new(true, 'razorpay success')
|
32
|
+
end
|
33
|
+
|
34
|
+
def request_type
|
35
|
+
'DEFAULT'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
Spree::Order.class_eval do
|
2
|
+
|
3
|
+
def self.process_razorpayment(params, order)
|
4
|
+
payment_method = Spree::PaymentMethod.find(params[:payment_method_id])
|
5
|
+
setup_razorpay(payment_method)
|
6
|
+
razorpay_pmnt_obj = Razorpay::Payment.fetch(params[:razorpay_payment_id])
|
7
|
+
status = razorpay_pmnt_obj.status
|
8
|
+
payment = payment(order, razorpay_pmnt_obj, payment_method)
|
9
|
+
if status == "authorized"
|
10
|
+
razorpay_pmnt_obj.capture({ amount: order.amount_in_paise })
|
11
|
+
razorpay_pmnt_obj = Razorpay::Payment.fetch(params[:razorpay_payment_id])
|
12
|
+
payment.update(response_code: razorpay_pmnt_obj.status)
|
13
|
+
razorpay_pmnt_obj.status
|
14
|
+
else
|
15
|
+
raise StandardError, "Unable to capture payment"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def amount_in_paise
|
20
|
+
(amount.to_f * 100).to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.setup_razorpay(payment_method)
|
24
|
+
Razorpay.setup(payment_method.preferences[:key_id], payment_method.preferences[:key_secret])
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.payment(order, payment_object, payment_method)
|
28
|
+
order.payments.create!(
|
29
|
+
source: Spree::RazorpayCheckout.create(
|
30
|
+
order_id: order.id,
|
31
|
+
razorpay_payment_id: payment_object.id,
|
32
|
+
status: payment_object.status,
|
33
|
+
payment_method: payment_object.method,
|
34
|
+
card_id: payment_object.card_id,
|
35
|
+
bank: payment_object.bank,
|
36
|
+
wallet: payment_object.wallet,
|
37
|
+
vpa: payment_object.vpa,
|
38
|
+
email: payment_object.email,
|
39
|
+
contact: payment_object.contact
|
40
|
+
),
|
41
|
+
payment_method: payment_method,
|
42
|
+
amount: order.total,
|
43
|
+
response_code: payment_object.status
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
private_class_method :setup_razorpay, :payment
|
48
|
+
end
|
File without changes
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
|
2
|
+
<script src="http://malsup.github.io/jquery.blockUI.js"></script>
|
3
|
+
|
4
|
+
<div id='razorpay' class='btn razorpay-payment-button pull-right'>
|
5
|
+
Pay by Razorpay
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div id='blockUI-message' style='display: none;'>
|
9
|
+
<h1>
|
10
|
+
<b>HOLDON!</b>
|
11
|
+
While we connect you back to merchant's site
|
12
|
+
</h1>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<script>
|
16
|
+
$(document).ready(function(){
|
17
|
+
|
18
|
+
$("#razorpay").click(function() {
|
19
|
+
var options = {
|
20
|
+
"key": "<%= payment_method.preferences[:key_id] %>",
|
21
|
+
"amount": "<%= current_order.amount_in_paise %>",
|
22
|
+
'name': "<%= payment_method.preferences[:merchant_name] %>",
|
23
|
+
'description': "<%= payment_method.preferences[:merchant_description] %>",
|
24
|
+
"handler": function (response){
|
25
|
+
$(document).ajaxStart(function() {
|
26
|
+
$.blockUI({ message: $('#blockUI-message') });
|
27
|
+
});
|
28
|
+
$.ajax({
|
29
|
+
type: 'POST',
|
30
|
+
url: "/razorpay",
|
31
|
+
data: { payment_method_id: "<%= payment_method.id %>", razorpay_payment_id: response.razorpay_payment_id },
|
32
|
+
dataType: 'html'
|
33
|
+
}).done(function(data){
|
34
|
+
$.blockUI({ message: $('#blockUI-message') });
|
35
|
+
setTimeout(function(){
|
36
|
+
window.location.replace("/orders/<%= current_order.number %>");
|
37
|
+
}, 5000);
|
38
|
+
});
|
39
|
+
},
|
40
|
+
"prefill": {
|
41
|
+
"name": "<%= spree_current_user.try(:email) %>",
|
42
|
+
"email": "<%= spree_current_user.try(:email) %>"
|
43
|
+
},
|
44
|
+
"notes": {
|
45
|
+
"address": "<%= payment_method.preferences[:merchant_address] %>"
|
46
|
+
},
|
47
|
+
"theme": {
|
48
|
+
"color": "<%= payment_method.preferences[:theme_color] %>"
|
49
|
+
}
|
50
|
+
};
|
51
|
+
var rzp1 = new Razorpay(options);
|
52
|
+
rzp1.open();
|
53
|
+
});
|
54
|
+
|
55
|
+
});
|
56
|
+
</script>
|
File without changes
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "spree_razorpay"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/config/routes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateSpreeRazorpayCheckouts < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :spree_razorpay_checkouts do |t|
|
4
|
+
t.string :order_id
|
5
|
+
t.string :razorpay_payment_id
|
6
|
+
t.string :status
|
7
|
+
t.string :payment_method
|
8
|
+
t.string :card_id
|
9
|
+
t.string :bank
|
10
|
+
t.string :wallet
|
11
|
+
t.string :vpa
|
12
|
+
t.string :email
|
13
|
+
t.string :contact
|
14
|
+
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module SpreeRazorpay
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
class_option :auto_run_migrations, :type => :boolean, :default => false
|
6
|
+
|
7
|
+
def add_stylesheets
|
8
|
+
if File.exists?('vendor/assets/stylesheets/spree/frontend/all.css')
|
9
|
+
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/razorpay\n", :before => /\*\//, :verbose => true
|
10
|
+
elsif File.exists?('vendor/assets/stylesheets/spree/frontend/all.css.scss')
|
11
|
+
append_file 'vendor/assets/stylesheets/spree/frontend/all.css.scss', "\n@import 'spree/razorpay'\n"
|
12
|
+
elsif File.exists?('vendor/assets/stylesheets/spree/frontend/all.scss')
|
13
|
+
append_file 'vendor/assets/stylesheets/spree/frontend/all.scss', "\n@import 'spree/razorpay'\n"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_migrations
|
18
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_razorpay'
|
19
|
+
end
|
20
|
+
|
21
|
+
def run_migrations
|
22
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
|
23
|
+
if run_migrations
|
24
|
+
run 'bundle exec rake db:migrate'
|
25
|
+
else
|
26
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SpreeRazorpay
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
require 'spree/core'
|
4
|
+
isolate_namespace Spree
|
5
|
+
engine_name 'spree_razorpay'
|
6
|
+
|
7
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
8
|
+
|
9
|
+
# use rspec for tests
|
10
|
+
config.generators do |g|
|
11
|
+
g.test_framework :rspec
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.activate
|
15
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
16
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
initializer 'spree.gateway.payment_methods', after: 'spree.register.payment_methods' do |app|
|
21
|
+
app.config.spree.payment_methods << Spree::Gateway::RazorpayGateway
|
22
|
+
end
|
23
|
+
|
24
|
+
config.to_prepare &method(:activate).to_proc
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "spree_razorpay/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.platform = Gem::Platform::RUBY
|
8
|
+
spec.name = "spree_razorpay"
|
9
|
+
spec.version = SpreeRazorpay::VERSION
|
10
|
+
spec.authors = ["Neeraj Kumar"]
|
11
|
+
spec.email = ["neeraj.kumar@gmail.com"]
|
12
|
+
|
13
|
+
spec.summary = %q{Razorpay integration into spree application.}
|
14
|
+
spec.description = spec.summary
|
15
|
+
spec.homepage = "https://github.com/neerajkumar/spree-razorpay"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
spec.metadata["allowed_push_host"] = 'https://rubygems.org'
|
22
|
+
else
|
23
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
24
|
+
"public gem pushes."
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
f.match(%r{^(test|spec|features)/})
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
spec.requirements << 'none'
|
34
|
+
|
35
|
+
spec.add_dependency 'spree_core'
|
36
|
+
spec.add_dependency 'razorpay'
|
37
|
+
|
38
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
39
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
40
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_razorpay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Neeraj Kumar
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: spree_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: razorpay
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
description: Razorpay integration into spree application.
|
84
|
+
email:
|
85
|
+
- neeraj.kumar@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- CODE_OF_CONDUCT.md
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- app/assets/images/PayWithRzp.png
|
99
|
+
- app/assets/stylesheets/spree/razorpay.scss
|
100
|
+
- app/controllers/spree/razorpay_controller.rb
|
101
|
+
- app/models/spree/gateway/razorpay_gateway.rb
|
102
|
+
- app/models/spree/order_decorator.rb
|
103
|
+
- app/models/spree/razorpay_checkout.rb
|
104
|
+
- app/views/spree/admin/payments/source_views/_razorpay.html.erb
|
105
|
+
- app/views/spree/checkout/payment/_razorpay.html.erb
|
106
|
+
- app/views/spree/razorpay/create.html.erb
|
107
|
+
- bin/console
|
108
|
+
- bin/setup
|
109
|
+
- config/routes.rb
|
110
|
+
- db/migrate/20180902203415_create_spree_razorpay_checkouts.rb
|
111
|
+
- lib/generators/spree_razorpay/install/install_generator.rb
|
112
|
+
- lib/spree_razorpay.rb
|
113
|
+
- lib/spree_razorpay/engine.rb
|
114
|
+
- lib/spree_razorpay/version.rb
|
115
|
+
- spree_razorpay.gemspec
|
116
|
+
homepage: https://github.com/neerajkumar/spree-razorpay
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata:
|
120
|
+
allowed_push_host: https://rubygems.org
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements:
|
136
|
+
- none
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.7.7
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Razorpay integration into spree application.
|
142
|
+
test_files: []
|