paypal_calculator 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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +5 -0
- data/Rakefile +1 -0
- data/lib/paypal_calculator.rb +6 -0
- data/lib/paypal_calculator/version.rb +3 -0
- data/paypal_calculator.gemspec +23 -0
- data/spec/paypal-calculator.spec.coffee +71 -0
- data/vendor/assets/javascripts/paypal_calculator.coffee +19 -0
- metadata +77 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "paypal_calculator/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "paypal_calculator"
|
7
|
+
s.version = PaypalCalculator::VERSION
|
8
|
+
s.authors = ["Paul McMahon"]
|
9
|
+
s.email = ["paul@mobalean.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Calculate PayPal Fees}
|
12
|
+
s.description = %q{Rails javascript plugin for calculating PayPal fees}
|
13
|
+
|
14
|
+
s.rubyforge_project = "paypal_calculator"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency 'rails', '~> 3.1'
|
22
|
+
s.add_dependency 'coffee-rails', '~> 3.1'
|
23
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "coffee-script"
|
2
|
+
paypalCalculator = require "../vendor/assets/javascripts/paypal_calculator"
|
3
|
+
|
4
|
+
describe 'paypal calculator', ->
|
5
|
+
it 'should calculate merchant rate', ->
|
6
|
+
calculator = new paypalCalculator.PaypalCalculator(1000, 1)
|
7
|
+
expect(calculator.merchant_rate).toEqual 0.036
|
8
|
+
|
9
|
+
calculator = new paypalCalculator.PaypalCalculator(30*10000, 1)
|
10
|
+
expect(calculator.merchant_rate).toEqual 0.036
|
11
|
+
|
12
|
+
calculator = new paypalCalculator.PaypalCalculator(30*10000+1, 1)
|
13
|
+
expect(calculator.merchant_rate).toEqual 0.034
|
14
|
+
|
15
|
+
calculator = new paypalCalculator.PaypalCalculator(100*10000, 1)
|
16
|
+
expect(calculator.merchant_rate).toEqual 0.034
|
17
|
+
|
18
|
+
calculator = new paypalCalculator.PaypalCalculator(100*10000+1, 1)
|
19
|
+
expect(calculator.merchant_rate).toEqual 0.032
|
20
|
+
|
21
|
+
calculator = new paypalCalculator.PaypalCalculator(1000*10000, 1)
|
22
|
+
expect(calculator.merchant_rate).toEqual 0.032
|
23
|
+
|
24
|
+
calculator = new paypalCalculator.PaypalCalculator(1000*10000+1, 1)
|
25
|
+
expect(calculator.merchant_rate).toEqual 0.029
|
26
|
+
|
27
|
+
it 'should not change standard rate with volume', ->
|
28
|
+
calculator = new paypalCalculator.PaypalCalculator(1000, 1)
|
29
|
+
expect(calculator.standard_rate).toEqual 0.036
|
30
|
+
|
31
|
+
calculator = new paypalCalculator.PaypalCalculator(1000*10000+1, 1)
|
32
|
+
expect(calculator.standard_rate).toEqual 0.036
|
33
|
+
|
34
|
+
it 'should have the standard transaction fee', ->
|
35
|
+
calculator = new paypalCalculator.PaypalCalculator(1000, 1)
|
36
|
+
expect(calculator.standard_transaction_fee).toEqual 40
|
37
|
+
|
38
|
+
it 'should have the micropayment transaction fee', ->
|
39
|
+
calculator = new paypalCalculator.PaypalCalculator(1000, 1)
|
40
|
+
expect(calculator.micropayment_transaction_fee).toEqual 7
|
41
|
+
|
42
|
+
it 'should have the micropayment rate', ->
|
43
|
+
calculator = new paypalCalculator.PaypalCalculator(1000, 1)
|
44
|
+
expect(calculator.micropayment_rate).toEqual 0.05
|
45
|
+
|
46
|
+
it 'should calculate standard fees', ->
|
47
|
+
calculator = new paypalCalculator.PaypalCalculator(1000, 1)
|
48
|
+
expect(calculator.standard_fees).toEqual 1000*0.036 + 1*40
|
49
|
+
|
50
|
+
calculator = new paypalCalculator.PaypalCalculator(1000, 2)
|
51
|
+
expect(calculator.standard_fees).toEqual 2*1000*0.036 + 2*40
|
52
|
+
|
53
|
+
it 'should calculate micropayment fees', ->
|
54
|
+
calculator = new paypalCalculator.PaypalCalculator(1000, 1)
|
55
|
+
expect(calculator.micropayment_fees).toEqual 1000*0.05 + 1*7
|
56
|
+
|
57
|
+
calculator = new paypalCalculator.PaypalCalculator(1000, 2)
|
58
|
+
expect(calculator.micropayment_fees).toEqual 2*1000*0.05 + 2*7
|
59
|
+
|
60
|
+
it 'should calculate merchant fees', ->
|
61
|
+
calculator = new paypalCalculator.PaypalCalculator(1000, 1)
|
62
|
+
expect(calculator.merchant_fees).toEqual 1000*0.036 + 1*40
|
63
|
+
|
64
|
+
calculator = new paypalCalculator.PaypalCalculator(1000*10000+1, 2)
|
65
|
+
expect(calculator.merchant_fees).toEqual Math.round(2*(1000*10000+1)*0.029 + 2*40)
|
66
|
+
|
67
|
+
it 'should round fees', ->
|
68
|
+
calculator = new paypalCalculator.PaypalCalculator(1, 1)
|
69
|
+
expect(calculator.merchant_fees).toEqual 40
|
70
|
+
expect(calculator.standard_fees).toEqual 40
|
71
|
+
expect(calculator.micropayment_fees).toEqual 7
|
@@ -0,0 +1,19 @@
|
|
1
|
+
root = exports ? this
|
2
|
+
class root.PaypalCalculator
|
3
|
+
constructor: (@avg_transaction, @transactions) ->
|
4
|
+
base = @avg_transaction * @transactions
|
5
|
+
@merchant_rate = if base <= 300000
|
6
|
+
0.036
|
7
|
+
else if base <= 1000000
|
8
|
+
0.034
|
9
|
+
else if base <= 10000000
|
10
|
+
0.032
|
11
|
+
else
|
12
|
+
0.029
|
13
|
+
@standard_fees = Math.round(this.standard_rate * base + @transactions * this.standard_transaction_fee)
|
14
|
+
@micropayment_fees = Math.round(this.micropayment_rate * base + @transactions * this.micropayment_transaction_fee)
|
15
|
+
@merchant_fees = Math.round(this.merchant_rate * base + @transactions * this.standard_transaction_fee)
|
16
|
+
standard_rate: 0.036
|
17
|
+
standard_transaction_fee: 40
|
18
|
+
micropayment_transaction_fee: 7
|
19
|
+
micropayment_rate: 0.05
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paypal_calculator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paul McMahon
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &2157067940 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2157067940
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: coffee-rails
|
27
|
+
requirement: &2157065360 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.1'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2157065360
|
36
|
+
description: Rails javascript plugin for calculating PayPal fees
|
37
|
+
email:
|
38
|
+
- paul@mobalean.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- lib/paypal_calculator.rb
|
48
|
+
- lib/paypal_calculator/version.rb
|
49
|
+
- paypal_calculator.gemspec
|
50
|
+
- spec/paypal-calculator.spec.coffee
|
51
|
+
- vendor/assets/javascripts/paypal_calculator.coffee
|
52
|
+
homepage: ''
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project: paypal_calculator
|
72
|
+
rubygems_version: 1.8.10
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Calculate PayPal Fees
|
76
|
+
test_files:
|
77
|
+
- spec/paypal-calculator.spec.coffee
|