remit 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/remit/get_pipeline.rb +1 -0
- data/lib/remit/ipn_request.rb +8 -18
- data/lib/remit/{cancel_token.rb → operations/cancel_token.rb} +1 -1
- data/lib/remit/{discard_results.rb → operations/discard_results.rb} +1 -1
- data/lib/remit/{fund_prepaid.rb → operations/fund_prepaid.rb} +6 -6
- data/lib/remit/{get_account_activity.rb → operations/get_account_activity.rb} +1 -1
- data/lib/remit/{get_account_balance.rb → operations/get_account_balance.rb} +0 -0
- data/lib/remit/{get_all_credit_instruments.rb → operations/get_all_credit_instruments.rb} +0 -0
- data/lib/remit/{get_all_prepaid_instruments.rb → operations/get_all_prepaid_instruments.rb} +0 -0
- data/lib/remit/{get_debt_balance.rb → operations/get_debt_balance.rb} +1 -1
- data/lib/remit/{get_outstanding_debt_balance.rb → operations/get_outstanding_debt_balance.rb} +0 -0
- data/lib/remit/{get_payment_instruction.rb → operations/get_payment_instruction.rb} +1 -1
- data/lib/remit/{get_prepaid_balance.rb → operations/get_prepaid_balance.rb} +1 -1
- data/lib/remit/{get_results.rb → operations/get_results.rb} +0 -0
- data/lib/remit/{get_token_by_caller.rb → operations/get_token_by_caller.rb} +0 -0
- data/lib/remit/{get_token_usage.rb → operations/get_token_usage.rb} +1 -1
- data/lib/remit/{get_tokens.rb → operations/get_tokens.rb} +0 -0
- data/lib/remit/{get_total_prepaid_liability.rb → operations/get_total_prepaid_liability.rb} +0 -0
- data/lib/remit/{get_transaction.rb → operations/get_transaction.rb} +1 -1
- data/lib/remit/{install_payment_instruction.rb → operations/install_payment_instruction.rb} +3 -3
- data/lib/remit/{pay.rb → operations/pay.rb} +6 -6
- data/lib/remit/{refund.rb → operations/refund.rb} +6 -8
- data/lib/remit/{reserve.rb → operations/reserve.rb} +6 -6
- data/lib/remit/{retry_transaction.rb → operations/retry_transaction.rb} +1 -1
- data/lib/remit/{settle.rb → operations/settle.rb} +2 -2
- data/lib/remit/{settle_debt.rb → operations/settle_debt.rb} +6 -6
- data/lib/remit/{subscribe_for_caller_notification.rb → operations/subscribe_for_caller_notification.rb} +2 -2
- data/lib/remit/{unsubscribe_for_caller_notification.rb → operations/unsubscribe_for_caller_notification.rb} +1 -1
- data/lib/remit/{write_off_debt.rb → operations/write_off_debt.rb} +4 -4
- data/lib/remit/pipeline_response.rb +11 -21
- data/lib/remit.rb +30 -30
- data/spec/units/ipn_request_spec.rb +1 -1
- data/spec/units/pay_spec.rb +72 -9
- metadata +36 -37
data/lib/remit/get_pipeline.rb
CHANGED
data/lib/remit/ipn_request.rb
CHANGED
@@ -2,30 +2,24 @@ require 'base64'
|
|
2
2
|
require 'openssl/digest'
|
3
3
|
|
4
4
|
module Remit
|
5
|
-
|
6
|
-
##
|
7
5
|
# Encapsulates the logic for IPN request validation and attribute retrieval.
|
8
|
-
#
|
9
6
|
class IpnRequest
|
10
|
-
|
11
7
|
# Signature key name used by AmazonFPS IPNs
|
12
|
-
SIGNATURE_KEY = '
|
13
|
-
|
14
|
-
##
|
8
|
+
SIGNATURE_KEY = 'awsSignature'
|
9
|
+
|
15
10
|
# +params+ should be your controllers request parameters.
|
16
|
-
#
|
17
11
|
def initialize(params, secret_key)
|
18
12
|
raise ArgumentError, "Expected the request params hash, received: #{params.inspect}" unless params.kind_of?(Hash)
|
19
13
|
@params = strip_keys_from(params, 'action', 'controller')
|
20
14
|
@supplied_signature = @params.delete(SIGNATURE_KEY)
|
21
15
|
@secret_key = secret_key
|
22
16
|
end
|
23
|
-
|
17
|
+
|
24
18
|
def valid?
|
25
19
|
return false unless @supplied_signature
|
26
20
|
generate_signature_for(@params) == @supplied_signature
|
27
21
|
end
|
28
|
-
|
22
|
+
|
29
23
|
def method_missing(method, *args) #:nodoc:
|
30
24
|
if @params.has_key?(method.to_s)
|
31
25
|
@params[method.to_s]
|
@@ -33,24 +27,20 @@ module Remit
|
|
33
27
|
super(method, *args)
|
34
28
|
end
|
35
29
|
end
|
36
|
-
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
|
30
|
+
|
41
31
|
def generate_signature_for(params)
|
42
32
|
query = params.sort_by { |k,v| k.downcase }
|
43
33
|
digest = OpenSSL::Digest::Digest.new('sha1')
|
44
34
|
hmac = OpenSSL::HMAC.digest(digest, @secret_key, query.to_s)
|
45
35
|
encoded = Base64.encode64(hmac).chomp
|
46
36
|
end
|
47
|
-
|
37
|
+
private :generate_signature_for
|
38
|
+
|
48
39
|
def strip_keys_from(params, *ignore_keys)
|
49
40
|
parsed = params.dup
|
50
41
|
ignore_keys.each { |key| parsed.delete(key) }
|
51
42
|
parsed
|
52
43
|
end
|
53
|
-
|
44
|
+
private :strip_keys_from
|
54
45
|
end
|
55
|
-
|
56
46
|
end
|
@@ -6,17 +6,17 @@ module Remit
|
|
6
6
|
action :FundPrepaid
|
7
7
|
parameter :transaction_ids
|
8
8
|
parameter :caller_description
|
9
|
-
parameter :caller_reference
|
10
|
-
parameter :caller_token_id
|
11
|
-
parameter :charge_fee_to
|
12
|
-
parameter :funding_amount
|
9
|
+
parameter :caller_reference, :required => true
|
10
|
+
parameter :caller_token_id, :required => true
|
11
|
+
parameter :charge_fee_to, :required => true
|
12
|
+
parameter :funding_amount, :type => Remit::RequestTypes::Amount, :required => true
|
13
13
|
parameter :meta_data
|
14
|
-
parameter :prepaid_instrument_id
|
14
|
+
parameter :prepaid_instrument_id, :required => true
|
15
15
|
parameter :recipient_description
|
16
16
|
parameter :recipient_reference
|
17
17
|
parameter :sender_description
|
18
18
|
parameter :sender_reference
|
19
|
-
parameter :sender_token_id
|
19
|
+
parameter :sender_token_id, :required => true
|
20
20
|
parameter :transaction_date
|
21
21
|
end
|
22
22
|
|
File without changes
|
File without changes
|
File without changes
|
data/lib/remit/{get_outstanding_debt_balance.rb → operations/get_outstanding_debt_balance.rb}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -4,10 +4,10 @@ module Remit
|
|
4
4
|
module InstallPaymentInstruction
|
5
5
|
class Request < Remit::Request
|
6
6
|
action :InstallPaymentInstruction
|
7
|
-
parameter :payment_instruction
|
8
|
-
parameter :caller_reference
|
7
|
+
parameter :payment_instruction, :required => true
|
8
|
+
parameter :caller_reference, :required => true
|
9
9
|
parameter :token_friendly_name
|
10
|
-
parameter :token_type
|
10
|
+
parameter :token_type, :required => true
|
11
11
|
parameter :payment_reason
|
12
12
|
end
|
13
13
|
|
@@ -5,21 +5,21 @@ module Remit
|
|
5
5
|
class Request < Remit::Request
|
6
6
|
action :Pay
|
7
7
|
parameter :caller_description
|
8
|
-
parameter :caller_reference
|
9
|
-
parameter :caller_token_id
|
10
|
-
parameter :charge_fee_to
|
8
|
+
parameter :caller_reference, :required => true
|
9
|
+
parameter :caller_token_id, :required => true
|
10
|
+
parameter :charge_fee_to, :required => true
|
11
11
|
parameter :descriptor_policy, :type => Remit::RequestTypes::DescriptorPolicy
|
12
12
|
parameter :marketplace_fixed_fee, :type => Remit::RequestTypes::Amount
|
13
13
|
parameter :marketplace_variable_fee
|
14
14
|
parameter :meta_data
|
15
15
|
parameter :recipient_description
|
16
16
|
parameter :recipient_reference
|
17
|
-
parameter :recipient_token_id
|
17
|
+
parameter :recipient_token_id, :required => true
|
18
18
|
parameter :sender_description
|
19
19
|
parameter :sender_reference
|
20
|
-
parameter :sender_token_id
|
20
|
+
parameter :sender_token_id, :required => true
|
21
21
|
parameter :temporary_decline_policy, :type => Remit::RequestTypes::TemporaryDeclinePolicy
|
22
|
-
parameter :transaction_amount, :type => Remit::RequestTypes::Amount
|
22
|
+
parameter :transaction_amount, :type => Remit::RequestTypes::Amount, :required => true
|
23
23
|
parameter :transaction_date
|
24
24
|
end
|
25
25
|
|
@@ -5,26 +5,24 @@ module Remit
|
|
5
5
|
class Request < Remit::Request
|
6
6
|
action :Refund
|
7
7
|
parameter :caller_description
|
8
|
-
parameter :caller_reference
|
9
|
-
parameter :caller_token_id
|
10
|
-
parameter :charge_fee_to
|
8
|
+
parameter :caller_reference, :required => true
|
9
|
+
parameter :caller_token_id, :required => true
|
10
|
+
parameter :charge_fee_to, :required => true
|
11
11
|
parameter :meta_data
|
12
12
|
parameter :refund_amount, :type => Remit::RequestTypes::Amount
|
13
13
|
parameter :refund_recipient_description
|
14
14
|
parameter :refund_recipient_reference
|
15
15
|
parameter :refund_sender_description
|
16
16
|
parameter :refund_sender_reference
|
17
|
-
parameter :refund_sender_token_id
|
17
|
+
parameter :refund_sender_token_id, :required => true
|
18
18
|
parameter :transaction_date
|
19
|
-
parameter :transaction_id
|
20
|
-
|
21
|
-
|
19
|
+
parameter :transaction_id, :required => true
|
20
|
+
|
22
21
|
# The RefundAmount parameter has multiple components. It is specified on the query string like
|
23
22
|
# so: RefundAmount.Amount=XXX&RefundAmount.CurrencyCode=YYY
|
24
23
|
def convert_complex_key(key, parameter)
|
25
24
|
"#{convert_key(key).to_s}.#{convert_key(parameter).to_s}"
|
26
25
|
end
|
27
|
-
|
28
26
|
end
|
29
27
|
|
30
28
|
class Response < Remit::Response
|
@@ -4,15 +4,15 @@ module Remit
|
|
4
4
|
module Reserve
|
5
5
|
class Request < Remit::Request
|
6
6
|
action :Reserve
|
7
|
-
parameter :recipient_token_id
|
8
|
-
parameter :sender_token_id
|
9
|
-
parameter :caller_token_id
|
7
|
+
parameter :recipient_token_id, :required => true
|
8
|
+
parameter :sender_token_id, :required => true
|
9
|
+
parameter :caller_token_id, :required => true
|
10
10
|
parameter :sender_reference
|
11
11
|
parameter :recipient_reference
|
12
|
-
parameter :caller_reference
|
12
|
+
parameter :caller_reference, :required => true
|
13
13
|
parameter :transaction_date
|
14
|
-
parameter :transaction_amount
|
15
|
-
parameter :charge_fee_to
|
14
|
+
parameter :transaction_amount, :type => Remit::RequestTypes::Amount, :required => true
|
15
|
+
parameter :charge_fee_to, :required => true
|
16
16
|
parameter :sender_description
|
17
17
|
parameter :recipient_description
|
18
18
|
parameter :caller_description
|
@@ -4,8 +4,8 @@ module Remit
|
|
4
4
|
module Settle
|
5
5
|
class Request < Remit::Request
|
6
6
|
action :Settle
|
7
|
-
parameter :
|
8
|
-
parameter :
|
7
|
+
parameter :reserve_transaction_id, :required => true
|
8
|
+
parameter :transaction_amount, :type => Remit::RequestTypes::Amount
|
9
9
|
parameter :transaction_date
|
10
10
|
end
|
11
11
|
|
@@ -5,17 +5,17 @@ module Remit
|
|
5
5
|
class Request < Remit::Request
|
6
6
|
action :SettleDebt
|
7
7
|
parameter :caller_description
|
8
|
-
parameter :caller_reference
|
9
|
-
parameter :caller_token_id
|
10
|
-
parameter :charge_fee_to
|
11
|
-
parameter :credit_instrument_id
|
8
|
+
parameter :caller_reference, :required => true
|
9
|
+
parameter :caller_token_id, :required => true
|
10
|
+
parameter :charge_fee_to, :required => true
|
11
|
+
parameter :credit_instrument_id, :required => true
|
12
12
|
parameter :meta_data
|
13
13
|
parameter :recipient_description
|
14
14
|
parameter :recipient_reference
|
15
15
|
parameter :sender_description
|
16
16
|
parameter :sender_reference
|
17
|
-
parameter :sender_token_id
|
18
|
-
parameter :settlement_amount
|
17
|
+
parameter :sender_token_id, :required => true
|
18
|
+
parameter :settlement_amount, :type => Remit::RequestTypes::Amount, :required => true
|
19
19
|
parameter :transaction_date
|
20
20
|
end
|
21
21
|
|
@@ -4,8 +4,8 @@ module Remit
|
|
4
4
|
module SubscribeForCallerNotification
|
5
5
|
class Request < Remit::Request
|
6
6
|
action :SubscribeForCallerNotification
|
7
|
-
parameter :notification_operation_name
|
8
|
-
parameter :web_service_api_url
|
7
|
+
parameter :notification_operation_name, :required => true
|
8
|
+
parameter :web_service_api_url, :required => true
|
9
9
|
end
|
10
10
|
|
11
11
|
class Response < Remit::Response
|
@@ -4,7 +4,7 @@ module Remit
|
|
4
4
|
module UnsubscribeForCallerNotification
|
5
5
|
class Request < Remit::Request
|
6
6
|
action :UnSubscribeForCallerNotification
|
7
|
-
parameter :notification_operation_name
|
7
|
+
parameter :notification_operation_name, :required => true
|
8
8
|
end
|
9
9
|
|
10
10
|
class Response < Remit::Response
|
@@ -4,12 +4,12 @@ module Remit
|
|
4
4
|
module WriteOffDebt
|
5
5
|
class Request < Remit::Request
|
6
6
|
action :WriteOffDebt
|
7
|
-
parameter :caller_token_id
|
8
|
-
parameter :credit_instrument_id
|
9
|
-
parameter :adjustment_amount
|
7
|
+
parameter :caller_token_id, :required => true
|
8
|
+
parameter :credit_instrument_id, :required => true
|
9
|
+
parameter :adjustment_amount, :required => true
|
10
10
|
parameter :transaction_date
|
11
11
|
parameter :sender_reference
|
12
|
-
parameter :caller_reference
|
12
|
+
parameter :caller_reference, :required => true
|
13
13
|
parameter :recipient_reference
|
14
14
|
parameter :sender_description
|
15
15
|
parameter :recipient_description
|
@@ -1,28 +1,22 @@
|
|
1
1
|
module Remit
|
2
|
-
|
3
2
|
class PipelineResponse
|
4
|
-
|
5
3
|
def initialize(uri, secret_key)
|
6
4
|
@uri = URI.parse(uri)
|
7
5
|
@secret_key = secret_key
|
8
6
|
end
|
9
|
-
|
10
|
-
##
|
7
|
+
|
11
8
|
# Returns +true+ if the response is correctly signed (awsSignature).
|
12
|
-
#
|
9
|
+
#
|
13
10
|
#--
|
14
11
|
# The unescape_value method is used here because the awsSignature value
|
15
12
|
# pulled from the request is filtered through the same method.
|
16
13
|
#++
|
17
|
-
#
|
18
14
|
def valid?
|
19
15
|
return false unless given_signature
|
20
16
|
Relax::Query.unescape_value(correct_signature) == given_signature
|
21
17
|
end
|
22
|
-
|
23
|
-
##
|
18
|
+
|
24
19
|
# Returns +true+ if the response returns a successful state.
|
25
|
-
#
|
26
20
|
def successful?
|
27
21
|
[
|
28
22
|
Remit::PipelineStatusCode::SUCCESS_ABT,
|
@@ -31,8 +25,7 @@ module Remit
|
|
31
25
|
Remit::PipelineStatusCode::SUCCESS_RECIPIENT_TOKEN_INSTALLED
|
32
26
|
].include?(request_query[:status])
|
33
27
|
end
|
34
|
-
|
35
|
-
|
28
|
+
|
36
29
|
def method_missing(method, *args) #:nodoc:
|
37
30
|
if request_query.has_key?(method.to_sym)
|
38
31
|
request_query[method.to_sym]
|
@@ -40,23 +33,20 @@ module Remit
|
|
40
33
|
super
|
41
34
|
end
|
42
35
|
end
|
43
|
-
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
|
36
|
+
|
48
37
|
def request_query(reload = false)
|
49
38
|
@query ||= Remit::SignedQuery.parse(@uri, @secret_key, @uri.query || '')
|
50
39
|
end
|
51
|
-
|
40
|
+
private :request_query
|
41
|
+
|
52
42
|
def given_signature
|
53
43
|
request_query[:awsSignature]
|
54
44
|
end
|
55
|
-
|
45
|
+
private :given_signature
|
46
|
+
|
56
47
|
def correct_signature
|
57
48
|
Remit::SignedQuery.new(@uri.path, @secret_key, request_query).sign
|
58
49
|
end
|
59
|
-
|
50
|
+
private :correct_signature
|
60
51
|
end
|
61
|
-
|
62
|
-
end
|
52
|
+
end
|
data/lib/remit.rb
CHANGED
@@ -9,43 +9,43 @@ require 'erb'
|
|
9
9
|
|
10
10
|
require 'rubygems'
|
11
11
|
|
12
|
-
gem 'relax', '0.0.
|
12
|
+
gem 'relax', '0.0.7'
|
13
13
|
require 'relax'
|
14
14
|
|
15
15
|
require 'remit/common'
|
16
16
|
require 'remit/data_types'
|
17
|
-
|
18
|
-
require 'remit/cancel_token'
|
19
|
-
require 'remit/discard_results'
|
20
17
|
require 'remit/error_codes'
|
21
|
-
require 'remit/fund_prepaid'
|
22
|
-
require 'remit/get_account_activity'
|
23
|
-
require 'remit/get_account_balance'
|
24
|
-
require 'remit/get_all_credit_instruments'
|
25
|
-
require 'remit/get_all_prepaid_instruments'
|
26
|
-
require 'remit/get_debt_balance'
|
27
|
-
require 'remit/get_outstanding_debt_balance'
|
28
|
-
require 'remit/get_payment_instruction'
|
29
|
-
require 'remit/get_pipeline'
|
30
|
-
require 'remit/get_prepaid_balance'
|
31
|
-
require 'remit/get_results'
|
32
|
-
require 'remit/get_token_usage'
|
33
|
-
require 'remit/get_tokens'
|
34
|
-
require 'remit/get_token_by_caller'
|
35
|
-
require 'remit/get_total_prepaid_liability'
|
36
|
-
require 'remit/get_transaction'
|
37
|
-
require 'remit/install_payment_instruction'
|
38
18
|
require 'remit/ipn_request'
|
39
|
-
require 'remit/
|
19
|
+
require 'remit/get_pipeline'
|
40
20
|
require 'remit/pipeline_response'
|
41
|
-
|
42
|
-
require 'remit/
|
43
|
-
require 'remit/
|
44
|
-
require 'remit/
|
45
|
-
require 'remit/
|
46
|
-
require 'remit/
|
47
|
-
require 'remit/
|
48
|
-
require 'remit/
|
21
|
+
|
22
|
+
require 'remit/operations/cancel_token'
|
23
|
+
require 'remit/operations/discard_results'
|
24
|
+
require 'remit/operations/fund_prepaid'
|
25
|
+
require 'remit/operations/get_account_activity'
|
26
|
+
require 'remit/operations/get_account_balance'
|
27
|
+
require 'remit/operations/get_all_credit_instruments'
|
28
|
+
require 'remit/operations/get_all_prepaid_instruments'
|
29
|
+
require 'remit/operations/get_debt_balance'
|
30
|
+
require 'remit/operations/get_outstanding_debt_balance'
|
31
|
+
require 'remit/operations/get_payment_instruction'
|
32
|
+
require 'remit/operations/get_prepaid_balance'
|
33
|
+
require 'remit/operations/get_results'
|
34
|
+
require 'remit/operations/get_token_by_caller'
|
35
|
+
require 'remit/operations/get_token_usage'
|
36
|
+
require 'remit/operations/get_tokens'
|
37
|
+
require 'remit/operations/get_total_prepaid_liability'
|
38
|
+
require 'remit/operations/get_transaction'
|
39
|
+
require 'remit/operations/install_payment_instruction'
|
40
|
+
require 'remit/operations/pay'
|
41
|
+
require 'remit/operations/refund'
|
42
|
+
require 'remit/operations/reserve'
|
43
|
+
require 'remit/operations/retry_transaction'
|
44
|
+
require 'remit/operations/settle'
|
45
|
+
require 'remit/operations/settle_debt'
|
46
|
+
require 'remit/operations/subscribe_for_caller_notification'
|
47
|
+
require 'remit/operations/unsubscribe_for_caller_notification'
|
48
|
+
require 'remit/operations/write_off_debt'
|
49
49
|
|
50
50
|
module Remit
|
51
51
|
class API < Relax::Service
|
@@ -4,6 +4,7 @@ describe 'an IPN request' do
|
|
4
4
|
before(:each) do
|
5
5
|
@request_params = {
|
6
6
|
"action" => "notice",
|
7
|
+
"awsSignature" => "DA7ZbuQaBDt2/+Mty9XweJyqI1E=",
|
7
8
|
"buyerName" => "Fps Buyer",
|
8
9
|
"callerReference" => "4-8-1-3.5",
|
9
10
|
"controller" => "amazon_fps/ipn",
|
@@ -11,7 +12,6 @@ describe 'an IPN request' do
|
|
11
12
|
"paymentMethod" => "CC",
|
12
13
|
"recipientEmail" => "recipient@email.url",
|
13
14
|
"recipientName" => "Fps Business",
|
14
|
-
"signature" => "DA7ZbuQaBDt2/+Mty9XweJyqI1E=",
|
15
15
|
"status" => "SUCCESS",
|
16
16
|
"transactionAmount" => "USD 3.50",
|
17
17
|
"transactionDate" => "1224687134",
|
data/spec/units/pay_spec.rb
CHANGED
@@ -37,10 +37,9 @@ describe "the Pay API" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "for a failed request" do
|
40
|
-
it_should_behave_like 'a failed response'
|
41
|
-
|
42
40
|
before do
|
43
41
|
doc = <<-XML
|
42
|
+
<?xml version=\"1.0\"?>
|
44
43
|
<ns3:PayResponse xmlns:ns3=\"http://fps.amazonaws.com/doc/2007-01-08/\">
|
45
44
|
<Status>Failure</Status>
|
46
45
|
<Errors>
|
@@ -56,15 +55,79 @@ describe "the Pay API" do
|
|
56
55
|
XML
|
57
56
|
|
58
57
|
@response = Remit::Pay::Response.new(doc)
|
58
|
+
@error = @response.errors.first
|
59
59
|
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
61
|
+
it_should_behave_like 'a failed response'
|
62
|
+
|
63
|
+
describe "with an invalid params error" do
|
64
|
+
it "should be a service error" do
|
65
|
+
@error.should be_kind_of(Remit::ServiceError)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should have an error type of 'Business'" do
|
69
|
+
@error.error_type.should == 'Business'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have an error code of 'InvalidParams'" do
|
73
|
+
@error.error_code.should == 'InvalidParams'
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should not be retriable" do
|
77
|
+
@error.is_retriable.should == 'false'
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should have reason text" do
|
81
|
+
@error.reason_text.should == 'callerTokenId can not be empty'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "for a failed request" do
|
87
|
+
before do
|
88
|
+
doc = <<-XML
|
89
|
+
<?xml version=\"1.0\"?>
|
90
|
+
<ns3:PayResponse xmlns:ns3=\"http://fps.amazonaws.com/doc/2007-01-08/\">
|
91
|
+
<Status>Failure</Status>
|
92
|
+
<Errors>
|
93
|
+
<Errors>
|
94
|
+
<ErrorType>Business</ErrorType>
|
95
|
+
<IsRetriable>false</IsRetriable>
|
96
|
+
<ErrorCode>TokenUsageError</ErrorCode>
|
97
|
+
<ReasonText>The token \"45XU7TLBN995ZQA2U1PS1ZCTJXJMJ3H1GH6VZAB82C1BGLK9X3AXUQDA3QDLJVPX\" has violated its usage policy.</ReasonText>
|
98
|
+
</Errors>
|
99
|
+
</Errors>
|
100
|
+
<RequestId>78acff80-b740-4b57-9301-18d0576e6855:0
|
101
|
+
</RequestId>
|
102
|
+
</ns3:PayResponse>
|
103
|
+
XML
|
104
|
+
|
105
|
+
@response = Remit::Pay::Response.new(doc)
|
106
|
+
@error = @response.errors.first
|
107
|
+
end
|
108
|
+
|
109
|
+
it_should_behave_like 'a failed response'
|
110
|
+
|
111
|
+
describe "with a token usage error" do
|
112
|
+
it "should be a service error" do
|
113
|
+
@error.should be_kind_of(Remit::ServiceError)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should have an error type of 'Business'" do
|
117
|
+
@error.error_type.should == 'Business'
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should have an error code of 'TokenUsageError'" do
|
121
|
+
@error.error_code.should == 'TokenUsageError'
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should not be retriable" do
|
125
|
+
@error.is_retriable.should == 'false'
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should have reason text" do
|
129
|
+
@error.reason_text.should == 'The token "45XU7TLBN995ZQA2U1PS1ZCTJXJMJ3H1GH6VZAB82C1BGLK9X3AXUQDA3QDLJVPX" has violated its usage policy.'
|
130
|
+
end
|
68
131
|
end
|
69
132
|
end
|
70
133
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Hunt
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-27 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.
|
23
|
+
version: 0.0.7
|
24
24
|
version:
|
25
25
|
description:
|
26
26
|
email: tyler@tylerhunt.com
|
@@ -29,51 +29,50 @@ executables: []
|
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files:
|
32
|
-
- README.markdown
|
33
32
|
- LICENSE
|
33
|
+
- README.markdown
|
34
34
|
files:
|
35
|
-
- lib/remit
|
36
|
-
- lib/remit/cancel_token.rb
|
35
|
+
- lib/remit.rb
|
37
36
|
- lib/remit/common.rb
|
38
37
|
- lib/remit/data_types.rb
|
39
|
-
- lib/remit/discard_results.rb
|
40
38
|
- lib/remit/error_codes.rb
|
41
|
-
- lib/remit/fund_prepaid.rb
|
42
|
-
- lib/remit/get_account_activity.rb
|
43
|
-
- lib/remit/get_account_balance.rb
|
44
|
-
- lib/remit/get_all_credit_instruments.rb
|
45
|
-
- lib/remit/get_all_prepaid_instruments.rb
|
46
|
-
- lib/remit/get_debt_balance.rb
|
47
|
-
- lib/remit/get_outstanding_debt_balance.rb
|
48
|
-
- lib/remit/get_payment_instruction.rb
|
49
39
|
- lib/remit/get_pipeline.rb
|
50
|
-
- lib/remit/get_prepaid_balance.rb
|
51
|
-
- lib/remit/get_results.rb
|
52
|
-
- lib/remit/get_token_by_caller.rb
|
53
|
-
- lib/remit/get_token_usage.rb
|
54
|
-
- lib/remit/get_tokens.rb
|
55
|
-
- lib/remit/get_total_prepaid_liability.rb
|
56
|
-
- lib/remit/get_transaction.rb
|
57
|
-
- lib/remit/install_payment_instruction.rb
|
58
40
|
- lib/remit/ipn_request.rb
|
59
|
-
- lib/remit/
|
41
|
+
- lib/remit/operations/cancel_token.rb
|
42
|
+
- lib/remit/operations/discard_results.rb
|
43
|
+
- lib/remit/operations/fund_prepaid.rb
|
44
|
+
- lib/remit/operations/get_account_activity.rb
|
45
|
+
- lib/remit/operations/get_account_balance.rb
|
46
|
+
- lib/remit/operations/get_all_credit_instruments.rb
|
47
|
+
- lib/remit/operations/get_all_prepaid_instruments.rb
|
48
|
+
- lib/remit/operations/get_debt_balance.rb
|
49
|
+
- lib/remit/operations/get_outstanding_debt_balance.rb
|
50
|
+
- lib/remit/operations/get_payment_instruction.rb
|
51
|
+
- lib/remit/operations/get_prepaid_balance.rb
|
52
|
+
- lib/remit/operations/get_results.rb
|
53
|
+
- lib/remit/operations/get_token_by_caller.rb
|
54
|
+
- lib/remit/operations/get_token_usage.rb
|
55
|
+
- lib/remit/operations/get_tokens.rb
|
56
|
+
- lib/remit/operations/get_total_prepaid_liability.rb
|
57
|
+
- lib/remit/operations/get_transaction.rb
|
58
|
+
- lib/remit/operations/install_payment_instruction.rb
|
59
|
+
- lib/remit/operations/pay.rb
|
60
|
+
- lib/remit/operations/refund.rb
|
61
|
+
- lib/remit/operations/reserve.rb
|
62
|
+
- lib/remit/operations/retry_transaction.rb
|
63
|
+
- lib/remit/operations/settle.rb
|
64
|
+
- lib/remit/operations/settle_debt.rb
|
65
|
+
- lib/remit/operations/subscribe_for_caller_notification.rb
|
66
|
+
- lib/remit/operations/unsubscribe_for_caller_notification.rb
|
67
|
+
- lib/remit/operations/write_off_debt.rb
|
60
68
|
- lib/remit/pipeline_response.rb
|
61
|
-
- lib/remit/refund.rb
|
62
|
-
- lib/remit/reserve.rb
|
63
|
-
- lib/remit/retry_transaction.rb
|
64
|
-
- lib/remit/settle.rb
|
65
|
-
- lib/remit/settle_debt.rb
|
66
|
-
- lib/remit/subscribe_for_caller_notification.rb
|
67
|
-
- lib/remit/unsubscribe_for_caller_notification.rb
|
68
|
-
- lib/remit/write_off_debt.rb
|
69
|
-
- lib/remit.rb
|
70
|
-
- README.markdown
|
71
69
|
- LICENSE
|
70
|
+
- README.markdown
|
72
71
|
has_rdoc: true
|
73
|
-
homepage: http://
|
72
|
+
homepage: http://github.com/tylerhunt/remit
|
74
73
|
post_install_message:
|
75
|
-
rdoc_options:
|
76
|
-
|
74
|
+
rdoc_options:
|
75
|
+
- --charset=UTF-8
|
77
76
|
require_paths:
|
78
77
|
- lib
|
79
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|