amazon_flex_pay 0.9.14 → 0.10.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.
@@ -1,303 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class AmazonFlexPayTest < AmazonFlexPay::Test
4
- include ResponseSamples
5
-
6
- ## Cancel
7
-
8
- should "construct a Cancel request" do
9
- AmazonFlexPay::API::Cancel.any_instance.expects(:submit)
10
- assert_nothing_raised do
11
- AmazonFlexPay.cancel('txid', {:description => 'test'})
12
- end
13
- end
14
-
15
- should "parse a Cancel response" do
16
- response = nil
17
- assert_nothing_raised do
18
- response = AmazonFlexPay::API::Cancel::Response.from_xml(cancel_response)
19
- end
20
- assert response.request_id
21
- assert response.transaction_id
22
- assert response.transaction_status
23
- end
24
-
25
- ## CancelToken
26
-
27
- should "construct a CancelToken request" do
28
- AmazonFlexPay::API::CancelToken.any_instance.expects(:submit)
29
- assert_nothing_raised do
30
- AmazonFlexPay.cancel_token('token', {:reason_text => 'test'})
31
- end
32
- end
33
-
34
- should "parse a CancelToken response" do
35
- response = nil
36
- assert_nothing_raised do
37
- response = AmazonFlexPay::API::CancelToken::Response.from_xml(cancel_token_response)
38
- end
39
- assert response.request_id
40
- end
41
-
42
- ## GetAccountActivity
43
-
44
- should "construct a GetAccountActivity request" do
45
- AmazonFlexPay::API::GetAccountActivity.any_instance.expects(:submit)
46
- since = Time.now - 60*60*24 # 1.day
47
- to = Time.now
48
- assert_nothing_raised do
49
- AmazonFlexPay.get_account_activity(since, to)
50
- end
51
- end
52
-
53
- should "parse a GetAccountActivity response" do
54
- response = nil
55
- assert_nothing_raised do
56
- response = AmazonFlexPay::API::GetAccountActivity::Response.from_xml(get_account_activity_response)
57
- end
58
- assert response.request_id
59
- assert_equal 5, response.transactions.count
60
- end
61
-
62
- ## GetAccountBalance
63
-
64
- should "construct a GetAccountBalance request" do
65
- AmazonFlexPay::API::GetAccountBalance.any_instance.expects(:submit)
66
- assert_nothing_raised do
67
- AmazonFlexPay.get_account_balance
68
- end
69
- end
70
-
71
- should "parse a GetAccountBalance response" do
72
- response = nil
73
- assert_nothing_raised do
74
- response = AmazonFlexPay::API::GetAccountBalance::Response.from_xml(get_account_balance_response)
75
- end
76
- assert response.request_id
77
- assert_equal '7.400000', response.account_balance.total_balance.value
78
- end
79
-
80
- ## GetRecipientVerificationStatus
81
-
82
- should "construct a GetRecipientVerificationStatus request" do
83
- AmazonFlexPay::API::GetRecipientVerificationStatus.any_instance.expects(:submit)
84
- assert_nothing_raised do
85
- AmazonFlexPay.get_recipient_verification_status('token')
86
- end
87
- end
88
-
89
- should "parse a GetRecipientVerificationStatus response" do
90
- response = nil
91
- assert_nothing_raised do
92
- response = AmazonFlexPay::API::GetRecipientVerificationStatus::Response.from_xml(get_recipient_verification_status_response)
93
- end
94
- assert response.request_id
95
- assert response.recipient_verification_status
96
- end
97
-
98
- ## GetTokenByCaller
99
-
100
- should "construct a GetTokenByCaller request by reference" do
101
- AmazonFlexPay::API::GetTokenByCaller.any_instance.expects(:submit)
102
- assert_nothing_raised do
103
- AmazonFlexPay.get_token_by_caller_reference('reference')
104
- end
105
- end
106
-
107
- should "construct a GetTokenByCaller request by token id" do
108
- AmazonFlexPay::API::GetTokenByCaller.any_instance.expects(:submit)
109
- assert_nothing_raised do
110
- AmazonFlexPay.get_token_by_id('token')
111
- end
112
- end
113
-
114
- should "parse a GetTokenByCaller response" do
115
- response = nil
116
- assert_nothing_raised do
117
- response = AmazonFlexPay::API::GetTokenByCaller::Response.from_xml(get_token_by_caller_response)
118
- end
119
- assert response.request_id
120
- assert response.token.token_id
121
- assert response.token.token_status
122
- end
123
-
124
- ## GetTokenUsage
125
-
126
- should "construct a GetTokenUsage request" do
127
- AmazonFlexPay::API::GetTokenUsage.any_instance.expects(:submit)
128
- assert_nothing_raised do
129
- AmazonFlexPay.get_token_usage('token')
130
- end
131
- end
132
-
133
- should "parse a GetTokenUsage response" do
134
- response = nil
135
- assert_nothing_raised do
136
- response = AmazonFlexPay::API::GetTokenUsage::Response.from_xml(get_token_usage_response)
137
- end
138
- assert_equal 2, response.token_usage_limits.count
139
- assert_equal '10.000000', response.token_usage_limits.first.amount.value
140
- assert_equal '1', response.token_usage_limits.last.count
141
- end
142
-
143
- ## GetTokens
144
-
145
- should "construct a GetTokens request" do
146
- AmazonFlexPay::API::GetTokens.any_instance.expects(:submit)
147
- assert_nothing_raised do
148
- AmazonFlexPay.get_tokens
149
- end
150
- end
151
-
152
- should "parse a GetTokens response" do
153
- response = nil
154
- assert_nothing_raised do
155
- response = AmazonFlexPay::API::GetTokens::Response.from_xml(get_tokens_response)
156
- end
157
- assert_equal 1, response.tokens.count
158
- end
159
-
160
- ## GetTransaction
161
-
162
- should "construct a GetTransaction request" do
163
- AmazonFlexPay::API::GetTransaction.any_instance.expects(:submit)
164
- assert_nothing_raised do
165
- AmazonFlexPay.get_transaction('txid')
166
- end
167
- end
168
-
169
- should "parse a GetTransaction response" do
170
- response = nil
171
- assert_nothing_raised do
172
- response = AmazonFlexPay::API::GetTransaction::Response.from_xml(get_transaction_response)
173
- end
174
- assert response.request_id
175
- assert response.transaction.caller_reference
176
- assert response.transaction.payment_method
177
- end
178
-
179
- should "delegate to transaction attributes" do
180
- response = AmazonFlexPay::API::GetTransaction::Response.from_xml(get_transaction_response)
181
- assert_equal response.caller_reference, response.transaction.caller_reference
182
- assert_equal response.date_completed, response.transaction.date_completed
183
- end
184
-
185
- ## GetTransactionStatus
186
-
187
- should "construct a GetTransactionStatus request" do
188
- AmazonFlexPay::API::GetTransactionStatus.any_instance.expects(:submit)
189
- assert_nothing_raised do
190
- AmazonFlexPay.get_transaction_status('txid')
191
- end
192
- end
193
-
194
- should "parse a GetTransactionStatus response" do
195
- response = nil
196
- assert_nothing_raised do
197
- response = AmazonFlexPay::API::GetTransactionStatus::Response.from_xml(get_transaction_status_response)
198
- end
199
- assert response.request_id
200
- assert response.transaction_id
201
- assert_equal 'Success', response.transaction_status
202
- end
203
-
204
- ## Pay
205
-
206
- should "construct a Pay request" do
207
- request = nil
208
- assert_nothing_raised do
209
- request = AmazonFlexPay::API::Pay.new(:transaction_amount => {:currency_code => 'USD', :value => '1.00'}, :caller_reference => 'myid')
210
- end
211
- assert_equal '1.00', request.transaction_amount.value
212
- end
213
-
214
- should "parse a Pay response" do
215
- response = nil
216
- assert_nothing_raised do
217
- response = AmazonFlexPay::API::Pay::Response.from_xml(reserve_response)
218
- end
219
- assert response.request_id
220
- assert response.transaction_id
221
- assert response.transaction_status
222
- end
223
-
224
- ## Refund
225
-
226
- should "construct a Refund request" do
227
- request = nil
228
- assert_nothing_raised do
229
- request = AmazonFlexPay::API::Refund.new(:transaction_id => 'txid', :caller_reference => 'myid', :refund_amount => {:currency_code => 'USD', :value => '1.00'})
230
- end
231
- assert_equal '1.00', request.refund_amount.value
232
- end
233
-
234
- should "parse a Refund response" do
235
- response = nil
236
- assert_nothing_raised do
237
- response = AmazonFlexPay::API::Refund::Response.from_xml(refund_response)
238
- end
239
- assert response.request_id
240
- assert response.transaction_id
241
- assert response.transaction_status
242
- end
243
-
244
- ## Reserve
245
-
246
- should "construct a Reserve request" do
247
- request = nil
248
- assert_nothing_raised do
249
- request = AmazonFlexPay::API::Reserve.new(:sender_token_id => 'token', :transaction_amount => {:currency_code => 'USD', :value => '1.00'}, :caller_reference => 'myid', :descriptor_policy => {:cs_owner => 'Caller', :soft_descriptor_type => 'Static'})
250
- end
251
- assert_equal 'Caller', request.descriptor_policy.cs_owner
252
- assert request.to_params['DescriptorPolicy'].has_key?('CSOwner') # funky casing
253
- end
254
-
255
- should "parse a Reserve response" do
256
- response = nil
257
- assert_nothing_raised do
258
- response = AmazonFlexPay::API::Reserve::Response.from_xml(reserve_response)
259
- end
260
- assert response.request_id
261
- assert response.transaction_id
262
- assert response.transaction_status
263
- end
264
-
265
- ## Settle
266
-
267
- should "construct a Settle request" do
268
- request = nil
269
- assert_nothing_raised do
270
- request = AmazonFlexPay::API::Settle.new(:reserve_transaction_id => 'txid', :transaction_amount => {:currency_code => 'USD', :value => '3.14'})
271
- end
272
- assert_equal 'USD', request.transaction_amount.currency_code
273
- assert_equal '3.14', request.transaction_amount.value
274
- end
275
-
276
- should "parse a Settle response" do
277
- response = nil
278
- assert_nothing_raised do
279
- response = AmazonFlexPay::API::Settle::Response.from_xml(settle_response)
280
- end
281
- assert response.request_id
282
- assert response.transaction_id
283
- assert response.transaction_status
284
- end
285
-
286
- ## VerifySignature
287
-
288
- should "construct a VerifySignature request" do
289
- AmazonFlexPay::API::VerifySignature.any_instance.expects(:submit)
290
- assert_nothing_raised do
291
- AmazonFlexPay.verify_signature('http://example.com/api', 'foo=bar')
292
- end
293
- end
294
-
295
- should "parse a VerifySignature response" do
296
- response = nil
297
- assert_nothing_raised do
298
- response = AmazonFlexPay::API::VerifySignature::Response.from_xml(verify_signature_response)
299
- end
300
- assert response.request_id
301
- assert response.verification_status
302
- end
303
- end
@@ -1,48 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class AmazonFlexPayPipelinesTest < AmazonFlexPay::Test
4
- should "build a edit token pipeline" do
5
- params = nil
6
- assert_nothing_raised do
7
- params = AmazonFlexPay.edit_token_pipeline('pipe1', :token_id => 'token').to_params('http://example.com/return')
8
- end
9
- assert_equal 'pipe1', params['callerReference']
10
- end
11
-
12
- should "build a multi use pipeline" do
13
- params = nil
14
- assert_nothing_raised do
15
- params = AmazonFlexPay.multi_use_pipeline('pipe2',
16
- :global_amount_limit => "50.00",
17
- :usage_limit_type1 => 'Count',
18
- :usage_limit_value1 => '2'
19
- ).to_params('http://example.com/return')
20
- end
21
- assert_equal 'pipe2', params['callerReference']
22
- assert_equal '50.00', params['globalAmountLimit']
23
- assert_equal 'Count', params['usageLimitType1']
24
- assert_equal '2', params['usageLimitValue1']
25
- end
26
-
27
- should "build a recipient pipeline" do
28
- params = nil
29
- assert_nothing_raised do
30
- params = AmazonFlexPay::recipient_pipeline('pipe3', :recipient_pays_fee => true).to_params('http://example.com/return')
31
- end
32
- assert_equal 'pipe3', params['callerReference']
33
- end
34
-
35
- should "build a single use pipeline" do
36
- params = nil
37
- assert_nothing_raised do
38
- params = AmazonFlexPay.single_use_pipeline('pipe4',
39
- :recipient_token => 'token',
40
- :transaction_amount => '25.00',
41
- :disable_guest => true
42
- ).to_params('http://example.com/return')
43
- end
44
- assert_equal 'pipe4', params['callerReference']
45
- assert_equal '25.00', params['transactionAmount']
46
- assert_equal 'True', params['disableGuest']
47
- end
48
- end