kkiapay 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/kkiapay.rb +55 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6a27f762107e249addcf62eb8931863a2519eb02b31e97373d576758fe6da9bb
4
+ data.tar.gz: 1e9cfb0e7c22600f04c4d6ccdc9efc635a23325fae5603c9cd7dabd1bdabc254
5
+ SHA512:
6
+ metadata.gz: c07867ee74b1805073cfacbd1e89443a49f68cf45e77b55bb4f1359d8806d811facd36b08ae5dd078ed3cb941071595cb2661eb166b3440116b84dfb5edda358
7
+ data.tar.gz: 305f369d3aa956a8cc35a62390f79008a1b11ccf23b8158947a9994f1d82e939cb3a896a40ab285ab53f0c80029b3fd01fee71b0ad9c787967001a55f92af27b
data/lib/kkiapay.rb ADDED
@@ -0,0 +1,55 @@
1
+ require "net/http"
2
+ require "net/https"
3
+ require "json"
4
+ require "uri"
5
+
6
+ BASE_URL = "https://api.kkiapay.me"
7
+ SANDBOX_URL = "https://api-sandbox.kkiapay.me"
8
+
9
+ def make_request(uri, transaction_id, headers)
10
+ begin
11
+ https = Net::HTTP.new(uri.host,uri.port)
12
+ https.use_ssl = true
13
+ req = Net::HTTP::Post.new(uri.path, initheader=headers)
14
+ req.body = {
15
+ "transactionId" => transaction_id
16
+ }.to_json
17
+ res = https.request(req)
18
+ res.body
19
+ rescue e
20
+ e
21
+ end
22
+ end
23
+
24
+ class Kkiapay
25
+
26
+ def initialize(public_key, private_key, secret, sandbox=false)
27
+ @headers = {
28
+ "Accept" => "application/json",
29
+ "Content-Type" => "application/json",
30
+ "X-SECRET-KEY" => secret,
31
+ "X-API-KEY"=> public_key,
32
+ "X-PRIVATE-KEY"=> private_key,
33
+ }
34
+
35
+ @url = sandbox ? SANDBOX_URL : BASE_URL
36
+ end
37
+
38
+ def verify_transaction(transaction_id)
39
+ transaction_url = URI.parse(@url + "/api/v1/transactions/status")
40
+ response = make_request(transaction_url, transaction_id, @headers)
41
+ response
42
+ end
43
+
44
+ def refund_transaction(transaction_id)
45
+ transaction_url = URI.parse(@url + "/api/v1/transactions/revert")
46
+ response = make_request(transaction_url, transaction_id, @headers)
47
+ response
48
+ end
49
+
50
+ def setup_payout(options)
51
+ transaction_url = URI.parse(@url + "/merchant/payouts/schedule")
52
+ response = make_request(transaction_url, transaction_id, @headers)
53
+ response
54
+ end
55
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kkiapay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - KKiaPay
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: KKiaPay Ruby SDK
14
+ email: support@kkiapay.me
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/kkiapay.rb
20
+ homepage: https://rubygems.org/gems/kkiapay
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.4.12
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: KKiaPay Ruby SDK
43
+ test_files: []