ifmb 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +8 -0
- data/README.md +23 -5
- data/Rakefile +6 -0
- data/ifmb.gemspec +2 -0
- data/lib/ifmb.rb +2 -2
- data/lib/ifmb/generator.rb +4 -14
- data/lib/ifmb/version.rb +1 -1
- data/spec/generator_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -0
- data/teste_ifmb.rb +4 -2
- metadata +35 -2
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
-
#
|
1
|
+
# IFMB [![Build Status](https://secure.travis-ci.org/Sinemys/ifmb.png?branch=master)](https://travis-ci.org/Sinemys/ifmb) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Sinemys/ifmb)
|
2
|
+
|
3
|
+
This is gem is a basic implementation to bill via IFMB service from IFTHEN.
|
4
|
+
It is a fork from https://github.com/Davidslv/MB and this may fail because it was not fully tested yet.
|
5
|
+
|
6
|
+
## Features
|
7
|
+
* Generate payment references to pay via MB (ATM)
|
8
|
+
* Format the payment data in html
|
2
9
|
|
3
|
-
TODO: Write a gem description
|
4
10
|
|
5
11
|
## Installation
|
6
12
|
|
7
13
|
Add this line to your application's Gemfile:
|
8
14
|
|
9
|
-
gem '
|
15
|
+
gem 'ifmb'
|
10
16
|
|
11
17
|
And then execute:
|
12
18
|
|
@@ -17,8 +23,20 @@ Or install it yourself as:
|
|
17
23
|
$ gem install ifmb
|
18
24
|
|
19
25
|
## Usage
|
20
|
-
|
21
|
-
|
26
|
+
```ruby
|
27
|
+
payment_data = {
|
28
|
+
entidade: 11604,
|
29
|
+
sub_entidade: 999,
|
30
|
+
order_id: 1234,
|
31
|
+
order_value: 25.86
|
32
|
+
}
|
33
|
+
|
34
|
+
@generator = Ifmb::Generator.new(payment_data)
|
35
|
+
@generator.generate # => your payment reference to give to the user
|
36
|
+
|
37
|
+
# You can also use the html format to print directly
|
38
|
+
<%= @generator.in_html %>
|
39
|
+
```
|
22
40
|
|
23
41
|
## Contributing
|
24
42
|
|
data/Rakefile
CHANGED
data/ifmb.gemspec
CHANGED
@@ -10,9 +10,11 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.summary = %q{Payment references generation for IFMB}
|
11
11
|
gem.homepage = "http://github.com/sinemys/ifmb"
|
12
12
|
|
13
|
+
gem.add_development_dependency('rake')
|
13
14
|
gem.add_development_dependency('rspec')
|
14
15
|
gem.add_development_dependency('guard-rspec')
|
15
16
|
gem.add_development_dependency('rb-fsevent')
|
17
|
+
gem.add_development_dependency('simplecov')
|
16
18
|
|
17
19
|
gem.files = `git ls-files`.split($\)
|
18
20
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/lib/ifmb.rb
CHANGED
data/lib/ifmb/generator.rb
CHANGED
@@ -19,7 +19,7 @@ module Ifmb
|
|
19
19
|
|
20
20
|
[:entidade, :sub_entidade, :order_id, :order_value].each do |attr|
|
21
21
|
define_method "#{attr}=" do |value|
|
22
|
-
# refresh validation
|
22
|
+
# TODO refresh validation
|
23
23
|
instance_variable_set "@#{attr}", value
|
24
24
|
end
|
25
25
|
end
|
@@ -59,26 +59,19 @@ module Ifmb
|
|
59
59
|
def generate
|
60
60
|
raise ArgumentError.new "arguments are invalid! #{@errors}" unless valid?
|
61
61
|
|
62
|
-
|
63
|
-
|
64
62
|
check_val = 0
|
65
63
|
# order_id = "0000" + order_id.to_s
|
66
64
|
|
67
|
-
puts order_value.inspect
|
68
|
-
|
69
65
|
# order_id = order_id.slice((order_id.length - 4)..-1).to_s
|
70
66
|
|
71
|
-
|
72
67
|
if ((order_value.to_f * 100).round < 1)
|
73
|
-
|
74
|
-
exit
|
68
|
+
raise RuntimeError.new 'impossivel de realizar pagamentos de 1 euro'
|
75
69
|
end
|
76
70
|
|
77
71
|
if ((order_value.to_f * 100).round >= 1_000_000)
|
78
72
|
# this is not implemented
|
79
73
|
# related with the while loop
|
80
|
-
|
81
|
-
exit
|
74
|
+
raise RuntimeError.new 'Aviso: Pagamento Fraccionado por exceder o valor limite para pagamentos por multibanco'
|
82
75
|
end
|
83
76
|
|
84
77
|
# this is not implemented
|
@@ -87,7 +80,7 @@ module Ifmb
|
|
87
80
|
# generate_mb_ref(entidade, sub_entidade, order_id, 999999.99)
|
88
81
|
# order_value = order_value.to_f - 999999.99
|
89
82
|
# end
|
90
|
-
|
83
|
+
|
91
84
|
|
92
85
|
check_str = sprintf('%05u%03u%04u%08u', entidade, sub_entidade, order_id.to_s, (order_value.to_f * 100).round)
|
93
86
|
|
@@ -102,9 +95,6 @@ module Ifmb
|
|
102
95
|
|
103
96
|
check_digits = sprintf('%02u', 98-check_val);
|
104
97
|
|
105
|
-
p "ENTIDADE : #{entidade}"
|
106
|
-
p "REFERENCIA: #{sub_entidade} #{check_str[8,3]} #{check_str[11,1]} #{check_digits}"
|
107
|
-
p "VALOR : #{order_value}"
|
108
98
|
@referencia = "#{sub_entidade}#{check_str[8,3]}#{check_str[11,1]}#{check_digits}".to_i
|
109
99
|
end
|
110
100
|
|
data/lib/ifmb/version.rb
CHANGED
data/spec/generator_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/teste_ifmb.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ifmb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,8 +10,24 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-11-
|
13
|
+
date: 2012-11-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
15
31
|
- !ruby/object:Gem::Dependency
|
16
32
|
name: rspec
|
17
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +76,22 @@ dependencies:
|
|
60
76
|
- - ! '>='
|
61
77
|
- !ruby/object:Gem::Version
|
62
78
|
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: simplecov
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
type: :development
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
63
95
|
description: Generate references for IFMB payments (portuguese ATM payment service
|
64
96
|
from IFTHEN)
|
65
97
|
email:
|
@@ -70,6 +102,7 @@ extra_rdoc_files: []
|
|
70
102
|
files:
|
71
103
|
- .gitignore
|
72
104
|
- .rspec
|
105
|
+
- .travis.yml
|
73
106
|
- Gemfile
|
74
107
|
- Guardfile
|
75
108
|
- LICENSE
|