remit 0.0.6 → 2.0.1

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.
Files changed (102) hide show
  1. data/README.markdown +36 -5
  2. data/lib/remit.rb +35 -39
  3. data/lib/remit/common.rb +79 -24
  4. data/lib/remit/data_types.rb +118 -17
  5. data/lib/remit/get_pipeline.rb +160 -80
  6. data/lib/remit/inbound_request.rb +85 -0
  7. data/lib/remit/ipn_request.rb +4 -39
  8. data/lib/remit/operations/cancel.rb +20 -0
  9. data/lib/remit/operations/cancel_subscription_and_refund.rb +5 -1
  10. data/lib/remit/operations/cancel_token.rb +1 -0
  11. data/lib/remit/operations/fund_prepaid.rb +6 -4
  12. data/lib/remit/operations/get_account_activity.rb +5 -34
  13. data/lib/remit/operations/get_account_balance.rb +14 -11
  14. data/lib/remit/operations/get_all_credit_instruments.rb +2 -0
  15. data/lib/remit/operations/get_all_prepaid_instruments.rb +2 -0
  16. data/lib/remit/operations/get_debt_balance.rb +9 -4
  17. data/lib/remit/operations/get_outstanding_debt_balance.rb +8 -5
  18. data/lib/remit/operations/get_payment_instruction.rb +2 -0
  19. data/lib/remit/operations/get_prepaid_balance.rb +9 -5
  20. data/lib/remit/operations/get_recipient_verification_status.rb +25 -0
  21. data/lib/remit/operations/get_token_by_caller.rb +5 -1
  22. data/lib/remit/operations/get_token_usage.rb +5 -1
  23. data/lib/remit/operations/get_tokens.rb +5 -1
  24. data/lib/remit/operations/get_total_prepaid_liability.rb +9 -5
  25. data/lib/remit/operations/get_transaction.rb +1 -25
  26. data/lib/remit/operations/get_transaction_status.rb +28 -0
  27. data/lib/remit/operations/install_payment_instruction.rb +8 -1
  28. data/lib/remit/operations/pay.rb +5 -9
  29. data/lib/remit/operations/refund.rb +20 -11
  30. data/lib/remit/operations/reserve.rb +2 -4
  31. data/lib/remit/operations/settle.rb +2 -1
  32. data/lib/remit/operations/settle_debt.rb +2 -4
  33. data/lib/remit/operations/subscribe_for_caller_notification.rb +2 -0
  34. data/lib/remit/operations/unsubscribe_for_caller_notification.rb +2 -0
  35. data/lib/remit/operations/write_off_debt.rb +2 -4
  36. data/lib/remit/pipeline_response.rb +8 -41
  37. data/lib/remit/signature_utils_for_outbound.rb +74 -0
  38. data/lib/remit/verify_signature.rb +21 -0
  39. data/spec/integrations/get_account_activity_spec.rb +25 -19
  40. data/spec/integrations/get_tokens_spec.rb +9 -7
  41. data/spec/integrations/integrations_helper.rb +7 -0
  42. data/spec/integrations/ipn_request_spec.rb +28 -20
  43. data/spec/integrations/pipeline_response_spec.rb +27 -0
  44. data/spec/integrations/verify_signature_spec.rb +140 -0
  45. data/spec/mocks/CancelResponse.xml +13 -0
  46. data/spec/mocks/CancelSubscriptionAndRefundResponse.xml +10 -0
  47. data/spec/mocks/CancelTokenResponse.xml +6 -0
  48. data/spec/mocks/ErrorResponse.xml +15 -0
  49. data/spec/mocks/FundPrepaidResponse.xml +11 -0
  50. data/spec/mocks/GetAccountActivityResponse.xml +68 -0
  51. data/spec/mocks/GetAccountBalanceResponse.xml +34 -0
  52. data/spec/mocks/GetDebtBalanceResponse.xml +21 -0
  53. data/spec/mocks/GetOutstandingDebtBalanceResponse.xml +21 -0
  54. data/spec/mocks/GetPaymentInstructionResponse.xml +25 -0
  55. data/spec/mocks/GetPrepaidBalanceResponse.xml +21 -0
  56. data/spec/mocks/GetRecipientVerificationStatusResponse.xml +9 -0
  57. data/spec/mocks/GetTokenByCallerResponse.xml +22 -0
  58. data/spec/mocks/GetTokenUsageResponse.xml +28 -0
  59. data/spec/mocks/GetTokensResponse.xml +22 -0
  60. data/spec/mocks/GetTotalPrepaidLiabilityResponse.xml +21 -0
  61. data/spec/mocks/GetTransactionResponse.xml +76 -0
  62. data/spec/mocks/GetTransactionStatusResponse.xml +16 -0
  63. data/spec/mocks/InstallPaymentInstructionResponse.xml +10 -0
  64. data/spec/mocks/PayResponse.xml +11 -0
  65. data/spec/mocks/RefundResponse.xml +11 -0
  66. data/spec/mocks/ReserveResponse.xml +11 -0
  67. data/spec/mocks/SettleDebtResponse.xml +11 -0
  68. data/spec/mocks/SettleResponse.xml +11 -0
  69. data/spec/mocks/VerifySignatureResponse.xml +11 -0
  70. data/spec/mocks/WriteOffDebtResponse.xml +11 -0
  71. data/spec/mocks/errors/InvalidParameterValue.xml +10 -0
  72. data/spec/mocks/errors/InvalidParams_certificateUrl.xml +2 -0
  73. data/spec/mocks/errors/RequestExpired.xml +10 -0
  74. data/spec/spec_helper.rb +59 -10
  75. data/spec/units/cancel_subscription_and_refund_spec.rb +29 -0
  76. data/spec/units/cancel_token_spec.rb +24 -0
  77. data/spec/units/fund_prepaid_spec.rb +28 -0
  78. data/spec/units/get_account_activity_spec.rb +58 -0
  79. data/spec/units/get_account_balance_spec.rb +28 -0
  80. data/spec/units/get_debt_balance_spec.rb +29 -0
  81. data/spec/units/get_outstanding_debt_balance_spec.rb +29 -0
  82. data/spec/units/get_pipeline_spec.rb +16 -0
  83. data/spec/units/get_prepaid_balance_spec.rb +29 -0
  84. data/spec/units/get_recipient_verification_status_spec.rb +26 -0
  85. data/spec/units/get_token_by_caller_spec.rb +56 -0
  86. data/spec/units/get_token_usage_spec.rb +51 -0
  87. data/spec/units/get_tokens_spec.rb +56 -0
  88. data/spec/units/get_total_prepaid_liability_spec.rb +26 -0
  89. data/spec/units/get_transaction_spec.rb +103 -0
  90. data/spec/units/get_transaction_status_spec.rb +44 -0
  91. data/spec/units/pay_spec.rb +36 -57
  92. data/spec/units/refund_spec.rb +41 -0
  93. data/spec/units/reserve_spec.rb +41 -0
  94. data/spec/units/settle_debt_spec.rb +41 -0
  95. data/spec/units/settle_spec.rb +41 -0
  96. data/spec/units/units_helper.rb +23 -2
  97. data/spec/units/write_off_debt_spec.rb +41 -0
  98. metadata +116 -12
  99. data/lib/remit/operations/discard_results.rb +0 -18
  100. data/lib/remit/operations/get_results.rb +0 -27
  101. data/lib/remit/operations/retry_transaction.rb +0 -18
  102. 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).to_s}.#{convert_key(parameter).to_s}"
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
- parameter :transaction_response, :namespace => 'ns3', :type => TransactionResponse
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 :transaction_response, :type => TransactionResponse
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 :transaction_response, :type => TransactionResponse
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 :transaction_response, :type => TransactionResponse
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)
@@ -1,5 +1,7 @@
1
1
  require 'remit/common'
