pg_recurrence 0.1.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.
- data/.document +5 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +33 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +65 -0
- data/VERSION +1 -0
- data/lib/pg_recurrence.rb +10 -0
- data/lib/ruby_psigate/account.rb +178 -0
- data/lib/ruby_psigate/charge.rb +227 -0
- data/lib/ruby_psigate/credential.rb +20 -0
- data/lib/ruby_psigate/request.rb +54 -0
- data/lib/ruby_psigate/response.rb +99 -0
- data/test/helper.rb +70 -0
- data/test/remote/test_account_remote.rb +104 -0
- data/test/remote/test_charge_remote.rb +92 -0
- data/test/remote/test_request_remote.rb +36 -0
- data/test/unit/test_account.rb +220 -0
- data/test/unit/test_charge.rb +15 -0
- data/test/unit/test_request.rb +50 -0
- data/test/unit/test_response.rb +55 -0
- metadata +200 -0
@@ -0,0 +1,220 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module RubyPsigate
|
4
|
+
class TestAccount < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
Request.credential = credential
|
8
|
+
end
|
9
|
+
|
10
|
+
#####
|
11
|
+
|
12
|
+
def test_return_true_for_new_record?
|
13
|
+
@account = Account.new
|
14
|
+
assert @account.new_record?
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_account_id_setter
|
18
|
+
@account = Account.new
|
19
|
+
assert @account.respond_to?(:accountid=), "Account instance does not have accountid setter"
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_account_id_getter
|
23
|
+
@account = Account.new
|
24
|
+
assert @account.respond_to?(:accountid), "Account instance does not have accountid getter"
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_name_setter
|
28
|
+
@account = Account.new
|
29
|
+
assert @account.respond_to?(:name=), "Account instance does not have name setter"
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_name_getter
|
33
|
+
@account = Account.new
|
34
|
+
assert @account.respond_to?(:name), "Account instance does not have name getter"
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_company_setter
|
38
|
+
@account = Account.new
|
39
|
+
assert @account.respond_to?(:company=), "Account instance does not have company setter"
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_company_getter
|
43
|
+
@account = Account.new
|
44
|
+
assert @account.respond_to?(:company), "Account instance does not have company getter"
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_address1_setter
|
48
|
+
@account = Account.new
|
49
|
+
assert @account.respond_to?(:address1=), "Account instance does not have address1 setter"
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_address1_getter
|
53
|
+
@account = Account.new
|
54
|
+
assert @account.respond_to?(:address1), "Account instance does not have address1 getter"
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_address2_setter
|
58
|
+
@account = Account.new
|
59
|
+
assert @account.respond_to?(:address2=), "Account instance does not have address2 setter"
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_address2_getter
|
63
|
+
@account = Account.new
|
64
|
+
assert @account.respond_to?(:address2), "Account instance does not have address2 getter"
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_city_setter
|
68
|
+
@account = Account.new
|
69
|
+
assert @account.respond_to?(:city=), "Account instance does not have city setter"
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_city_getter
|
73
|
+
@account = Account.new
|
74
|
+
assert @account.respond_to?(:city), "Account instance does not have city getter"
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_province_setter
|
78
|
+
@account = Account.new
|
79
|
+
assert @account.respond_to?(:province=), "Account instance does not have province setter"
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_province_getter
|
83
|
+
@account = Account.new
|
84
|
+
assert @account.respond_to?(:province), "Account instance does not have province getter"
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_state_setter_is_same_as_province_setter
|
88
|
+
@account = Account.new
|
89
|
+
@account.state = "Something"
|
90
|
+
assert_equal @account.province, @account.state
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_state_getter_is_same_as_province_getter
|
94
|
+
@account = Account.new
|
95
|
+
@account.province = "Something"
|
96
|
+
assert_equal @account.state, @account.province
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_postal_code_setter
|
100
|
+
@account = Account.new
|
101
|
+
assert @account.respond_to?(:postalcode=), "Account instance does not have postal code setter"
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_postal_code_getter
|
105
|
+
@account = Account.new
|
106
|
+
assert @account.respond_to?(:postalcode), "Account instance does not have postal code getter"
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_country_setter
|
110
|
+
@account = Account.new
|
111
|
+
assert @account.respond_to?(:country=), "Account instance does not have country setter"
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_country_getter
|
115
|
+
@account = Account.new
|
116
|
+
assert @account.respond_to?(:country), "Account instance does not have country getter"
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_phone_setter
|
120
|
+
@account = Account.new
|
121
|
+
assert @account.respond_to?(:phone=), "Account instance does not have phone setter"
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_phone_getter
|
125
|
+
@account = Account.new
|
126
|
+
assert @account.respond_to?(:phone), "Account instance does not have phone getter"
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_fax_setter
|
130
|
+
@account = Account.new
|
131
|
+
assert @account.respond_to?(:fax=), "Account instance does not have fax setter"
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_fax_getter
|
135
|
+
@account = Account.new
|
136
|
+
assert @account.respond_to?(:fax), "Account instance does not have fax getter"
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_email_setter
|
140
|
+
@account = Account.new
|
141
|
+
assert @account.respond_to?(:email=), "Account instance does not have email setter"
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_email_getter
|
145
|
+
@account = Account.new
|
146
|
+
assert @account.respond_to?(:email), "Account instance does not have email getter"
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_comments_setter
|
150
|
+
@account = Account.new
|
151
|
+
assert @account.respond_to?(:comments=), "Account instance does not have comments setter"
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_comments_getter
|
155
|
+
@account = Account.new
|
156
|
+
assert @account.respond_to?(:comments), "Account instance does not have comments getter"
|
157
|
+
end
|
158
|
+
|
159
|
+
# Holder for credit card object
|
160
|
+
|
161
|
+
def test_credit_card_object_holder
|
162
|
+
@account = Account.new
|
163
|
+
assert @account.respond_to?(:credit_card=), "Account instance does not have credit card object setter"
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_raises_error_if_credit_card_is_not_instance_of_pg_creditcard
|
167
|
+
@account = Account.new
|
168
|
+
assert_raise(ArgumentError) do
|
169
|
+
@account.credit_card = "hello world"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_raises_no_error_if_credit_card_is_instance_of_pg_creditcard
|
174
|
+
creditcard = PgCreditcard.new(
|
175
|
+
:name => "Homer Simpsons",
|
176
|
+
:number => "4111111111111111",
|
177
|
+
:month => "03",
|
178
|
+
:year => "20",
|
179
|
+
:cvv => "123"
|
180
|
+
)
|
181
|
+
|
182
|
+
@account = Account.new
|
183
|
+
assert_nothing_raised do
|
184
|
+
@account.credit_card = creditcard
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# Creating instances from hash
|
189
|
+
|
190
|
+
def test_new_account_instance_accepts_hash_of_values
|
191
|
+
@account = Account.new(
|
192
|
+
:accountid => "account_id_123",
|
193
|
+
:name => "Homer Simpson"
|
194
|
+
)
|
195
|
+
|
196
|
+
assert @account, "Account instance not initialized from hash of attributes"
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_new_account_instance_with_hash_will_assign_instance_variables
|
200
|
+
attributes = {
|
201
|
+
:accountid => "account_id_123",
|
202
|
+
:name => "Homer Simpson",
|
203
|
+
:country => "USA",
|
204
|
+
:zipcode => "12345",
|
205
|
+
:province => "Ontario"
|
206
|
+
}
|
207
|
+
|
208
|
+
@account = Account.new(attributes)
|
209
|
+
|
210
|
+
assert_equal @account.accountid, "account_id_123"
|
211
|
+
assert_equal @account.name, "Homer Simpson"
|
212
|
+
assert_equal @account.country, "USA"
|
213
|
+
assert_equal @account.zipcode, "12345"
|
214
|
+
assert_equal @account.province, "Ontario"
|
215
|
+
end
|
216
|
+
|
217
|
+
# Remote testing in remote testing directory
|
218
|
+
|
219
|
+
end
|
220
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module RubyPsigate
|
4
|
+
class TestRequest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@credential = Credential.new(:CID => "test", :UserID => "test", :password => "test")
|
8
|
+
Request.credential = @credential
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_storeid_setter
|
12
|
+
assert Request.respond_to?(:storeid=)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_storeid_getter
|
16
|
+
assert Request.respond_to?(:storeid)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_set_credential_setter_on_class_level
|
20
|
+
assert Request.respond_to?(:credential=)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_sets_credential
|
24
|
+
assert_equal @credential, Request.credential
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_raises_error_if_credentials_not_from_credential_class
|
28
|
+
assert_raises(ArgumentError) {Request.credential = "hello world"}
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_params_setter
|
32
|
+
@request = Request.new
|
33
|
+
assert @request.respond_to?(:params=)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_raises_error_if_params_is_not_a_hash
|
37
|
+
@request = Request.new
|
38
|
+
assert_raises(ArgumentError) { @request.params = "Hello World" }
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_sets_params
|
42
|
+
hash = { :Hello => "World" }
|
43
|
+
@request = Request.new
|
44
|
+
@request.params = hash
|
45
|
+
|
46
|
+
assert_equal hash, @request.params
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module RubyPsigate
|
4
|
+
class TestResponse < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_accepts_xml
|
7
|
+
@response = Response.new(api_response)
|
8
|
+
assert @response
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def api_response
|
14
|
+
<<-EOF
|
15
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
16
|
+
<Response>
|
17
|
+
<CID>1000001</CID>
|
18
|
+
<Action>REGISTER NEW PAYMENT ACCOUNTS</Action>
|
19
|
+
<ReturnCode>RPA-0000</ReturnCode>
|
20
|
+
<ReturnMessage>Register Payment Accounts completed successfully.</ReturnMessage>
|
21
|
+
<Account>
|
22
|
+
<ReturnCode>RPA-0010</ReturnCode>
|
23
|
+
<ReturnMessage>Register Payment Account completed successfully.</ReturnMessage>
|
24
|
+
<AccountID>2010090412944</AccountID>
|
25
|
+
<Status></Status>
|
26
|
+
<Name>John Smith</Name>
|
27
|
+
<Company>PSiGate Inc.</Company>
|
28
|
+
<Address1>145 King St.</Address1>
|
29
|
+
<Address2>2300</Address2>
|
30
|
+
<City>Toronto</City>
|
31
|
+
<Province>Ontario</Province>
|
32
|
+
<Postalcode>M5H 1J8</Postalcode>
|
33
|
+
<Country>Canada</Country>
|
34
|
+
<Phone>1-905-123-4567</Phone>
|
35
|
+
<Fax>1-905-123-4568</Fax>
|
36
|
+
<Email>support@psigate.com</Email>
|
37
|
+
<Comments>No Comment Today</Comments>
|
38
|
+
<CardInfo>
|
39
|
+
<Status></Status>
|
40
|
+
<SerialNo>1</SerialNo>
|
41
|
+
<AccountID>2010090412944</AccountID>
|
42
|
+
<CardHolder>John Smith</CardHolder>
|
43
|
+
<CardNumber>400555...0019</CardNumber>
|
44
|
+
<CardExpMonth>08</CardExpMonth>
|
45
|
+
<CardExpYear>11</CardExpYear>
|
46
|
+
<CardType>VISA</CardType>
|
47
|
+
</CardInfo>
|
48
|
+
</Account>
|
49
|
+
</Response>
|
50
|
+
EOF
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pg_recurrence
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Simon Chiu
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-07 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: crack
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
prerelease: false
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: pg_serializer
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: pg_connection
|
48
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: pg_creditcard
|
61
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
type: :runtime
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: *id004
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: mocha
|
74
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: *id005
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: bundler
|
87
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
segments:
|
93
|
+
- 1
|
94
|
+
- 0
|
95
|
+
- 0
|
96
|
+
version: 1.0.0
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: *id006
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: jeweler
|
102
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ~>
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
segments:
|
108
|
+
- 1
|
109
|
+
- 5
|
110
|
+
- 1
|
111
|
+
version: 1.5.1
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: *id007
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: rcov
|
117
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
version: "0"
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: *id008
|
128
|
+
description: Unofficial Psigate recurring billing library for Ruby
|
129
|
+
email: skhchiu@gmail.com
|
130
|
+
executables: []
|
131
|
+
|
132
|
+
extensions: []
|
133
|
+
|
134
|
+
extra_rdoc_files:
|
135
|
+
- LICENSE.txt
|
136
|
+
- README.rdoc
|
137
|
+
files:
|
138
|
+
- .document
|
139
|
+
- Gemfile
|
140
|
+
- Gemfile.lock
|
141
|
+
- LICENSE.txt
|
142
|
+
- README.rdoc
|
143
|
+
- Rakefile
|
144
|
+
- VERSION
|
145
|
+
- lib/pg_recurrence.rb
|
146
|
+
- lib/ruby_psigate/account.rb
|
147
|
+
- lib/ruby_psigate/charge.rb
|
148
|
+
- lib/ruby_psigate/credential.rb
|
149
|
+
- lib/ruby_psigate/request.rb
|
150
|
+
- lib/ruby_psigate/response.rb
|
151
|
+
- test/helper.rb
|
152
|
+
- test/remote/test_account_remote.rb
|
153
|
+
- test/remote/test_charge_remote.rb
|
154
|
+
- test/remote/test_request_remote.rb
|
155
|
+
- test/unit/test_account.rb
|
156
|
+
- test/unit/test_charge.rb
|
157
|
+
- test/unit/test_request.rb
|
158
|
+
- test/unit/test_response.rb
|
159
|
+
has_rdoc: true
|
160
|
+
homepage: http://github.com/drchiu/pg_recurrence
|
161
|
+
licenses:
|
162
|
+
- MIT
|
163
|
+
post_install_message:
|
164
|
+
rdoc_options: []
|
165
|
+
|
166
|
+
require_paths:
|
167
|
+
- lib
|
168
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
hash: -4504296644844795293
|
174
|
+
segments:
|
175
|
+
- 0
|
176
|
+
version: "0"
|
177
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
|
+
none: false
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
segments:
|
183
|
+
- 0
|
184
|
+
version: "0"
|
185
|
+
requirements: []
|
186
|
+
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 1.3.7
|
189
|
+
signing_key:
|
190
|
+
specification_version: 3
|
191
|
+
summary: Unofficial Psigate recurring billing library for Ruby
|
192
|
+
test_files:
|
193
|
+
- test/helper.rb
|
194
|
+
- test/remote/test_account_remote.rb
|
195
|
+
- test/remote/test_charge_remote.rb
|
196
|
+
- test/remote/test_request_remote.rb
|
197
|
+
- test/unit/test_account.rb
|
198
|
+
- test/unit/test_charge.rb
|
199
|
+
- test/unit/test_request.rb
|
200
|
+
- test/unit/test_response.rb
|