powerpay21 0.0.0 → 0.0.1

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 +4 -4
  2. data/lib/powerpay21.rb +84 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43e3c68e72af94373e11032de66c0f510738d466
4
- data.tar.gz: e785c161fcb44c2287e03356368fd77731d96b43
3
+ metadata.gz: da192b58aaa91c55402b4caf18f087c6977d360c
4
+ data.tar.gz: 97e4e8c46cc9a33e927a8419e1b995c31318f2b6
5
5
  SHA512:
6
- metadata.gz: 941419e4c97d904a2c634f155089f5a21bdeca410dd52613317c6754c43a8c08bbaf04504bfd4a34eed45724f1f70f7258192b24d194bfbe3a343a417ee1b646
7
- data.tar.gz: 5ce904cea9d91384845b51388e6f7d73ce62ac1a01b50b986341b36a424a8e7eee67eca8096f0bd6ffa687bd421600ec08e2b02aa8ffb433fa24c7662c067a56
6
+ metadata.gz: 07cb099eb008a4b7d6bde57ba750490eb00e50e406744ff420f83895bc2c320fb14d6efd4770a0f405166561206433db3de84a801fadb0d241941f90f50f2b35
7
+ data.tar.gz: 5352c3589f83ca5a40384af6d348949959d450ef432b198a309dc572e338e91b9fb91e4b0d26f544559f83e9b042753a79200c8ddb0c0b0c27423b59f088a3f0
@@ -1,6 +1,90 @@
1
1
  # Main class for Powerpay21 API
2
2
  class Powerpay21
3
+ require 'digest'
4
+ require 'net/http'
5
+
6
+ # Constants - URLs
7
+ URL_HASH = {
8
+ :demo => {
9
+ :init => "https://pay4.powercash21.com/powercash21-3-2/payment/init",
10
+ :pre_auth => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_preauthorize",
11
+ :auth => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_authorize",
12
+ :refund => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_refund",
13
+ :reveral => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_reversal",
14
+ :capture => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_capture"
15
+
16
+ },
17
+ :live => {
18
+ :init => "https://pay4.powercash21.com/powercash21-3-2/payment/init",
19
+ :pre_auth => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_preauthorize",
20
+ :auth => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_authorize",
21
+ :refund => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_refund",
22
+ :reveral => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_reversal",
23
+ :capture => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_capture"
24
+ }
25
+ }
26
+
27
+ # Instance variables
28
+ @merchantid = nil
29
+ @secret=nil
30
+ @live_demo=false
31
+
32
+ def initialize(merchantid, secret, live=false)
33
+ @merchantid=merchantid
34
+ @secret=secret
35
+ if live
36
+ @live_demo=:live
37
+ else
38
+ @live_demo=:demo
39
+ end
40
+ end
41
+
42
+
3
43
  def self.help
4
44
  puts "This is a Powerpay21 API. Check our website for Guide"
5
45
  end
46
+
47
+ def authorize(params)
48
+ uri = URI(URL_HASH[@live_demo][:auth])
49
+
50
+ signature = calculate_signature(params)
51
+
52
+ params['signature'] = signature
53
+
54
+ res = Net::HTTP.post_form(uri, params)
55
+ end
56
+
57
+ # Calculates the SHA1Sum signature for give param hash by
58
+ # sorting the keys in ascending order
59
+ def calculate_signature(params)
60
+ raw_string = ""
61
+ params.sort.each do |key,value|
62
+ raw_string += value
63
+ end
64
+
65
+ sha1 = Digest::SHA1.new
66
+
67
+ sha1 << raw_string
68
+
69
+ return sha1.hexdigest || ""
70
+
71
+ end
72
+
73
+ def pre_authorize
74
+ end
75
+
76
+ def capture
77
+ end
78
+
79
+ def refund
80
+ end
81
+
82
+ def cft
83
+ end
84
+
85
+ def cancel
86
+ end
87
+
88
+ def status
89
+ end
6
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: powerpay21
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fazley Chowdhury
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-03 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem helps to simplify the integration to Powerpay21 Payment gateway
14
14
  for Ruby applications