dwolla-ruby 2.9.0 → 3.0.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 +4 -4
- data/.gitignore +8 -8
- data/.travis.yml +11 -6
- data/Gemfile +1 -1
- data/README.md +225 -222
- data/Rakefile +8 -8
- data/dwolla-ruby.gemspec +27 -27
- data/examples/balance.rb +15 -15
- data/examples/contacts.rb +32 -32
- data/examples/fundingSources.rb +39 -39
- data/examples/oauth.rb +59 -59
- data/examples/offsiteGateway.rb +31 -31
- data/examples/transactions.rb +72 -72
- data/examples/users.rb +30 -30
- data/gemfiles/json.gemfile +2 -2
- data/lib/dwolla.rb +319 -327
- data/lib/dwolla/accounts.rb +27 -27
- data/lib/dwolla/balance.rb +15 -15
- data/lib/dwolla/contacts.rb +30 -30
- data/lib/dwolla/errors/api_connection_error.rb +3 -3
- data/lib/dwolla/errors/api_error.rb +3 -3
- data/lib/dwolla/errors/authentication_error.rb +3 -3
- data/lib/dwolla/errors/dwolla_error.rb +19 -19
- data/lib/dwolla/errors/invalid_request_error.rb +10 -10
- data/lib/dwolla/errors/missing_parameter_error.rb +3 -3
- data/lib/dwolla/exceptions.rb +4 -4
- data/lib/dwolla/funding_sources.rb +65 -65
- data/lib/dwolla/json.rb +20 -20
- data/lib/dwolla/masspay.rb +52 -52
- data/lib/dwolla/oauth.rb +84 -84
- data/lib/dwolla/offsite_gateway.rb +152 -152
- data/lib/dwolla/requests.rb +56 -56
- data/lib/dwolla/transactions.rb +108 -108
- data/lib/dwolla/users.rb +39 -39
- data/lib/dwolla/version.rb +3 -3
- data/test/test_accounts.rb +18 -18
- data/test/test_balance.rb +9 -9
- data/test/test_contacts.rb +19 -19
- data/test/test_dwolla.rb +62 -0
- data/test/test_funding_sources.rb +64 -64
- data/test/test_masspay.rb +47 -47
- data/test/test_oauth.rb +36 -36
- data/test/test_offsite_gateway.rb +57 -57
- data/test/test_requests.rb +29 -29
- data/test/test_transactions.rb +117 -117
- data/test/test_users.rb +33 -33
- metadata +5 -3
data/test/test_balance.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'mocha/test_unit'
|
3
|
-
require 'dwolla'
|
4
|
-
|
5
|
-
class BalanceTest < Test::Unit::TestCase
|
6
|
-
def test_balance
|
7
|
-
Dwolla.stubs(:request).with(:get, '/balance/', {}, {}, 'abc')
|
8
|
-
Dwolla::Balance.get('abc')
|
9
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mocha/test_unit'
|
3
|
+
require 'dwolla'
|
4
|
+
|
5
|
+
class BalanceTest < Test::Unit::TestCase
|
6
|
+
def test_balance
|
7
|
+
Dwolla.stubs(:request).with(:get, '/balance/', {}, {}, 'abc')
|
8
|
+
Dwolla::Balance.get('abc')
|
9
|
+
end
|
10
10
|
end
|
data/test/test_contacts.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'mocha/test_unit'
|
3
|
-
require 'dwolla'
|
4
|
-
|
5
|
-
class ContactsTest < Test::Unit::TestCase
|
6
|
-
def test_get
|
7
|
-
Dwolla.stubs(:request).with(:get, '/contacts/', { :search => 'Test Parameter' }, {}, 'abc')
|
8
|
-
Dwolla::Contacts.get({:search => 'Test Parameter'}, 'abc')
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_nearby
|
12
|
-
Dwolla.stubs(:request).with(:get, '/contacts/nearby',
|
13
|
-
{
|
14
|
-
:latitude => 35,
|
15
|
-
:longitude => 45,
|
16
|
-
:limit => 10
|
17
|
-
}, {}, false)
|
18
|
-
Dwolla::Contacts.nearby(35, 45, { :limit => 10 })
|
19
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mocha/test_unit'
|
3
|
+
require 'dwolla'
|
4
|
+
|
5
|
+
class ContactsTest < Test::Unit::TestCase
|
6
|
+
def test_get
|
7
|
+
Dwolla.stubs(:request).with(:get, '/contacts/', { :search => 'Test Parameter' }, {}, 'abc')
|
8
|
+
Dwolla::Contacts.get({:search => 'Test Parameter'}, 'abc')
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_nearby
|
12
|
+
Dwolla.stubs(:request).with(:get, '/contacts/nearby',
|
13
|
+
{
|
14
|
+
:latitude => 35,
|
15
|
+
:longitude => 45,
|
16
|
+
:limit => 10
|
17
|
+
}, {}, false)
|
18
|
+
Dwolla::Contacts.nearby(35, 45, { :limit => 10 })
|
19
|
+
end
|
20
20
|
end
|
data/test/test_dwolla.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mocha/test_unit'
|
3
|
+
require 'dwolla'
|
4
|
+
|
5
|
+
class DwollaTest < Test::Unit::TestCase
|
6
|
+
def setup()
|
7
|
+
Dwolla.token = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_no_authorization_if_oauthToken_false()
|
11
|
+
params = {}
|
12
|
+
headers = {}
|
13
|
+
Dwolla.extract_authorization(params, headers, false)
|
14
|
+
assert_nil headers[:authorization]
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_remove_token_from_params_if_oauthToken_false()
|
18
|
+
params = { :oauth_token => 'test'}
|
19
|
+
headers = {}
|
20
|
+
|
21
|
+
Dwolla.extract_authorization(params, headers, false)
|
22
|
+
assert_nil params[:oauth_token]
|
23
|
+
assert_nil headers[:authorization]
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_add_app_credentials_to_params_if_oauthToken_false()
|
27
|
+
params = {}
|
28
|
+
headers = {}
|
29
|
+
Dwolla.api_key = 'api key'
|
30
|
+
Dwolla.api_secret = 'api secret'
|
31
|
+
Dwolla.extract_authorization(params, headers, false)
|
32
|
+
assert_nil headers[:authorization]
|
33
|
+
assert_equal params[:client_id], 'api key'
|
34
|
+
assert_equal params[:client_secret], 'api secret'
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_default_to_global_token()
|
38
|
+
params = {}
|
39
|
+
headers = {}
|
40
|
+
token = 'test'
|
41
|
+
Dwolla.token = token
|
42
|
+
Dwolla.extract_authorization(params, headers)
|
43
|
+
assert_equal headers[:authorization], "Bearer #{token}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_pull_from_params()
|
47
|
+
token = 'test'
|
48
|
+
params = { :oauth_token => token }
|
49
|
+
headers = {}
|
50
|
+
Dwolla.extract_authorization(params, headers)
|
51
|
+
assert_equal headers[:authorization], "Bearer #{token}"
|
52
|
+
assert_nil params[:oauth_token]
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_use_provided_token()
|
56
|
+
token = 'test'
|
57
|
+
params = {}
|
58
|
+
headers = {}
|
59
|
+
Dwolla.extract_authorization(params, headers, token)
|
60
|
+
assert_equal headers[:authorization], "Bearer #{token}"
|
61
|
+
end
|
62
|
+
end
|
@@ -1,65 +1,65 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'mocha/test_unit'
|
3
|
-
require 'dwolla'
|
4
|
-
|
5
|
-
class FundingSourcesTest < Test::Unit::TestCase
|
6
|
-
def test_get
|
7
|
-
Dwolla.stubs(:request).with(:get, '/fundingsources/123456', {}, {}, 'abc')
|
8
|
-
Dwolla::FundingSources.get('123456', 'abc')
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_withdraw
|
12
|
-
Dwolla.stubs(:request).with(:post, '/fundingsources/123456/withdraw',
|
13
|
-
{
|
14
|
-
:pin => 1337,
|
15
|
-
:amount => 13.37
|
16
|
-
}, {}, 'abc')
|
17
|
-
Dwolla::FundingSources.withdraw('123456',
|
18
|
-
{
|
19
|
-
:pin => 1337,
|
20
|
-
:amount => 13.37
|
21
|
-
}, 'abc')
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_deposit
|
25
|
-
Dwolla.stubs(:request).with(:post, '/fundingsources/123456/deposit',
|
26
|
-
{
|
27
|
-
:pin => 1337,
|
28
|
-
:amount => 13.37
|
29
|
-
}, {}, 'abc')
|
30
|
-
Dwolla::FundingSources.deposit('123456',
|
31
|
-
{
|
32
|
-
:pin => 1337,
|
33
|
-
:amount => 13.37
|
34
|
-
}, 'abc')
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_add
|
38
|
-
Dwolla.stubs(:request).with(:post, '/fundingsources/',
|
39
|
-
{
|
40
|
-
:account_number => '123456',
|
41
|
-
:routing_number => '654321',
|
42
|
-
:account_type => 'Checking',
|
43
|
-
:name => 'My Unit Testing Account'
|
44
|
-
}, {}, 'abc')
|
45
|
-
Dwolla::FundingSources.add({
|
46
|
-
:account_number => '123456',
|
47
|
-
:routing_number => '654321',
|
48
|
-
:account_type => 'Checking',
|
49
|
-
:name => 'My Unit Testing Account'
|
50
|
-
}, 'abc')
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_verify
|
54
|
-
Dwolla.stubs(:request).with(:post, '/fundingsources/123456/verify',
|
55
|
-
{
|
56
|
-
:deposit1 => 0.05,
|
57
|
-
:deposit2 => 0.08
|
58
|
-
}, {}, 'abc')
|
59
|
-
Dwolla::FundingSources.verify('123456',
|
60
|
-
{
|
61
|
-
:deposit1 => 0.05,
|
62
|
-
:deposit2 => 0.08
|
63
|
-
}, 'abc')
|
64
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mocha/test_unit'
|
3
|
+
require 'dwolla'
|
4
|
+
|
5
|
+
class FundingSourcesTest < Test::Unit::TestCase
|
6
|
+
def test_get
|
7
|
+
Dwolla.stubs(:request).with(:get, '/fundingsources/123456', {}, {}, 'abc')
|
8
|
+
Dwolla::FundingSources.get('123456', 'abc')
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_withdraw
|
12
|
+
Dwolla.stubs(:request).with(:post, '/fundingsources/123456/withdraw',
|
13
|
+
{
|
14
|
+
:pin => 1337,
|
15
|
+
:amount => 13.37
|
16
|
+
}, {}, 'abc')
|
17
|
+
Dwolla::FundingSources.withdraw('123456',
|
18
|
+
{
|
19
|
+
:pin => 1337,
|
20
|
+
:amount => 13.37
|
21
|
+
}, 'abc')
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_deposit
|
25
|
+
Dwolla.stubs(:request).with(:post, '/fundingsources/123456/deposit',
|
26
|
+
{
|
27
|
+
:pin => 1337,
|
28
|
+
:amount => 13.37
|
29
|
+
}, {}, 'abc')
|
30
|
+
Dwolla::FundingSources.deposit('123456',
|
31
|
+
{
|
32
|
+
:pin => 1337,
|
33
|
+
:amount => 13.37
|
34
|
+
}, 'abc')
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_add
|
38
|
+
Dwolla.stubs(:request).with(:post, '/fundingsources/',
|
39
|
+
{
|
40
|
+
:account_number => '123456',
|
41
|
+
:routing_number => '654321',
|
42
|
+
:account_type => 'Checking',
|
43
|
+
:name => 'My Unit Testing Account'
|
44
|
+
}, {}, 'abc')
|
45
|
+
Dwolla::FundingSources.add({
|
46
|
+
:account_number => '123456',
|
47
|
+
:routing_number => '654321',
|
48
|
+
:account_type => 'Checking',
|
49
|
+
:name => 'My Unit Testing Account'
|
50
|
+
}, 'abc')
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_verify
|
54
|
+
Dwolla.stubs(:request).with(:post, '/fundingsources/123456/verify',
|
55
|
+
{
|
56
|
+
:deposit1 => 0.05,
|
57
|
+
:deposit2 => 0.08
|
58
|
+
}, {}, 'abc')
|
59
|
+
Dwolla::FundingSources.verify('123456',
|
60
|
+
{
|
61
|
+
:deposit1 => 0.05,
|
62
|
+
:deposit2 => 0.08
|
63
|
+
}, 'abc')
|
64
|
+
end
|
65
65
|
end
|
data/test/test_masspay.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'mocha/test_unit'
|
3
|
-
require 'dwolla'
|
4
|
-
|
5
|
-
class MassPayTest < Test::Unit::TestCase
|
6
|
-
def test_get
|
7
|
-
Dwolla.stubs(:request).with(:get, '/masspay/', {}, {}, 'abc')
|
8
|
-
Dwolla::MassPay.get('abc')
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_create
|
12
|
-
Dwolla.stubs(:request).with(:post, '/masspay/',
|
13
|
-
{
|
14
|
-
:fundsSource => 'Balance',
|
15
|
-
:pin => 1337,
|
16
|
-
:items =>
|
17
|
-
{
|
18
|
-
:amount => 13.37,
|
19
|
-
:destination => '812-111-1234'
|
20
|
-
}
|
21
|
-
}, {}, 'abc')
|
22
|
-
Dwolla::MassPay.create(
|
23
|
-
{
|
24
|
-
:fundsSource => 'Balance',
|
25
|
-
:pin => 1337,
|
26
|
-
:items =>
|
27
|
-
{
|
28
|
-
:amount => 13.37,
|
29
|
-
:destination => '812-111-1234'
|
30
|
-
}
|
31
|
-
}, 'abc')
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_getItems
|
35
|
-
Dwolla.stubs(:request).with(:get, '/masspay/123456/items', { :limit => 10 }, {}, 'abc')
|
36
|
-
Dwolla::MassPay.getItems('123456', { :limit => 10 }, 'abc')
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_getItem
|
40
|
-
Dwolla.stubs(:request).with(:get, '/masspay/123456/items/654321', {}, {}, 'abc')
|
41
|
-
Dwolla::MassPay.getItem('123456', '654321', 'abc')
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_getJob
|
45
|
-
Dwolla.stubs(:request).with(:get, '/masspay/123456', {}, {}, 'abc')
|
46
|
-
Dwolla::MassPay.getJob('123456', 'abc')
|
47
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mocha/test_unit'
|
3
|
+
require 'dwolla'
|
4
|
+
|
5
|
+
class MassPayTest < Test::Unit::TestCase
|
6
|
+
def test_get
|
7
|
+
Dwolla.stubs(:request).with(:get, '/masspay/', {}, {}, 'abc')
|
8
|
+
Dwolla::MassPay.get('abc')
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_create
|
12
|
+
Dwolla.stubs(:request).with(:post, '/masspay/',
|
13
|
+
{
|
14
|
+
:fundsSource => 'Balance',
|
15
|
+
:pin => 1337,
|
16
|
+
:items =>
|
17
|
+
{
|
18
|
+
:amount => 13.37,
|
19
|
+
:destination => '812-111-1234'
|
20
|
+
}
|
21
|
+
}, {}, 'abc')
|
22
|
+
Dwolla::MassPay.create(
|
23
|
+
{
|
24
|
+
:fundsSource => 'Balance',
|
25
|
+
:pin => 1337,
|
26
|
+
:items =>
|
27
|
+
{
|
28
|
+
:amount => 13.37,
|
29
|
+
:destination => '812-111-1234'
|
30
|
+
}
|
31
|
+
}, 'abc')
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_getItems
|
35
|
+
Dwolla.stubs(:request).with(:get, '/masspay/123456/items', { :limit => 10 }, {}, 'abc')
|
36
|
+
Dwolla::MassPay.getItems('123456', { :limit => 10 }, 'abc')
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_getItem
|
40
|
+
Dwolla.stubs(:request).with(:get, '/masspay/123456/items/654321', {}, {}, 'abc')
|
41
|
+
Dwolla::MassPay.getItem('123456', '654321', 'abc')
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_getJob
|
45
|
+
Dwolla.stubs(:request).with(:get, '/masspay/123456', {}, {}, 'abc')
|
46
|
+
Dwolla::MassPay.getJob('123456', 'abc')
|
47
|
+
end
|
48
48
|
end
|
data/test/test_oauth.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'mocha/test_unit'
|
3
|
-
require 'dwolla'
|
4
|
-
|
5
|
-
class OAuthTest < Test::Unit::TestCase
|
6
|
-
def test_get_auth_url
|
7
|
-
Dwolla::api_key = 'abcd'
|
8
|
-
Dwolla::scope = 'efgh'
|
9
|
-
assert Dwolla::OAuth.get_auth_url == "https://www.dwolla.com/oauth/v2/authenticate?client_id=abcd&response_type=code&scope=efgh&verified_account=false"
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_get_token
|
13
|
-
Dwolla.stubs(:request).with(:post, 'https://www.dwolla.com/oauth/v2/token',
|
14
|
-
{
|
15
|
-
:grant_type => 'authorization_code',
|
16
|
-
:code => 'abc',
|
17
|
-
:redirect_uri => 'http://google.com'
|
18
|
-
}, {}, false, false, true)
|
19
|
-
Dwolla::OAuth.get_token('abc', 'http://google.com')
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_refresh_auth
|
23
|
-
Dwolla.stubs(:request).with(:post, 'https://www.dwolla.com/oauth/v2/token',
|
24
|
-
{
|
25
|
-
:grant_type => 'refresh_token',
|
26
|
-
:refresh_token => 'abc'
|
27
|
-
}, {}, false, false, true)
|
28
|
-
Dwolla::OAuth.refresh_auth('abc')
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_catalog
|
32
|
-
Dwolla.stubs(:request).with(:get, '/catalog',
|
33
|
-
{}, {}, 'abc', false, false)
|
34
|
-
Dwolla::OAuth.catalog('abc')
|
35
|
-
end
|
36
|
-
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mocha/test_unit'
|
3
|
+
require 'dwolla'
|
4
|
+
|
5
|
+
class OAuthTest < Test::Unit::TestCase
|
6
|
+
def test_get_auth_url
|
7
|
+
Dwolla::api_key = 'abcd'
|
8
|
+
Dwolla::scope = 'efgh'
|
9
|
+
assert Dwolla::OAuth.get_auth_url == "https://www.dwolla.com/oauth/v2/authenticate?client_id=abcd&response_type=code&scope=efgh&verified_account=false"
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_get_token
|
13
|
+
Dwolla.stubs(:request).with(:post, 'https://www.dwolla.com/oauth/v2/token',
|
14
|
+
{
|
15
|
+
:grant_type => 'authorization_code',
|
16
|
+
:code => 'abc',
|
17
|
+
:redirect_uri => 'http://google.com'
|
18
|
+
}, {}, false, false, true)
|
19
|
+
Dwolla::OAuth.get_token('abc', 'http://google.com')
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_refresh_auth
|
23
|
+
Dwolla.stubs(:request).with(:post, 'https://www.dwolla.com/oauth/v2/token',
|
24
|
+
{
|
25
|
+
:grant_type => 'refresh_token',
|
26
|
+
:refresh_token => 'abc'
|
27
|
+
}, {}, false, false, true)
|
28
|
+
Dwolla::OAuth.refresh_auth('abc')
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_catalog
|
32
|
+
Dwolla.stubs(:request).with(:get, '/catalog',
|
33
|
+
{}, {}, 'abc', false, false)
|
34
|
+
Dwolla::OAuth.catalog('abc')
|
35
|
+
end
|
36
|
+
|
37
37
|
end
|
@@ -1,58 +1,58 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'mocha/test_unit'
|
3
|
-
require 'dwolla'
|
4
|
-
|
5
|
-
class OffsiteGatewayTest < Test::Unit::TestCase
|
6
|
-
def test_add_product
|
7
|
-
Dwolla::OffsiteGateway.add_product("Test", "Desc", 1.50, 2)
|
8
|
-
assert Dwolla::OffsiteGateway.instance_variable_get(:@products) == [{:name => 'Test', :description => 'Desc', :price => 1.50, :quantity => 2}]
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_set_customer_info
|
12
|
-
Dwolla::OffsiteGateway.set_customer_info("First", "Last", "Em@i.l", "City", "State", "90210")
|
13
|
-
assert Dwolla::OffsiteGateway.instance_variable_get(:@customerInfo) == {
|
14
|
-
:firstName => "First",
|
15
|
-
:lastName => "Last",
|
16
|
-
:email => "Em@i.l",
|
17
|
-
:city => "City",
|
18
|
-
:state => "State",
|
19
|
-
:zip => "90210"
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_discount
|
24
|
-
Dwolla::OffsiteGateway.discount = 1
|
25
|
-
assert Dwolla::OffsiteGateway.instance_variable_get(:@discount) == -1
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_get_checkout_url
|
29
|
-
Dwolla.stubs(:request).with(:post, 'https://www.dwolla.com/payment/request',
|
30
|
-
{
|
31
|
-
:key => 'abc',
|
32
|
-
:secret => 'def',
|
33
|
-
:allowFundingSources => true,
|
34
|
-
:additionalFundingSources => true,
|
35
|
-
:test => false,
|
36
|
-
:callback => nil,
|
37
|
-
:redirect => nil,
|
38
|
-
:orderId => nil,
|
39
|
-
:notes => nil,
|
40
|
-
:purchaseOrder => {
|
41
|
-
:customerInfo => @customerInfo,
|
42
|
-
:destinationId => '812-111-1234',
|
43
|
-
:orderItems => [{:name => 'Test', :description => 'Desc', :price => 1.50, :quantity => 2}],
|
44
|
-
:facilitatorAmount => nil,
|
45
|
-
:discount => -1,
|
46
|
-
:shipping => 0,
|
47
|
-
:tax => 0,
|
48
|
-
:total => 2.00
|
49
|
-
}
|
50
|
-
}, {}, false, false, true)
|
51
|
-
Dwolla::api_key = 'abc'
|
52
|
-
Dwolla::api_secret = 'def'
|
53
|
-
Dwolla::OffsiteGateway.get_checkout_url('812-111-1234')
|
54
|
-
end
|
55
|
-
|
56
|
-
## TODO: Tests to validate OpenSSL digest functionality.
|
57
|
-
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mocha/test_unit'
|
3
|
+
require 'dwolla'
|
4
|
+
|
5
|
+
class OffsiteGatewayTest < Test::Unit::TestCase
|
6
|
+
def test_add_product
|
7
|
+
Dwolla::OffsiteGateway.add_product("Test", "Desc", 1.50, 2)
|
8
|
+
assert Dwolla::OffsiteGateway.instance_variable_get(:@products) == [{:name => 'Test', :description => 'Desc', :price => 1.50, :quantity => 2}]
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_set_customer_info
|
12
|
+
Dwolla::OffsiteGateway.set_customer_info("First", "Last", "Em@i.l", "City", "State", "90210")
|
13
|
+
assert Dwolla::OffsiteGateway.instance_variable_get(:@customerInfo) == {
|
14
|
+
:firstName => "First",
|
15
|
+
:lastName => "Last",
|
16
|
+
:email => "Em@i.l",
|
17
|
+
:city => "City",
|
18
|
+
:state => "State",
|
19
|
+
:zip => "90210"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_discount
|
24
|
+
Dwolla::OffsiteGateway.discount = 1
|
25
|
+
assert Dwolla::OffsiteGateway.instance_variable_get(:@discount) == -1
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_get_checkout_url
|
29
|
+
Dwolla.stubs(:request).with(:post, 'https://www.dwolla.com/payment/request',
|
30
|
+
{
|
31
|
+
:key => 'abc',
|
32
|
+
:secret => 'def',
|
33
|
+
:allowFundingSources => true,
|
34
|
+
:additionalFundingSources => true,
|
35
|
+
:test => false,
|
36
|
+
:callback => nil,
|
37
|
+
:redirect => nil,
|
38
|
+
:orderId => nil,
|
39
|
+
:notes => nil,
|
40
|
+
:purchaseOrder => {
|
41
|
+
:customerInfo => @customerInfo,
|
42
|
+
:destinationId => '812-111-1234',
|
43
|
+
:orderItems => [{:name => 'Test', :description => 'Desc', :price => 1.50, :quantity => 2}],
|
44
|
+
:facilitatorAmount => nil,
|
45
|
+
:discount => -1,
|
46
|
+
:shipping => 0,
|
47
|
+
:tax => 0,
|
48
|
+
:total => 2.00
|
49
|
+
}
|
50
|
+
}, {}, false, false, true)
|
51
|
+
Dwolla::api_key = 'abc'
|
52
|
+
Dwolla::api_secret = 'def'
|
53
|
+
Dwolla::OffsiteGateway.get_checkout_url('812-111-1234')
|
54
|
+
end
|
55
|
+
|
56
|
+
## TODO: Tests to validate OpenSSL digest functionality.
|
57
|
+
|
58
58
|
end
|