cashfree 0.0.0 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cashfree.rb +34 -21
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 933b1bcbe86a5febc20bdbf6fa76b43cc375bc700ec452d6e923d6f2af6b7220
|
4
|
+
data.tar.gz: 6ea1433fc82ddb82f1cd08a64c0ae48c643830590e79b2a09e72e9a3b0217a85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c817b1d5ba887eb40c8c9654b0208a1e9b3c1acfcf56e47e59dd01da70441e2c23920f00dd49d4891416ddb8f8dc1f55ba32d9e206c45c33580a1a85c10d081d
|
7
|
+
data.tar.gz: eec1cf87f4936961eaebba4ae5a441c9ce52b4d7cbb7ff2788115eea5ef10a53ffa3943d6ab1c25768ad37ae9bd57998c9da1d1693bb2a3a5fe1de74e29349bf
|
data/lib/cashfree.rb
CHANGED
@@ -3,17 +3,19 @@ require 'net/http'
|
|
3
3
|
require 'openssl'
|
4
4
|
require 'json'
|
5
5
|
module Cashfree
|
6
|
-
class Cashfree
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
class Cashfree
|
7
|
+
def initialize app_id, app_secret, app_version, cashfree_url, cashfree_return_url
|
8
|
+
@app_id = app_id
|
9
|
+
@app_secret = app_secret
|
10
|
+
@app_version = app_version
|
11
|
+
@cashfree_url = cashfree_url
|
12
|
+
@cashfree_return_url = cashfree_return_url
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate_order order_id, amount, email, mobile, customer_id = nil, order_currency = "INR"
|
16
|
+
customer_id ||= mobile.gsub("+91","")
|
17
|
+
url = URI(@cashfree_url)
|
18
|
+
http, request = update_request url
|
17
19
|
request.body = {
|
18
20
|
"customer_details": {
|
19
21
|
"customer_id": "#{customer_id}",
|
@@ -21,7 +23,7 @@ module Cashfree
|
|
21
23
|
"customer_phone": "#{mobile}",
|
22
24
|
},
|
23
25
|
"order_meta": {
|
24
|
-
"return_url": "#{
|
26
|
+
"return_url": "#{@cashfree_return_url}"
|
25
27
|
},
|
26
28
|
"order_id": "#{order_id}",
|
27
29
|
"order_amount": amount,
|
@@ -32,14 +34,8 @@ module Cashfree
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def validate_payment order_id
|
35
|
-
url = URI("#{
|
36
|
-
http =
|
37
|
-
http.use_ssl = true
|
38
|
-
request = Net::HTTP::Get.new(url)
|
39
|
-
request["accept"] = 'application/json'
|
40
|
-
request["x-client-id"] = FREECASH_APPID
|
41
|
-
request["x-client-secret"] = FREECASH_APPSECRET
|
42
|
-
request["x-api-version"] = FREECASH_API_VERSION
|
37
|
+
url = URI("#{@cashfree_url}/#{order_id}")
|
38
|
+
http, request = update_request url
|
43
39
|
response = http.request(request)
|
44
40
|
data = JSON.parse(response.read_body)
|
45
41
|
if data["order_status"] == "PAID"
|
@@ -47,6 +43,23 @@ module Cashfree
|
|
47
43
|
else
|
48
44
|
false
|
49
45
|
end
|
50
|
-
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def update_request url
|
50
|
+
http = Net::HTTP.new(url.host, url.port)
|
51
|
+
http.use_ssl = true
|
52
|
+
request = Net::HTTP::Post.new(url)
|
53
|
+
request["accept"] = 'application/json'
|
54
|
+
request["x-client-id"] = @app_id
|
55
|
+
request["x-client-secret"] = @app_secret
|
56
|
+
request["x-api-version"] = @app_version
|
57
|
+
request["content-type"] = 'application/json'
|
58
|
+
return http, request
|
59
|
+
end
|
51
60
|
end
|
52
61
|
end
|
62
|
+
|
63
|
+
|
64
|
+
#gem build cashfree.gemspec
|
65
|
+
#gem install ./cashfree-0.0.1.gem
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cashfree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Awijeet Shandilya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-http
|
@@ -71,7 +71,7 @@ extensions: []
|
|
71
71
|
extra_rdoc_files: []
|
72
72
|
files:
|
73
73
|
- lib/cashfree.rb
|
74
|
-
homepage: https://
|
74
|
+
homepage: https://github.com/aw-madhulata/cashfree
|
75
75
|
licenses:
|
76
76
|
- MIT
|
77
77
|
metadata: {}
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
93
|
+
rubygems_version: 3.1.6
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Cashfree
|