2
2
 
3
+ # This action seems to have been deprecated
4
+
3
5
  module Remit
4
6
  module SubscribeForCallerNotification
5
7
  class Request < Remit::Request
@@ -1,5 +1,7 @@
1
1
  require 'remit/common'
2
2
 
3
+ # This action seems to have been deprecated
4
+
3
5
  module Remit
4
6
  module UnsubscribeForCallerNotification
5
7
  class Request < Remit::Request
@@ -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 :transaction_response, :type => TransactionResponse
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
- # Returns +true+ if the response returns a successful state.
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?(request_query[:status])
30
- end
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 have_at_least(1).transactions
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
- transaction.caller_name.should_not be_empty
19
- transaction.caller_token_id.should_not be_empty
20
- transaction.caller_transaction_date.should_not be_nil
21
- transaction.date_completed.should_not be_nil
22
- transaction.date_received.should_not be_nil
23
- transaction.error_code.should be_empty
24
- transaction.error_detail.should be_empty
25
- transaction.error_message.should be_empty
26
- transaction.fees.should_not be_nil
27
- transaction.operation.should_not be_empty
28
- transaction.recipient_name.should_not be_empty
29
- transaction.sender_name.should_not be_empty
30
- transaction.sender_token_id.should_not be_empty
31
- transaction.status.should_not be_empty
32
- transaction.transaction_amount.should_not be_nil
33
- transaction.transaction_id.should_not be_empty
34
- transaction.transaction_parts.should_not be_empty
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.status.should_not be_empty
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.status.should match(/^(IN)?ACTIVE$/i)
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
- @request_params = {
6
- "expiry" => "10/2013",
7
- "tokenID" => "Q5IG5ETFCEBU8KBLTI4JHINQVL6VAJVHICBRR49AKLPIEZH1KB1S8C7VHAJJMLJ3",
8
- "status" => "SC",
9
- "callerReference" => "1253247023946cMcrTRrjtLjNrZGNKchWfDtUEIGuJfiOBAAJYPjbytBV",
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
- "signatureVersion" => "2",
12
- "certificateUrl" => "https://fps.amazonaws.com/certs/090909/PKICert.pem",
13
- "controller" => "amazon_fps", # controller and action get deleted
14
- "action" => "index",
15
- "signature" => "H4NTAsp3YwAEiyQ86j5B53lksv2hwwEaEFxtdWFpy9xX764AZy/Dm0RLEykUUyPVLgqCOlMopay5" \
16
- + "Qxr/VDwhdYAzgQzA8VCV8x9Mn0caKsJT2HCU6tSLNa6bLwzg/ildCm2lHDho1Xt2yaBHMt+/Cn4q" \
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
- @request = Remit::IpnRequest.new(@request_params, 'http://www.mysite.com/call_pay.jsp', ACCESS_KEY, SECRET_KEY)
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.should be_valid
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 == 'SC'
30
- @request.callerReference.should == '1253247023946cMcrTRrjtLjNrZGNKchWfDtUEIGuJfiOBAAJYPjbytBV'
35
+ @request.status.should == 'SUCCESS'
36
+ @request.operation.should == 'PAY'
37
+ @request.transactionId.should == '13KIGL9RC25853BGPPOS2VSKBKF2JERR3HO'
31
38
  end
32
39
  end
40
+