cashfree 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cashfree.rb +52 -0
  3. metadata +97 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 136d2c105f849b16191b11b2168b91a742daf163b1d6694c32f2dfbffafc4f4e
4
+ data.tar.gz: da946cbc7b0a944a21736552c35bb3e9d38350e1cdf59247abc280a69605a130
5
+ SHA512:
6
+ metadata.gz: 9ae6ce76f99dd626aea2d9f3d29476aa66a89844f699c9aaac99057ebf87cbd5227eb4176521b5cbce298598c04f8af2eb16d0638ae5759479861e8d1444db28
7
+ data.tar.gz: 7cc461d5babe933796650e2d5184f408deca53680da2a26ae595f5d3332d73f42a35c52f869b45ae58ab131d6f5c7043dc7ebc271d47cd025e74e46a499291bf
data/lib/cashfree.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require 'openssl'
4
+ require 'json'
5
+ module Cashfree
6
+ class Cashfree
7
+ def generate_order order_id, customer_id, amount, email, mobile, order_currency = "INR"
8
+ url = URI(CASHFREE_URL) #["https://api.cashfree.com/pg/orders", "https://sandbox.cashfree.com/pg/orders"]
9
+ http = Net::HTTP.new(url.host, url.port)
10
+ http.use_ssl = true
11
+ request = Net::HTTP::Post.new(url)
12
+ request["accept"] = 'application/json'
13
+ request["x-client-id"] = FREECASH_APPID
14
+ request["x-client-secret"] = FREECASH_APPSECRET
15
+ request["x-api-version"] = FREECASH_API_VERSION
16
+ request["content-type"] = 'application/json'
17
+ request.body = {
18
+ "customer_details": {
19
+ "customer_id": "#{customer_id}",
20
+ "customer_email": "#{email}",
21
+ "customer_phone": "#{mobile}",
22
+ },
23
+ "order_meta": {
24
+ "return_url": "#{CASHFREE_RETURN_URL}"
25
+ },
26
+ "order_id": "#{order_id}",
27
+ "order_amount": amount,
28
+ "order_currency": order_currency
29
+ }.to_json
30
+ response = http.request(request)
31
+ return response.read_body
32
+ end
33
+
34
+ def validate_payment order_id
35
+ url = URI("#{CASHFREE_URL}/#{order_id}")
36
+ http = Net::HTTP.new(url.host, url.port)
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
43
+ response = http.request(request)
44
+ data = JSON.parse(response.read_body)
45
+ if data["order_status"] == "PAID"
46
+ data["order_amount"].to_f*100
47
+ else
48
+ false
49
+ end
50
+ end
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cashfree
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Awijeet Shandilya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: net-http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.3.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.3'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.3.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: json
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.6'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.6.3
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '2.6'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.6.3
53
+ - !ruby/object:Gem::Dependency
54
+ name: openssl
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: 2.2.1
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: 2.2.1
67
+ description: Cashfree
68
+ email: awijeet@rubyonrails4ror.com
69
+ executables: []
70
+ extensions: []
71
+ extra_rdoc_files: []
72
+ files:
73
+ - lib/cashfree.rb
74
+ homepage: https://rubygems.org/gems/cashfree
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubygems_version: 3.2.32
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Cashfree
97
+ test_files: []