khalti 0.1.0 → 0.1.1
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 +4 -4
- data/.gitignore +1 -0
- data/README.md +13 -2
- data/lib/khalti/transaction.rb +38 -0
- data/lib/khalti/verification.rb +24 -0
- data/lib/khalti/version.rb +1 -1
- data/lib/khalti.rb +3 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f710f282228b97bc8f188a6f68f296df93174b5a54373d4c78df014c6f26cbee
|
4
|
+
data.tar.gz: bfa511624d569ae7dd9d598c2cd9ee0049a525bbf8abbb52eb1e4a2e68ae7c29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b0fecfc8cf7f7885402a7d45452b604846a3d0d3beeeb53941f3bad0a962a7bfd608d6dedcb967042a0844989af81026db6ce1118e4fb067e30c1da81979fce
|
7
|
+
data.tar.gz: 3315b174393419596cf382027c18c58e7d48dbd37899a1268cd04e9b6e4368eba50870ade4cf2b05ca0164eab8e9d70fefa08cc14fde02d588826a8046b253fb
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Khalti
|
2
2
|
|
3
|
-
Welcome to
|
3
|
+
Welcome to the khalti ruby gem. It is an API wrapper for Khalti payment gateway. For more info visit [Khalti Gateway Docs](http://docs.khalti.com/).
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,7 +20,18 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
export KHALTI_SECRET_KEY=your_secret_key
|
24
|
+
|
25
|
+
It supports server side verification and transaction list/ find
|
26
|
+
|
27
|
+
Verification:
|
28
|
+
|
29
|
+
Khalti::Verification.verify('token', 'amount')
|
30
|
+
|
31
|
+
Transaction:
|
32
|
+
|
33
|
+
Khalti::Transaction.all
|
34
|
+
Khalti::Transaction.find(idx)
|
24
35
|
|
25
36
|
## Development
|
26
37
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
API_URL = 'https://khalti.com/api/merchant-transaction'
|
6
|
+
|
7
|
+
module Khalti
|
8
|
+
class Transaction
|
9
|
+
def self.find(idx)
|
10
|
+
secret_key = ENV['KHALTI_SECRET_KEY'] #test_secret_key_f59e8b7d18b4499ca40f68195a846e9b
|
11
|
+
headers = {
|
12
|
+
Authorization: "Key #{secret_key}"
|
13
|
+
}
|
14
|
+
uri = URI.parse("#{API_URL}/#{idx}/")
|
15
|
+
puts uri
|
16
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
17
|
+
https.use_ssl = true
|
18
|
+
request = Net::HTTP::Get.new(uri.request_uri, headers)
|
19
|
+
response = https.request(request)
|
20
|
+
|
21
|
+
JSON.parse(response.body) || {}
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.all
|
25
|
+
secret_key = ENV['KHALTI_SECRET_KEY'] #test_secret_key_f59e8b7d18b4499ca40f68195a846e9b
|
26
|
+
headers = {
|
27
|
+
Authorization: "Key #{secret_key}"
|
28
|
+
}
|
29
|
+
uri = URI.parse("#{API_URL}/")
|
30
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
31
|
+
https.use_ssl = true
|
32
|
+
request = Net::HTTP::Get.new(uri.request_uri, headers)
|
33
|
+
response = https.request(request)
|
34
|
+
|
35
|
+
JSON.parse(response.body) || {}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
API_URL = "https://khalti.com/api/payment/verify/"
|
6
|
+
|
7
|
+
module Khalti
|
8
|
+
class Verification
|
9
|
+
def self.verify(token, amount)
|
10
|
+
secret_key = ENV['KHALTI_SECRET_KEY']
|
11
|
+
headers = {
|
12
|
+
Authorization: "Key #{secret_key}"
|
13
|
+
}
|
14
|
+
uri = URI.parse("#{API_URL}")
|
15
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
16
|
+
https.use_ssl = true
|
17
|
+
request = Net::HTTP::Post.new(uri.request_uri, headers)
|
18
|
+
request.set_form_data('token' => "#{token}", 'amount' => "#{amount}")
|
19
|
+
response = https.request(request)
|
20
|
+
|
21
|
+
JSON.parse(response.body) || {}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/khalti/version.rb
CHANGED
data/lib/khalti.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: khalti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Degendra Sivakoti
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,8 @@ files:
|
|
71
71
|
- bin/setup
|
72
72
|
- khalti.gemspec
|
73
73
|
- lib/khalti.rb
|
74
|
+
- lib/khalti/transaction.rb
|
75
|
+
- lib/khalti/verification.rb
|
74
76
|
- lib/khalti/version.rb
|
75
77
|
homepage: https://github.com/bajratech/khalti-ruby
|
76
78
|
licenses:
|