remit 0.0.6 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +36 -5
- data/lib/remit.rb +35 -39
- data/lib/remit/common.rb +79 -24
- data/lib/remit/data_types.rb +118 -17
- data/lib/remit/get_pipeline.rb +160 -80
- data/lib/remit/inbound_request.rb +85 -0
- data/lib/remit/ipn_request.rb +4 -39
- data/lib/remit/operations/cancel.rb +20 -0
- data/lib/remit/operations/cancel_subscription_and_refund.rb +5 -1
- data/lib/remit/operations/cancel_token.rb +1 -0
- data/lib/remit/operations/fund_prepaid.rb +6 -4
- data/lib/remit/operations/get_account_activity.rb +5 -34
- data/lib/remit/operations/get_account_balance.rb +14 -11
- data/lib/remit/operations/get_all_credit_instruments.rb +2 -0
- data/lib/remit/operations/get_all_prepaid_instruments.rb +2 -0
- data/lib/remit/operations/get_debt_balance.rb +9 -4
- data/lib/remit/operations/get_outstanding_debt_balance.rb +8 -5
- data/lib/remit/operations/get_payment_instruction.rb +2 -0
- data/lib/remit/operations/get_prepaid_balance.rb +9 -5
- data/lib/remit/operations/get_recipient_verification_status.rb +25 -0
- data/lib/remit/operations/get_token_by_caller.rb +5 -1
- data/lib/remit/operations/get_token_usage.rb +5 -1
- data/lib/remit/operations/get_tokens.rb +5 -1
- data/lib/remit/operations/get_total_prepaid_liability.rb +9 -5
- data/lib/remit/operations/get_transaction.rb +1 -25
- data/lib/remit/operations/get_transaction_status.rb +28 -0
- data/lib/remit/operations/install_payment_instruction.rb +8 -1
- data/lib/remit/operations/pay.rb +5 -9
- data/lib/remit/operations/refund.rb +20 -11
- data/lib/remit/operations/reserve.rb +2 -4
- data/lib/remit/operations/settle.rb +2 -1
- data/lib/remit/operations/settle_debt.rb +2 -4
- data/lib/remit/operations/subscribe_for_caller_notification.rb +2 -0
- data/lib/remit/operations/unsubscribe_for_caller_notification.rb +2 -0
- data/lib/remit/operations/write_off_debt.rb +2 -4
- data/lib/remit/pipeline_response.rb +8 -41
- data/lib/remit/signature_utils_for_outbound.rb +74 -0
- data/lib/remit/verify_signature.rb +21 -0
- data/spec/integrations/get_account_activity_spec.rb +25 -19
- data/spec/integrations/get_tokens_spec.rb +9 -7
- data/spec/integrations/integrations_helper.rb +7 -0
- data/spec/integrations/ipn_request_spec.rb +28 -20
- data/spec/integrations/pipeline_response_spec.rb +27 -0
- data/spec/integrations/verify_signature_spec.rb +140 -0
- data/spec/mocks/CancelResponse.xml +13 -0
- data/spec/mocks/CancelSubscriptionAndRefundResponse.xml +10 -0
- data/spec/mocks/CancelTokenResponse.xml +6 -0
- data/spec/mocks/ErrorResponse.xml +15 -0
- data/spec/mocks/FundPrepaidResponse.xml +11 -0
- data/spec/mocks/GetAccountActivityResponse.xml +68 -0
- data/spec/mocks/GetAccountBalanceResponse.xml +34 -0
- data/spec/mocks/GetDebtBalanceResponse.xml +21 -0
- data/spec/mocks/GetOutstandingDebtBalanceResponse.xml +21 -0
- data/spec/mocks/GetPaymentInstructionResponse.xml +25 -0
- data/spec/mocks/GetPrepaidBalanceResponse.xml +21 -0
- data/spec/mocks/GetRecipientVerificationStatusResponse.xml +9 -0
- data/spec/mocks/GetTokenByCallerResponse.xml +22 -0
- data/spec/mocks/GetTokenUsageResponse.xml +28 -0
- data/spec/mocks/GetTokensResponse.xml +22 -0
- data/spec/mocks/GetTotalPrepaidLiabilityResponse.xml +21 -0
- data/spec/mocks/GetTransactionResponse.xml +76 -0
- data/spec/mocks/GetTransactionStatusResponse.xml +16 -0
- data/spec/mocks/InstallPaymentInstructionResponse.xml +10 -0
- data/spec/mocks/PayResponse.xml +11 -0
- data/spec/mocks/RefundResponse.xml +11 -0
- data/spec/mocks/ReserveResponse.xml +11 -0
- data/spec/mocks/SettleDebtResponse.xml +11 -0
- data/spec/mocks/SettleResponse.xml +11 -0
- data/spec/mocks/VerifySignatureResponse.xml +11 -0
- data/spec/mocks/WriteOffDebtResponse.xml +11 -0
- data/spec/mocks/errors/InvalidParameterValue.xml +10 -0
- data/spec/mocks/errors/InvalidParams_certificateUrl.xml +2 -0
- data/spec/mocks/errors/RequestExpired.xml +10 -0
- data/spec/spec_helper.rb +59 -10
- data/spec/units/cancel_subscription_and_refund_spec.rb +29 -0
- data/spec/units/cancel_token_spec.rb +24 -0
- data/spec/units/fund_prepaid_spec.rb +28 -0
- data/spec/units/get_account_activity_spec.rb +58 -0
- data/spec/units/get_account_balance_spec.rb +28 -0
- data/spec/units/get_debt_balance_spec.rb +29 -0
- data/spec/units/get_outstanding_debt_balance_spec.rb +29 -0
- data/spec/units/get_pipeline_spec.rb +16 -0
- data/spec/units/get_prepaid_balance_spec.rb +29 -0
- data/spec/units/get_recipient_verification_status_spec.rb +26 -0
- data/spec/units/get_token_by_caller_spec.rb +56 -0
- data/spec/units/get_token_usage_spec.rb +51 -0
- data/spec/units/get_tokens_spec.rb +56 -0
- data/spec/units/get_total_prepaid_liability_spec.rb +26 -0
- data/spec/units/get_transaction_spec.rb +103 -0
- data/spec/units/get_transaction_status_spec.rb +44 -0
- data/spec/units/pay_spec.rb +36 -57
- data/spec/units/refund_spec.rb +41 -0
- data/spec/units/reserve_spec.rb +41 -0
- data/spec/units/settle_debt_spec.rb +41 -0
- data/spec/units/settle_spec.rb +41 -0
- data/spec/units/units_helper.rb +23 -2
- data/spec/units/write_off_debt_spec.rb +41 -0
- metadata +116 -12
- data/lib/remit/operations/discard_results.rb +0 -18
- data/lib/remit/operations/get_results.rb +0 -27
- data/lib/remit/operations/retry_transaction.rb +0 -18
- data/spec/units/get_results_spec.rb +0 -49
@@ -6,28 +6,37 @@ module Remit
|
|
6
6
|
action :Refund
|
7
7
|
parameter :caller_description
|
8
8
|
parameter :caller_reference, :required => true
|
9
|
-
parameter :caller_token_id, :required => true
|
10
|
-
parameter :charge_fee_to, :required => true
|
11
|
-
parameter :meta_data
|
12
9
|
parameter :refund_amount, :type => Remit::RequestTypes::Amount
|
13
|
-
parameter :refund_recipient_description
|
14
|
-
parameter :refund_recipient_reference
|
15
|
-
parameter :refund_sender_description
|
16
|
-
parameter :refund_sender_reference
|
17
|
-
parameter :refund_sender_token_id, :required => true
|
18
|
-
parameter :transaction_date
|
19
10
|
parameter :transaction_id, :required => true
|
11
|
+
#MarketplaceRefundPolicy is available in these APIs:
|
12
|
+
# Amazon FPS Advanced Quick Start
|
13
|
+
# Amazon FPS Marketplace Quick Start
|
14
|
+
# Amazon FPS Aggregated Payments Quick Start
|
15
|
+
# i.e. Not Basic Quick Start
|
16
|
+
#Amazon Docs now correctly list it as an Enumerated DataType
|
17
|
+
parameter :marketplace_refund_policy
|
18
|
+
parameter :timestamp
|
19
|
+
# TODO: Check these parameters in Latest FPS API
|
20
|
+
# parameter :refund_recipient_description
|
21
|
+
# parameter :refund_recipient_reference
|
22
|
+
# parameter :refund_sender_description
|
23
|
+
# parameter :refund_sender_reference
|
24
|
+
# parameter :refund_sender_token_id
|
25
|
+
# parameter :transaction_date
|
20
26
|
|
21
27
|
# The RefundAmount parameter has multiple components. It is specified on the query string like
|
22
28
|
# so: RefundAmount.Amount=XXX&RefundAmount.CurrencyCode=YYY
|
23
29
|
def convert_complex_key(key, parameter)
|
24
|
-
"#{convert_key(key)
|
30
|
+
"#{convert_key(key)}.#{convert_key(parameter)}"
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
34
|
class Response < Remit::Response
|
29
35
|
parser :rexml
|
30
|
-
|
36
|
+
#Namespace changed with new API:
|
37
|
+
# parameter :transaction_response, :namespace => 'ns3', :type => TransactionResponse
|
38
|
+
parameter :refund_result, :type => Remit::TransactionResponse
|
39
|
+
parameter :response_metadata, :type => ResponseMetadata
|
31
40
|
end
|
32
41
|
|
33
42
|
def refund(request = Request.new)
|
@@ -6,7 +6,6 @@ module Remit
|
|
6
6
|
action :Reserve
|
7
7
|
parameter :recipient_token_id, :required => true
|
8
8
|
parameter :sender_token_id, :required => true
|
9
|
-
parameter :caller_token_id, :required => true
|
10
9
|
parameter :sender_reference
|
11
10
|
parameter :recipient_reference
|
12
11
|
parameter :caller_reference, :required => true
|
@@ -14,13 +13,12 @@ module Remit
|
|
14
13
|
parameter :transaction_amount, :type => Remit::RequestTypes::Amount, :required => true
|
15
14
|
parameter :charge_fee_to, :required => true
|
16
15
|
parameter :sender_description
|
17
|
-
parameter :recipient_description
|
18
16
|
parameter :caller_description
|
19
|
-
parameter :meta_data
|
20
17
|
end
|
21
18
|
|
22
19
|
class Response < Remit::Response
|
23
|
-
parameter :
|
20
|
+
parameter :reserve_result, :type => Remit::TransactionResponse
|
21
|
+
parameter :response_metadata, :type=>ResponseMetadata
|
24
22
|
end
|
25
23
|
|
26
24
|
def reserve(request = Request.new)
|
@@ -10,7 +10,8 @@ module Remit
|
|
10
10
|
end
|
11
11
|
|
12
12
|
class Response < Remit::Response
|
13
|
-
parameter :
|
13
|
+
parameter :settle_result, :type => Remit::TransactionResponse
|
14
|
+
parameter :response_metadata, :type=>ResponseMetadata
|
14
15
|
end
|
15
16
|
|
16
17
|
def settle(request = Request.new)
|
@@ -6,11 +6,8 @@ module Remit
|
|
6
6
|
action :SettleDebt
|
7
7
|
parameter :caller_description
|
8
8
|
parameter :caller_reference, :required => true
|
9
|
-
parameter :caller_token_id, :required => true
|
10
9
|
parameter :charge_fee_to, :required => true
|
11
10
|
parameter :credit_instrument_id, :required => true
|
12
|
-
parameter :meta_data
|
13
|
-
parameter :recipient_description
|
14
11
|
parameter :recipient_reference
|
15
12
|
parameter :sender_description
|
16
13
|
parameter :sender_reference
|
@@ -20,7 +17,8 @@ module Remit
|
|
20
17
|
end
|
21
18
|
|
22
19
|
class Response < Remit::Response
|
23
|
-
parameter :
|
20
|
+
parameter :settle_debt_result, :type => Remit::TransactionResponse
|
21
|
+
parameter :response_metadata, :type=>ResponseMetadata
|
24
22
|
end
|
25
23
|
|
26
24
|
def settle_debt(request = Request.new)
|
@@ -4,7 +4,6 @@ module Remit
|
|
4
4
|
module WriteOffDebt
|
5
5
|
class Request < Remit::Request
|
6
6
|
action :WriteOffDebt
|
7
|
-
parameter :caller_token_id, :required => true
|
8
7
|
parameter :credit_instrument_id, :required => true
|
9
8
|
parameter :adjustment_amount, :required => true
|
10
9
|
parameter :transaction_date
|
@@ -12,13 +11,12 @@ module Remit
|
|
12
11
|
parameter :caller_reference, :required => true
|
13
12
|
parameter :recipient_reference
|
14
13
|
parameter :sender_description
|
15
|
-
parameter :recipient_description
|
16
14
|
parameter :caller_description
|
17
|
-
parameter :meta_data
|
18
15
|
end
|
19
16
|
|
20
17
|
class Response < Remit::Response
|
21
|
-
parameter :
|
18
|
+
parameter :write_off_debt_result, :type => Remit::TransactionResponse
|
19
|
+
parameter :response_metadata, :type=>ResponseMetadata
|
22
20
|
end
|
23
21
|
|
24
22
|
def write_off_debt(request = Request.new)
|
@@ -1,53 +1,20 @@
|
|
1
1
|
module Remit
|
2
|
-
class PipelineResponse
|
3
|
-
def initialize(params, uri, access_key, secret_key)
|
4
|
-
@params = strip_keys_from(params, 'action', 'controller', 'id')
|
5
|
-
@uri = URI.parse(uri)
|
6
|
-
@url_end_point = @uri.scheme + '://' + @uri.host + @uri.path
|
7
|
-
@access_key = access_key
|
8
|
-
@secret_key = secret_key
|
9
|
-
end
|
10
|
-
|
11
|
-
# Returns +true+ if the response is correctly signed (awsSignature).
|
12
|
-
#
|
13
|
-
#--
|
14
|
-
# The unescape_value method is used here because the awsSignature value
|
15
|
-
# pulled from the request is filtered through the same method.
|
16
|
-
#++
|
17
|
-
def valid?
|
18
|
-
utils = Amazon::FPS::SignatureUtilsForOutbound.new(@access_key, @secret_key);
|
19
|
-
utils.validate_request(:parameters => @params, :url_end_point => @url_end_point, :http_method => "GET")
|
20
|
-
end
|
21
2
|
|
22
|
-
|
3
|
+
class PipelineResponse < InboundRequest
|
4
|
+
# signature key name
|
5
|
+
SIGNATURE_KEY = 'awsSignature'
|
6
|
+
|
23
7
|
def successful?
|
24
8
|
[
|
9
|
+
Remit::PipelineStatusCode::SUCCESS_UNCHANGED,
|
25
10
|
Remit::PipelineStatusCode::SUCCESS_ABT,
|
26
11
|
Remit::PipelineStatusCode::SUCCESS_ACH,
|
27
12
|
Remit::PipelineStatusCode::SUCCESS_CC,
|
28
13
|
Remit::PipelineStatusCode::SUCCESS_RECIPIENT_TOKEN_INSTALLED
|
29
|
-
].include?(
|
30
|
-
|
31
|
-
|
32
|
-
def method_missing(method, *args) #:nodoc:
|
33
|
-
if request_query.has_key?(method.to_sym)
|
34
|
-
request_query[method.to_sym]
|
35
|
-
else
|
36
|
-
super
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def request_query(reload = false)
|
41
|
-
@query ||= Remit::SignedQuery.parse(@uri, @secret_key, @uri.query || '')
|
42
|
-
end
|
43
|
-
private :request_query
|
14
|
+
].include?(@hash_params['status']) #:status])
|
15
|
+
# BJM: 'status' not :status
|
44
16
|
|
45
|
-
def strip_keys_from(params, *ignore_keys)
|
46
|
-
parsed = params.dup
|
47
|
-
ignore_keys.each { |key| parsed.delete(key) }
|
48
|
-
parsed
|
49
17
|
end
|
50
|
-
private :strip_keys_from
|
51
|
-
|
52
18
|
end
|
19
|
+
|
53
20
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'cgi'
|
3
|
+
#require 'openssl'
|
4
|
+
#require 'net/http'
|
5
|
+
#require 'net/https'
|
6
|
+
|
7
|
+
#Lifted From Amazon FPSRuby Code example and then refactored for remit
|
8
|
+
module Remit
|
9
|
+
module SignatureUtilsForOutbound
|
10
|
+
# Convert a string into URL encoded form.
|
11
|
+
def urlencode(plaintext)
|
12
|
+
CGI.escape(plaintext.to_s).gsub("+", "%20").gsub("%7E", "~")
|
13
|
+
end
|
14
|
+
|
15
|
+
# def get_http_data(url)
|
16
|
+
# #2. fetch certificate if not found in cache
|
17
|
+
# uri = URI.parse(url)
|
18
|
+
# http_session = Net::HTTP.new(uri.host, uri.port)
|
19
|
+
# http_session.use_ssl = true
|
20
|
+
# http_session.ca_file = 'ca-bundle.crt'
|
21
|
+
# http_session.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
22
|
+
# http_session.verify_depth = 5
|
23
|
+
#
|
24
|
+
# res = http_session.start {|http_session|
|
25
|
+
# req = Net::HTTP::Get.new(url, {"User-Agent" => USER_AGENT_STRING})
|
26
|
+
# http_session.request(req)
|
27
|
+
# }
|
28
|
+
#
|
29
|
+
# return res.body
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# def starts_with(string, prefix)
|
33
|
+
# prefix = prefix.to_s
|
34
|
+
# string[0, prefix.length] == prefix
|
35
|
+
# end
|
36
|
+
|
37
|
+
def get_http_params(params)
|
38
|
+
params.map do |(k, v)|
|
39
|
+
urlencode(k) + "=" + urlencode(v)
|
40
|
+
end.join("&")
|
41
|
+
end
|
42
|
+
|
43
|
+
SIGNATURE_KEYNAME = "signature"
|
44
|
+
SIGNATURE_METHOD_KEYNAME = "signatureMethod"
|
45
|
+
SIGNATURE_VERSION_KEYNAME = "signatureVersion"
|
46
|
+
CERTIFICATE_URL_KEYNAME = "certificateUrl"
|
47
|
+
SIGNATURE_VERSION_2 = "2"
|
48
|
+
|
49
|
+
#Will raise an error if there are obvious problems with the request (indicating it was forged or corrupted)
|
50
|
+
def check_parameters(params)
|
51
|
+
# begin
|
52
|
+
raise ":parameters must be enumerable" unless params.kind_of? Enumerable
|
53
|
+
|
54
|
+
signature = params[SIGNATURE_KEYNAME];
|
55
|
+
raise "'signature' is missing from the parameters." if (signature.nil?)
|
56
|
+
|
57
|
+
signature_version = params[SIGNATURE_VERSION_KEYNAME];
|
58
|
+
raise "'signatureVersion' is missing from the parameters." if (signature_version.nil?)
|
59
|
+
raise "'signatureVersion' present in parameters is invalid. Valid values are: 2" if (signature_version != SIGNATURE_VERSION_2)
|
60
|
+
|
61
|
+
signature_method = params[SIGNATURE_METHOD_KEYNAME]
|
62
|
+
raise "'signatureMethod' is missing from the parameters." if (signature_method.nil?)
|
63
|
+
|
64
|
+
certificate_url = params[CERTIFICATE_URL_KEYNAME]
|
65
|
+
raise "'certificate_url' is missing from the parameters." if (certificate_url.nil?)
|
66
|
+
return true
|
67
|
+
# rescue
|
68
|
+
# puts "There was a problem with parameters being invalid or missing."
|
69
|
+
# return false
|
70
|
+
# end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Remit
|
2
|
+
module VerifySignature
|
3
|
+
class Request < Remit::Request
|
4
|
+
action :VerifySignature
|
5
|
+
parameter :url_end_point, :required => true
|
6
|
+
parameter :http_parameters, :required => true
|
7
|
+
parameter :version, :required => true
|
8
|
+
end
|
9
|
+
|
10
|
+
class Response < Remit::Response
|
11
|
+
class VerifySignatureResult < BaseResponse
|
12
|
+
parameter :verification_status
|
13
|
+
end
|
14
|
+
parameter :verify_signature_result, :type => VerifySignatureResult
|
15
|
+
end
|
16
|
+
|
17
|
+
def verify_signature(request = Request.new)
|
18
|
+
call(request, Response)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -9,28 +9,34 @@ describe 'a GetAccountActivity call' do
|
|
9
9
|
@response = remit.get_account_activity(request)
|
10
10
|
end
|
11
11
|
|
12
|
+
it "has results" do
|
13
|
+
@response.get_account_activity_result.should_not be_nil
|
14
|
+
end
|
15
|
+
|
12
16
|
it 'should have a collection of transactions' do
|
13
|
-
@response.should
|
17
|
+
@response.get_account_activity_result.transactions.class.should == Array
|
14
18
|
end
|
15
19
|
|
16
20
|
it 'should have a transaction with all of its values set' do
|
17
|
-
transaction = @response.transactions.first
|
18
|
-
|
19
|
-
transaction
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
21
|
+
transaction = @response.get_account_activity_result.transactions.first
|
22
|
+
#Depending on the data in the sandbox used there may or may not actually be data here:
|
23
|
+
if transaction
|
24
|
+
transaction.caller_name.should_not be_empty
|
25
|
+
transaction.caller_transaction_date.should_not be_nil
|
26
|
+
transaction.date_completed.should_not be_nil
|
27
|
+
transaction.date_received.should_not be_nil
|
28
|
+
transaction.error_code.should eql("")
|
29
|
+
#transaction.error_detail.should eql("")
|
30
|
+
#transaction.error_message.should eql("")
|
31
|
+
transaction.fees.should_not be_nil
|
32
|
+
transaction.fps_operation.should_not be_empty
|
33
|
+
transaction.recipient_name.should_not be_empty
|
34
|
+
transaction.sender_name.should_not be_empty
|
35
|
+
transaction.sender_token_id.should_not be_nil #some transactions have '' here.
|
36
|
+
transaction.status_code.should_not be_empty
|
37
|
+
transaction.transaction_amount.should_not be_nil
|
38
|
+
transaction.transaction_id.should_not be_empty
|
39
|
+
transaction.transaction_parts.should_not be_empty
|
40
|
+
end
|
35
41
|
end
|
36
42
|
end
|
@@ -5,33 +5,35 @@ describe 'a GetTokens call' do
|
|
5
5
|
|
6
6
|
before(:all) do
|
7
7
|
@response = remit.get_tokens
|
8
|
+
|
8
9
|
end
|
9
10
|
|
10
11
|
it 'should have a collection of tokens' do
|
11
|
-
@response.should have_at_least(1).tokens
|
12
|
+
@response.get_tokens_result.should have_at_least(1).tokens
|
12
13
|
end
|
13
14
|
|
14
15
|
it 'should have a token with all of its values set' do
|
15
|
-
token = @response.tokens.first
|
16
|
+
token = @response.get_tokens_result.tokens.first
|
16
17
|
token.token_id.should_not be_empty
|
17
18
|
token.friendly_name.should_not be_empty
|
18
|
-
token.
|
19
|
+
token.token_status.should_not be_empty
|
19
20
|
token.date_installed.should_not be_nil
|
20
|
-
token.caller_installed.should_not be_empty
|
21
|
+
#token.caller_installed.should_not be_empty
|
21
22
|
token.caller_reference.should_not be_empty
|
22
23
|
token.token_type.should_not be_empty
|
23
24
|
token.old_token_id.should_not be_empty
|
25
|
+
#token.payment_reason.should be_empty
|
24
26
|
end
|
25
27
|
|
26
28
|
it 'should have a token with a token ID' do
|
27
|
-
@response.tokens.first.token_id.should_not be_empty
|
29
|
+
@response.get_tokens_result.tokens.first.token_id.should_not be_empty
|
28
30
|
end
|
29
31
|
|
30
32
|
it 'should have a token with a valid token status' do
|
31
|
-
@response.tokens.first.
|
33
|
+
@response.get_tokens_result.tokens.first.token_status.should match(/^(IN)?ACTIVE$/i)
|
32
34
|
end
|
33
35
|
|
34
36
|
it 'should have a token with a valid installation date' do
|
35
|
-
@response.tokens.first.date_installed.should be_a_kind_of(Time)
|
37
|
+
@response.get_tokens_result.tokens.first.date_installed.should be_a_kind_of(Time)
|
36
38
|
end
|
37
39
|
end
|
@@ -5,4 +5,11 @@ unless ACCESS_KEY and SECRET_KEY
|
|
5
5
|
raise RuntimeError, "You must set your AWS_ACCESS_KEY and AWS_SECRET_KEY environment variables to run integration tests"
|
6
6
|
end
|
7
7
|
|
8
|
+
#def remit_api
|
9
|
+
# @remit ||= Remit::API.new(ACCESS_KEY, SECRET_KEY, true)
|
10
|
+
#end
|
11
|
+
|
12
|
+
#puts "Access key = #{ACCESS_KEY}"
|
13
|
+
#puts "Secret key = #{SECRET_KEY}"
|
14
|
+
|
8
15
|
require File.dirname(__FILE__) + '/../spec_helper'
|
@@ -1,32 +1,40 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/integrations_helper'
|
2
2
|
|
3
|
-
describe 'an IPN request' do
|
3
|
+
describe 'an IPN request with a bad signature' do
|
4
|
+
# This needs to be updated to match the new Verify methods
|
5
|
+
# The signature does not match the one calculated for these req params by amazon. Need to get a fresh example.
|
6
|
+
# So it is currently a test that a bad signature will be verified as BAD
|
4
7
|
before(:each) do
|
5
|
-
@
|
6
|
-
"
|
7
|
-
"
|
8
|
-
"
|
9
|
-
"
|
8
|
+
@bad_request_params = {
|
9
|
+
"action" => "notice",
|
10
|
+
"buyerName" => "Fps Buyer",
|
11
|
+
"callerReference" => "4-8-1-3.5",
|
12
|
+
"controller" => "amazon_fps/ipn",
|
13
|
+
"operation" => "PAY",
|
14
|
+
"paymentMethod" => "CC",
|
15
|
+
"recipientEmail" => "recipient@email.url",
|
16
|
+
"recipientName" => "Fps Business",
|
17
|
+
"signatureVersion" => Remit::API::SIGNATURE_VERSION.to_s,
|
10
18
|
"signatureMethod" => "RSA-SHA1",
|
11
|
-
"
|
12
|
-
|
13
|
-
"
|
14
|
-
"
|
15
|
-
"
|
16
|
-
|
17
|
-
+ "I5B+6PDrb8csuAWxW/mbUhk7AzazZMfQciJNjS5k+INlcvOOtQqoA/gVeBLsXK5jNsTh09cNa7pb" \
|
18
|
-
+ "gAvey+0DEjYnIRX+beJV6EMCPZxnXDGo0fA1PENLWXIHtAoIJAfLYEkVbT2lva2tZ0KBBWENnSjf" \
|
19
|
-
+ "26lMZVokypIo4huoGaZMp1IVkImFi3qC6ipCrw=="
|
19
|
+
"certificateUrl" => "https://fps.sandbox.amazonaws.com/certs/090909/PKICert.pem",
|
20
|
+
Remit::IpnRequest::SIGNATURE_KEY => "This-is-a-bad-sig",
|
21
|
+
"status" => "SUCCESS",
|
22
|
+
"transactionAmount" => "USD 3.50",
|
23
|
+
"transactionDate" => "1224687134",
|
24
|
+
"transactionId" => "13KIGL9RC25853BGPPOS2VSKBKF2JERR3HO"
|
20
25
|
}
|
21
|
-
|
26
|
+
|
27
|
+
@request = Remit::IpnRequest.new('http://example.com/ipn/processor', @bad_request_params, remit)
|
22
28
|
end
|
23
29
|
|
24
|
-
it 'should be a valid request' do
|
25
|
-
@request.
|
30
|
+
it 'should not be a valid request' do
|
31
|
+
@request.should_not be_valid
|
26
32
|
end
|
27
33
|
|
28
34
|
it 'should pass through access to given parameters' do
|
29
|
-
@request.status.should == '
|
30
|
-
@request.
|
35
|
+
@request.status.should == 'SUCCESS'
|
36
|
+
@request.operation.should == 'PAY'
|
37
|
+
@request.transactionId.should == '13KIGL9RC25853BGPPOS2VSKBKF2JERR3HO'
|
31
38
|
end
|
32
39
|
end
|
40
|
+
|