epaybg 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -0
- data/epaybg.gemspec +1 -0
- data/lib/epaybg.rb +3 -3
- data/lib/epaybg/response.rb +2 -2
- data/lib/epaybg/transaction.rb +5 -3
- data/lib/epaybg/version.rb +1 -1
- data/spec/epaybg/transaction_spec.rb +58 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/test_config.yml +11 -0
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 710d9ff6dbbfe8ff3daab192b62f75ef67b1a2c9
|
4
|
+
data.tar.gz: 86253a6b8fd37208140b98c572662734fc789f82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d294f6db3df01afff33c59686f7e378c43b7fee59b79dc427ac6259c415897a378ec07069dccb5bbcae2477e4079e4b19fff00ca42fb9ba8a9126743be934fc4
|
7
|
+
data.tar.gz: 8d67b601ea920480d12d7ef56414c740cbe4234bcbe69b2c4a23c11cf9261aab054b6682a79296ce566b1639393c4effb36fae0dea60aab18025eabebb552735
|
data/Rakefile
CHANGED
data/epaybg.gemspec
CHANGED
data/lib/epaybg.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require 'epaybg/railtie'
|
1
|
+
require 'epaybg/railtie' if defined?(Rails)
|
2
2
|
require 'epaybg/transaction'
|
3
3
|
require 'epaybg/response'
|
4
4
|
require 'epaybg/version'
|
5
5
|
|
6
6
|
module Epaybg
|
7
7
|
class << self
|
8
|
-
def hmac(data)
|
9
|
-
OpenSSL::HMAC.hexdigest('sha1',
|
8
|
+
def hmac(data, secret)
|
9
|
+
OpenSSL::HMAC.hexdigest('sha1', secret, data)
|
10
10
|
end
|
11
11
|
|
12
12
|
# Configuration is loaded based on this property.
|
data/lib/epaybg/response.rb
CHANGED
data/lib/epaybg/transaction.rb
CHANGED
@@ -3,7 +3,7 @@ require 'net/http'
|
|
3
3
|
module Epaybg
|
4
4
|
class Transaction
|
5
5
|
attr_accessor :url, :url_idn, :invoice, :amount, :expires_on,
|
6
|
-
:description, :encoding, :url_ok, :url_cancel
|
6
|
+
:description, :encoding, :url_ok, :url_cancel, :min, :secret
|
7
7
|
|
8
8
|
def initialize(args = {})
|
9
9
|
set_defaults!
|
@@ -18,7 +18,7 @@ module Epaybg
|
|
18
18
|
exp_time = expires_on.strftime('%d.%m.%Y')
|
19
19
|
|
20
20
|
data = <<-DATA
|
21
|
-
MIN=#{
|
21
|
+
MIN=#{min}
|
22
22
|
LANG=bg
|
23
23
|
INVOICE=#{invoice}
|
24
24
|
AMOUNT=#{amount}
|
@@ -29,7 +29,7 @@ EXP_TIME=#{exp_time}
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def checksum
|
32
|
-
Epaybg.hmac(encoded)
|
32
|
+
Epaybg.hmac(encoded, secret)
|
33
33
|
end
|
34
34
|
|
35
35
|
def register_payment
|
@@ -66,6 +66,8 @@ EXP_TIME=#{exp_time}
|
|
66
66
|
@url ||= Epaybg.config['url']
|
67
67
|
@url_idn ||= Epaybg.config['url_idn']
|
68
68
|
@encoding ||= 'utf-8'
|
69
|
+
@min ||= Epaybg.config['min']
|
70
|
+
@secret ||= Epaybg.config['secret']
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
data/lib/epaybg/version.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
describe 'Transaction' do
|
5
|
+
before {
|
6
|
+
Epaybg.config = YAML.load_file('spec/test_config.yml')
|
7
|
+
}
|
8
|
+
|
9
|
+
it 'can generate an epay_link for a transaction without using the config' do
|
10
|
+
transaction_params_without_config = {
|
11
|
+
invoice: 12345,
|
12
|
+
amount: 1,
|
13
|
+
expires_on: Date.today + 1,
|
14
|
+
min: "YOUR-MIN",
|
15
|
+
secret: "YOUR-SECRET-KEY",
|
16
|
+
url_ok: 'http://www.google.com',
|
17
|
+
url_cancel: 'http://www.yahoo.com',
|
18
|
+
}
|
19
|
+
|
20
|
+
transaction_params_with_config = {
|
21
|
+
invoice: 12345,
|
22
|
+
amount: 1,
|
23
|
+
expires_on: Date.today + 1,
|
24
|
+
url_ok: 'http://www.google.com',
|
25
|
+
url_cancel: 'http://www.yahoo.com',
|
26
|
+
}
|
27
|
+
|
28
|
+
config_transaction = ::Epaybg::Transaction.new(transaction_params_with_config)
|
29
|
+
no_config_transaction = ::Epaybg::Transaction.new(transaction_params_without_config)
|
30
|
+
|
31
|
+
expect(config_transaction.epay_link).to eq(no_config_transaction.epay_link)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'can generate a credit_card_link for a transaction without using the config' do
|
35
|
+
transaction_params_without_config = {
|
36
|
+
invoice: 12345,
|
37
|
+
amount: 1,
|
38
|
+
expires_on: Date.today + 1,
|
39
|
+
min: "YOUR-MIN",
|
40
|
+
secret: "YOUR-SECRET-KEY",
|
41
|
+
url_ok: 'http://www.google.com',
|
42
|
+
url_cancel: 'http://www.yahoo.com',
|
43
|
+
}
|
44
|
+
|
45
|
+
transaction_params_with_config = {
|
46
|
+
invoice: 12345,
|
47
|
+
amount: 1,
|
48
|
+
expires_on: Date.today + 1,
|
49
|
+
url_ok: 'http://www.google.com',
|
50
|
+
url_cancel: 'http://www.yahoo.com',
|
51
|
+
}
|
52
|
+
|
53
|
+
config_transaction = ::Epaybg::Transaction.new(transaction_params_with_config)
|
54
|
+
no_config_transaction = ::Epaybg::Transaction.new(transaction_params_without_config)
|
55
|
+
|
56
|
+
expect(config_transaction.credit_card_link).to eq(no_config_transaction.credit_card_link)
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
production:
|
2
|
+
secret: YOUR-SECRET-KEY
|
3
|
+
min: YOUR-MIN
|
4
|
+
url: "https://epay.bg"
|
5
|
+
url_idn: "https://epay.bg/ezp/reg_bill.cgi"
|
6
|
+
|
7
|
+
test:
|
8
|
+
secret: YOUR-SECRET-KEY
|
9
|
+
min: YOUR-MIN
|
10
|
+
url: "https://demo.epay.bg"
|
11
|
+
url_idn: "https://demo.epay.bg/ezp/reg_bill.cgi"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epaybg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gmitrev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Gem for dealing with epay.bg payments.
|
42
56
|
email:
|
43
57
|
- gvmitrev@gmail.com
|
@@ -60,6 +74,9 @@ files:
|
|
60
74
|
- lib/epaybg/version.rb
|
61
75
|
- lib/epaybg/view_helpers.rb
|
62
76
|
- log/test.log
|
77
|
+
- spec/epaybg/transaction_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- spec/test_config.yml
|
63
80
|
homepage: http://github.com/gmitrev/epaybg
|
64
81
|
licenses: []
|
65
82
|
metadata: {}
|
@@ -84,4 +101,7 @@ signing_key:
|
|
84
101
|
specification_version: 4
|
85
102
|
summary: Epaybg provides integration with the epay.bg payment services. It supports
|
86
103
|
payments through epay.bg, credit cards and in EasyPay offices.
|
87
|
-
test_files:
|
104
|
+
test_files:
|
105
|
+
- spec/epaybg/transaction_spec.rb
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
- spec/test_config.yml
|