epaybg 0.1.2 → 0.2.0
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 +7 -0
- data/.gitignore +1 -0
- data/README.md +48 -1
- data/Rakefile +4 -4
- data/epaybg.gemspec +9 -12
- data/lib/epaybg.rb +5 -8
- data/lib/epaybg/railtie.rb +3 -3
- data/lib/epaybg/response.rb +14 -8
- data/lib/epaybg/transaction.rb +16 -20
- data/lib/epaybg/version.rb +1 -1
- data/lib/epaybg/view_helpers.rb +4 -6
- metadata +16 -75
- data/spec/spec_helper.rb +0 -16
- data/spec/unit/transaction_spec.rb +0 -40
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 45239c656f82ff2132ca9fe16e741f8e32dc2e64
|
4
|
+
data.tar.gz: 2b0e1aff8b514c1d5c36a0b0a39634b08c8c0295
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e000ddb03b5b5c862afe7ce69560a5ee816f8b35db4dab0896514943ded9d63d656ed520f72a336368f749e4026193cbc9ed4908386186a164586e726238d1e
|
7
|
+
data.tar.gz: 89595e590c3f5bc75cce1a803d705325e07ef798404bf54d4cfe51a5076bfc1028cea91702168f4761e20d11850c1846d68f4568eaf18d829c97c1f2fdba4d36
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
[](https://codeclimate.com/github/gmitrev/epaybg)
|
3
3
|
[](https://travis-ci.org/gmitrev/epaybg)
|
4
4
|
|
5
|
+
Rails-specific library for working with the Epay.bg API. More information at
|
6
|
+
https://demo.epay.bg/?page=login
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Add this line to your application's Gemfile:
|
@@ -16,9 +19,53 @@ Or install it yourself as:
|
|
16
19
|
|
17
20
|
$ gem install epaybg
|
18
21
|
|
22
|
+
## Configuration
|
23
|
+
|
24
|
+
Create the config file config/epaybg.yml with the following contents:
|
25
|
+
|
26
|
+
```yml
|
27
|
+
production:
|
28
|
+
secret: YOUR-SECRET-KEY
|
29
|
+
min: YOUR-MIN
|
30
|
+
url: "https://epay.bg"
|
31
|
+
url_idn: "https://epay.bg/ezp/reg_bill.cgi"
|
32
|
+
|
33
|
+
test:
|
34
|
+
secret: YOUR-SECRET-KEY
|
35
|
+
min: YOUR-MIN
|
36
|
+
url: "https://demo.epay.bg"
|
37
|
+
url_idn: "https://demo.epay.bg/ezp/reg_bill.cgi"
|
38
|
+
```
|
39
|
+
|
40
|
+
Set the mode to production in your config/environments/production.rb file:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
# Add to bottom of the file
|
44
|
+
Epaybg.mode = :production
|
45
|
+
```
|
46
|
+
|
19
47
|
## Usage
|
48
|
+
Handle a response callback from epay:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
response = Epaybg::Response.new(params[:encoded], params[:checksum])
|
52
|
+
response.valid?
|
53
|
+
# => true
|
54
|
+
|
55
|
+
response.status
|
56
|
+
# => "PAID"
|
57
|
+
```
|
58
|
+
|
59
|
+
Respond to their callback:
|
60
|
+
```ruby
|
61
|
+
response = Epaybg::Response.new(params[:encoded], params[:checksum])
|
62
|
+
|
63
|
+
response.invoice
|
64
|
+
=> "f5b1eaf"
|
20
65
|
|
21
|
-
|
66
|
+
response.response_for(:ok)
|
67
|
+
=> "INVOICE=f5b1eaf:STATUS=PAID"
|
68
|
+
```
|
22
69
|
|
23
70
|
## Contributing
|
24
71
|
|
data/Rakefile
CHANGED
data/epaybg.gemspec
CHANGED
@@ -4,22 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'epaybg/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name =
|
7
|
+
gem.name = 'epaybg'
|
8
8
|
gem.version = Epaybg::VERSION
|
9
|
-
gem.authors = [
|
10
|
-
gem.email = [
|
11
|
-
gem.description =
|
12
|
-
gem.summary =
|
13
|
-
gem.homepage =
|
9
|
+
gem.authors = ['gmitrev']
|
10
|
+
gem.email = ['gvmitrev@gmail.com']
|
11
|
+
gem.description = 'Gem for dealing with epay.bg payments.'
|
12
|
+
gem.summary = 'Epaybg provides integration with the epay.bg payment services. It supports payments through epay.bg, credit cards and in EasyPay offices. '
|
13
|
+
gem.homepage = 'http://github.com/gmitrev/epaybg'
|
14
14
|
|
15
|
-
gem.files = `git ls-files`.split(
|
16
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = [
|
18
|
+
gem.require_paths = ['lib']
|
19
19
|
|
20
20
|
gem.add_development_dependency 'rake'
|
21
21
|
gem.add_development_dependency 'rspec'
|
22
|
-
gem.add_development_dependency 'rspec-rails'
|
23
|
-
gem.add_development_dependency 'rails'
|
24
|
-
gem.add_development_dependency 'coveralls'
|
25
22
|
end
|
data/lib/epaybg.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
require 'epaybg/railtie'
|
2
2
|
require 'epaybg/transaction'
|
3
3
|
require 'epaybg/response'
|
4
|
-
require
|
4
|
+
require 'epaybg/version'
|
5
5
|
|
6
6
|
module Epaybg
|
7
|
-
|
8
7
|
class << self
|
9
|
-
|
10
8
|
def hmac(data)
|
11
|
-
OpenSSL::HMAC.hexdigest('sha1', config[
|
9
|
+
OpenSSL::HMAC.hexdigest('sha1', config['secret'], data)
|
12
10
|
end
|
13
11
|
|
14
12
|
# Configuration is loaded based on this property.
|
@@ -20,21 +18,20 @@ module Epaybg
|
|
20
18
|
def mode=(mode)
|
21
19
|
valid = [:test, :production]
|
22
20
|
raise ArgumentError, "#{mode} is not a valid mode for Epaybg.
|
23
|
-
Valid modes are #{valid
|
21
|
+
Valid modes are #{valid}." unless valid.include?(mode)
|
24
22
|
@@mode = mode
|
25
23
|
end
|
26
24
|
|
27
|
-
@@mode = :
|
25
|
+
@@mode = :test
|
28
26
|
|
29
27
|
# A hash containing the configuration options found in the
|
30
28
|
# config/epaybg.yml file.
|
31
29
|
def config
|
32
|
-
@@config[
|
30
|
+
@@config[mode.to_s]
|
33
31
|
end
|
34
32
|
|
35
33
|
def config=(config)
|
36
34
|
@@config = config
|
37
35
|
end
|
38
|
-
|
39
36
|
end
|
40
37
|
end
|
data/lib/epaybg/railtie.rb
CHANGED
@@ -2,12 +2,12 @@ require 'epaybg/view_helpers'
|
|
2
2
|
|
3
3
|
module Epaybg
|
4
4
|
class Railtie < Rails::Railtie
|
5
|
-
initializer
|
5
|
+
initializer 'epaybg.view_helpers' do
|
6
6
|
ActionView::Base.send :include, Epaybg::ViewHelpers
|
7
7
|
end
|
8
8
|
|
9
|
-
initializer
|
10
|
-
Epaybg.config = YAML.load_file(app.root.join(
|
9
|
+
initializer 'epaybg.configure' do |app|
|
10
|
+
Epaybg.config = YAML.load_file(app.root.join('config', 'epaybg.yml'))
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/epaybg/response.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
module Epaybg
|
2
|
-
|
3
2
|
class Response
|
4
3
|
attr_accessor :encoded, :checksum
|
5
4
|
|
@@ -13,24 +12,32 @@ module Epaybg
|
|
13
12
|
end
|
14
13
|
|
15
14
|
def to_hash
|
16
|
-
i = decoded.strip.split(
|
15
|
+
i = decoded.strip.split(':').flat_map { |c| c.split('=') }
|
17
16
|
Hash[*i]
|
18
17
|
end
|
19
18
|
|
20
19
|
def valid?
|
21
|
-
Epaybg
|
20
|
+
Epaybg.hmac(@encoded) == @checksum
|
22
21
|
end
|
23
22
|
|
24
23
|
def status
|
25
|
-
to_hash[
|
24
|
+
to_hash['STATUS']
|
26
25
|
end
|
27
26
|
|
28
27
|
def invoice
|
29
|
-
to_hash[
|
28
|
+
to_hash['INVOICE']
|
29
|
+
end
|
30
|
+
|
31
|
+
def stan
|
32
|
+
to_hash['STAN'] if status == 'PAID'
|
33
|
+
end
|
34
|
+
|
35
|
+
def bcode
|
36
|
+
to_hash['BCODE'] if status == 'PAID'
|
30
37
|
end
|
31
38
|
|
32
39
|
def paid_on
|
33
|
-
DateTime.parse(to_hash[
|
40
|
+
DateTime.parse(to_hash['PAY_TIME']) if status == 'PAID'
|
34
41
|
end
|
35
42
|
|
36
43
|
def [](key)
|
@@ -40,8 +47,7 @@ module Epaybg
|
|
40
47
|
def response_for(status)
|
41
48
|
response_statuses = [:ok, :err]
|
42
49
|
raise "Status must be one of #{response_statuses}" unless response_statuses.include? status
|
43
|
-
"INVOICE=#{
|
50
|
+
"INVOICE=#{to_hash['INVOICE']}:STATUS=#{status.to_s.upcase}"
|
44
51
|
end
|
45
|
-
|
46
52
|
end
|
47
53
|
end
|
data/lib/epaybg/transaction.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
3
|
module Epaybg
|
4
|
-
|
5
4
|
class Transaction
|
6
|
-
|
7
5
|
attr_accessor :url, :url_idn, :invoice, :amount, :expires_on,
|
8
|
-
|
6
|
+
:description, :encoding, :url_ok, :url_cancel
|
9
7
|
|
10
8
|
def initialize(args = {})
|
11
9
|
set_defaults!
|
12
|
-
args.each do |k,v|
|
10
|
+
args.each do |k, v|
|
13
11
|
instance_variable_set("@#{k}", v) unless v.nil?
|
14
12
|
end
|
15
13
|
yield self if block_given?
|
@@ -17,25 +15,25 @@ module Epaybg
|
|
17
15
|
end
|
18
16
|
|
19
17
|
def encoded
|
20
|
-
exp_time =
|
18
|
+
exp_time = expires_on.strftime('%d.%m.%Y')
|
21
19
|
|
22
20
|
data = <<-DATA
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
MIN=#{Epaybg.config['min']}
|
22
|
+
LANG=bg
|
23
|
+
INVOICE=#{invoice}
|
24
|
+
AMOUNT=#{amount}
|
25
|
+
EXP_TIME=#{exp_time}
|
28
26
|
DATA
|
29
27
|
|
30
28
|
Base64.strict_encode64(data)
|
31
29
|
end
|
32
30
|
|
33
31
|
def checksum
|
34
|
-
Epaybg
|
32
|
+
Epaybg.hmac(encoded)
|
35
33
|
end
|
36
34
|
|
37
35
|
def register_payment
|
38
|
-
uri = URI("#{
|
36
|
+
uri = URI("#{url_idn}/?ENCODED=#{encoded}&CHECKSUM=#{checksum}")
|
39
37
|
|
40
38
|
http = Net::HTTP.new(uri.host, uri.port)
|
41
39
|
http.use_ssl = true
|
@@ -45,31 +43,29 @@ module Epaybg
|
|
45
43
|
end
|
46
44
|
|
47
45
|
def epay_link
|
48
|
-
base_link
|
46
|
+
base_link 'paylogin'
|
49
47
|
end
|
50
48
|
|
51
49
|
def credit_card_link
|
52
|
-
base_link
|
50
|
+
base_link 'credit_paydirect'
|
53
51
|
end
|
54
52
|
|
55
53
|
private
|
56
54
|
|
57
55
|
def base_link(action)
|
58
|
-
"#{
|
56
|
+
"#{url}/?PAGE=#{action}&ENCODED=#{encoded}&CHECKSUM=#{checksum}&URL_OK=#{url_ok}&URL_CANCEL=#{url_cancel}"
|
59
57
|
end
|
60
58
|
|
61
59
|
def validate!
|
62
60
|
[:invoice, :amount, :expires_on].each do |a|
|
63
|
-
raise ArgumentError, "Missing requried attribute: #{a}" if
|
61
|
+
raise ArgumentError, "Missing requried attribute: #{a}" if send(a).blank?
|
64
62
|
end
|
65
63
|
end
|
66
64
|
|
67
65
|
def set_defaults!
|
68
|
-
@url
|
69
|
-
@url_idn
|
66
|
+
@url ||= Epaybg.config['url']
|
67
|
+
@url_idn ||= Epaybg.config['url_idn']
|
70
68
|
@encoding ||= 'utf-8'
|
71
69
|
end
|
72
|
-
|
73
70
|
end
|
74
|
-
|
75
71
|
end
|
data/lib/epaybg/version.rb
CHANGED
data/lib/epaybg/view_helpers.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
module Epaybg
|
2
2
|
module ViewHelpers
|
3
|
-
|
4
|
-
|
5
|
-
link_to image_tag(image), "#{p.url}/?PAGE=#{action}&ENCODED=#{p.encoded}&CHECKSUM=#{p.checksum}&URL_OK=#{p.url_ok}&URL_CANCEL=#{p.url_cancel}"
|
3
|
+
def link_base(p, action, image = '')
|
4
|
+
link_to image_tag(image), "#{p.url}/?PAGE=#{action}&ENCODED=#{p.encoded}&CHECKSUM=#{p.checksum}&URL_OK=#{p.url_ok}&URL_CANCEL=#{p.url_cancel}"
|
6
5
|
end
|
7
6
|
|
8
7
|
def epay_link(p)
|
9
|
-
link_base p,
|
8
|
+
link_base p, 'paylogin', 'pay_with_epay.png'
|
10
9
|
end
|
11
10
|
|
12
11
|
def credit_card_link(p)
|
13
|
-
link_base p,
|
12
|
+
link_base p, 'credit_paydirect', 'pay_with_credit_card.jpg'
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
17
15
|
end
|
metadata
CHANGED
@@ -1,106 +1,53 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epaybg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- gmitrev
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-08-03 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
|
-
|
47
|
-
name: rspec-rails
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rails
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: coveralls
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
-
description: Framework for dealing with epay.bg payments.
|
41
|
+
description: Gem for dealing with epay.bg payments.
|
95
42
|
email:
|
96
43
|
- gvmitrev@gmail.com
|
97
44
|
executables: []
|
98
45
|
extensions: []
|
99
46
|
extra_rdoc_files: []
|
100
47
|
files:
|
101
|
-
- .gitignore
|
102
|
-
- .rspec
|
103
|
-
- .travis.yml
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".travis.yml"
|
104
51
|
- Gemfile
|
105
52
|
- LICENSE.txt
|
106
53
|
- README.md
|
@@ -113,34 +60,28 @@ files:
|
|
113
60
|
- lib/epaybg/version.rb
|
114
61
|
- lib/epaybg/view_helpers.rb
|
115
62
|
- log/test.log
|
116
|
-
- spec/spec_helper.rb
|
117
|
-
- spec/unit/transaction_spec.rb
|
118
63
|
homepage: http://github.com/gmitrev/epaybg
|
119
64
|
licenses: []
|
65
|
+
metadata: {}
|
120
66
|
post_install_message:
|
121
67
|
rdoc_options: []
|
122
68
|
require_paths:
|
123
69
|
- lib
|
124
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
71
|
requirements:
|
127
|
-
- -
|
72
|
+
- - ">="
|
128
73
|
- !ruby/object:Gem::Version
|
129
74
|
version: '0'
|
130
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
76
|
requirements:
|
133
|
-
- -
|
77
|
+
- - ">="
|
134
78
|
- !ruby/object:Gem::Version
|
135
79
|
version: '0'
|
136
80
|
requirements: []
|
137
81
|
rubyforge_project:
|
138
|
-
rubygems_version:
|
82
|
+
rubygems_version: 2.4.5
|
139
83
|
signing_key:
|
140
|
-
specification_version:
|
84
|
+
specification_version: 4
|
141
85
|
summary: Epaybg provides integration with the epay.bg payment services. It supports
|
142
86
|
payments through epay.bg, credit cards and in EasyPay offices.
|
143
|
-
test_files:
|
144
|
-
- spec/spec_helper.rb
|
145
|
-
- spec/unit/transaction_spec.rb
|
146
|
-
has_rdoc:
|
87
|
+
test_files: []
|
data/spec/spec_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require 'coveralls'
|
4
|
-
Coveralls.wear!
|
5
|
-
|
6
|
-
require "action_controller/railtie"
|
7
|
-
require 'rspec/rails'
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
end
|
11
|
-
|
12
|
-
require 'epaybg'
|
13
|
-
Epaybg.config = {
|
14
|
-
"test" => {"secret"=>"QESI7RA4BCW95TZPH2OM7583DCP250CEVWZYMM69E8GRS38932W54DWYI9KNCMZ0", "min"=>"D760738416", "url"=>"https://demo.epay.bg", "url_idn"=>"https://demo.epay.bg/ezp/reg_bill.cgi"},
|
15
|
-
"production" => {"secret"=>"n/a", "min"=>"n/a", "url"=>"https://epay.bg", "url_idn"=>"https://epay.bg/ezp/reg_bill.cgi"}
|
16
|
-
}
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Epaybg::Transaction do
|
4
|
-
let :attributes do
|
5
|
-
{ invoice: "12345", amount: 69.99, expires_on: Date.tomorrow }
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "initialization" do
|
9
|
-
it "accepts a hash with options" do
|
10
|
-
lambda do
|
11
|
-
Epaybg::Transaction.new(attributes)
|
12
|
-
end.should_not raise_error ArgumentError
|
13
|
-
end
|
14
|
-
|
15
|
-
it "accepts a block with options" do
|
16
|
-
lambda do
|
17
|
-
Epaybg::Transaction.new do |t|
|
18
|
-
t.amount = attributes[:amount]
|
19
|
-
t.price = attributes[:price]
|
20
|
-
t.expires_on = attributes[:expires_on]
|
21
|
-
end
|
22
|
-
end.should_not raise_error ArgumentError
|
23
|
-
end
|
24
|
-
|
25
|
-
it "doesn't initialize without no options" do
|
26
|
-
lambda do
|
27
|
-
Epaybg::Transaction.new
|
28
|
-
end.should raise_error ArgumentError
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
[:invoice, :amount, :expires_on].each do |attr|
|
33
|
-
it "fails when no #{attr} is given" do
|
34
|
-
lambda do
|
35
|
-
Epaybg::Transaction.new(attributes.except(attr))
|
36
|
-
end.should raise_error ArgumentError
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|