remit 0.0.6 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,20 @@
1
+ require 'remit/common'
2
+
3
+ module Remit
4
+ module Cancel
5
+ class Request < Remit::Request
6
+ action :Cancel
7
+ parameter :transaction_id, :required => true
8
+ parameter :description
9
+ end
10
+
11
+ class Response < Remit::Response
12
+ parser :rexml
13
+ parameter :cancel_response, :type => Remit::TransactionResponse
14
+ end
15
+
16
+ def cancel(request = Request.new)
17
+ call(request, Response)
18
+ end
19
+ end
20
+ end
@@ -12,7 +12,11 @@ module Remit
12
12
  end
13
13
 
14
14
  class Response < Remit::Response
15
- parameter :refund_transaction_id
15
+ class CancelSubscriptionAndRefundResult < Remit::BaseResponse
16
+ parameter :refund_transaction_id
17
+ end
18
+ parameter :cancel_subscription_and_refund_result, :type=>CancelSubscriptionAndRefundResult
19
+ parameter :response_metadata, :type=>ResponseMetadata
16
20
  end
17
21
 
18
22
  def cancel_subscription_and_refund(request = Request.new)
@@ -9,6 +9,7 @@ module Remit
9
9
  end
10
10
 
11
11
  class Response < Remit::Response
12
+ parameter :response_metadata, :type=>ResponseMetadata
12
13
  end
13
14
 
14
15
  def cancel_token(request = Request.new)
@@ -7,12 +7,9 @@ module Remit
7
7
  parameter :transaction_ids
8
8
  parameter :caller_description
9
9
  parameter :caller_reference, :required => true
10
- parameter :caller_token_id, :required => true
11
10
  parameter :charge_fee_to, :required => true
12
11
  parameter :funding_amount, :type => Remit::RequestTypes::Amount, :required => true
13
- parameter :meta_data
14
12
  parameter :prepaid_instrument_id, :required => true
15
- parameter :recipient_description
16
13
  parameter :recipient_reference
17
14
  parameter :sender_description
18
15
  parameter :sender_reference
@@ -21,7 +18,12 @@ module Remit
21
18
  end
22
19
 
23
20
  class Response < Remit::Response
24
- parameter :transaction_response, :type => TransactionResponse
21
+ class FundPrepaidResult < Remit::BaseResponse
22
+ parameter :transaction_id
23
+ parameter :transaction_status
24
+ end
25
+ parameter :fund_prepaid_result, :type => FundPrepaidResult
26
+ parameter :response_metadata, :type=>ResponseMetadata
25
27
  end
26
28
 
27
29
  def fund_prepaid(request = Request.new)
@@ -16,41 +16,12 @@ module Remit
16
16
  end
17
17
 
18
18
  class Response < Remit::Response
19
- class Transaction < Remit::BaseResponse
20
- class TransactionPart < Remit::BaseResponse
21
- parameter :account_id
22
- parameter :role
23
- parameter :name
24
- parameter :reference
25
- parameter :description
26
- parameter :fee_paid, :type => Amount
27
- end
28
-
29
- parameter :caller_name
30
- parameter :caller_token_id
31
- parameter :caller_transaction_date, :type => :time
32
- parameter :date_completed, :type => :time
33
- parameter :date_received, :type => :time
34
- parameter :error_code
35
- parameter :error_detail
36
- parameter :error_message
37
- parameter :fees, :type => Amount
38
- parameter :meta_data
39
- parameter :operation
40
- parameter :original_transaction_id
41
- parameter :payment_method
42
- parameter :recipient_name
43
- parameter :sender_name
44
- parameter :sender_token_id
45
- parameter :status
46
- parameter :transaction_amount, :type => Amount
47
- parameter :transaction_id
48
- parameter :transaction_parts, :collection => TransactionPart
19
+ class GetAccountActivityResult < Remit::BaseResponse
20
+ parameter :batch_size
21
+ parameter :transactions, :collection => Transaction, :element=>"Transaction"
22
+ parameter :start_time_for_next_transaction, :type => :time
49
23
  end
50
-
51
- parameter :response_batch_size
52
- parameter :transactions, :collection => Transaction
53
- parameter :start_time_for_next_transaction, :type => :time
24
+ parameter :get_account_activity_result, :type => GetAccountActivityResult
54
25
  end
55
26
 
56
27
  def get_account_activity(request = Request.new)
@@ -7,19 +7,22 @@ module Remit
7
7
  end
8
8
 
9
9
  class Response < Remit::Response
10
- class AccountBalance < Remit::BaseResponse
11
- class AvailableBalances < Remit::BaseResponse
12
- parameter :disburse_balance, :type => Amount
13
- parameter :refund_balance, :type => Amount
10
+ class GetAccountBalanceResult < Remit::BaseResponse
11
+ class AccountBalance < Remit::BaseResponse
12
+ class AvailableBalances < Remit::BaseResponse
13
+ parameter :disburse_balance, :type => Amount
14
+ parameter :refund_balance, :type => Amount
15
+ end
16
+
17
+ parameter :total_balance, :type => Amount
18
+ parameter :pending_in_balance, :type => Amount
19
+ parameter :pending_out_balance, :type => Amount
20
+ parameter :available_balances, :type => AvailableBalances
14
21
  end
15
-
16
- parameter :total_balance, :type => Amount
17
- parameter :pending_in_balance, :type => Amount
18
- parameter :pending_out_balance, :type => Amount
19
- parameter :available_balances, :type => AvailableBalances
22
+ parameter :account_balance, :type=>AccountBalance
20
23
  end
21
-
22
- parameter :account_balance, :type => AccountBalance
24
+ parameter :get_account_balance_result, :type => GetAccountBalanceResult
25
+ parameter :response_metadata, :type=>ResponseMetadata
23
26
  end
24
27
 
25
28
  def get_account_balance(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 GetAllCreditInstruments
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 GetAllPrepaidInstruments
5
7
  class Request < Remit::Request
@@ -8,12 +8,17 @@ module Remit
8
8
  end
9
9
 
10
10
  class Response < Remit::Response
11
- class DebtBalance < Remit::BaseResponse
12
- parameter :available_balance, :type => Amount
13
- parameter :pending_out_balance, :type => Amount
11
+ class GetDebtBalanceResult < Remit::BaseResponse
12
+ class DebtBalance < Remit::BaseResponse
13
+ parameter :available_balance, :type => Amount
14
+ parameter :pending_out_balance, :type => Amount
15
+ end
16
+ parameter :debt_balance, :type => DebtBalance
14
17
  end
15
18
 
16
- parameter :debt_balance, :type => DebtBalance
19
+ parameter :get_debt_balance_result, :type => GetDebtBalanceResult
20
+ parameter :response_metadata, :type=>ResponseMetadata
21
+
17
22
  end
18
23
 
19
24
  def get_debt_balance(request = Request.new)
@@ -7,12 +7,15 @@ module Remit
7
7
  end
8
8
 
9
9
  class Response < Remit::Response
10
- class OutstandingDebtBalance < Remit::BaseResponse
11
- parameter :outstanding_balance, :type => Amount
12
- parameter :pending_out_balance, :type => Amount
10
+ class GetOutstandingDebtBalanceResult < Remit::BaseResponse
11
+ class OutstandingDebtBalance < Remit::BaseResponse
12
+ parameter :outstanding_balance, :type => Amount
13
+ parameter :pending_out_balance, :type => Amount
14
+ end
15
+ parameter :outstanding_debt, :type => OutstandingDebtBalance
13
16
  end
14
-
15
- parameter :outstanding_debt, :type => OutstandingDebtBalance
17
+ parameter :get_outstanding_debt_balance_result, :type => GetOutstandingDebtBalanceResult
18
+ parameter :response_metadata, :type=>ResponseMetadata
16
19
  end
17
20
 
18
21
  def get_outstanding_debt_balance(request = Request.new)
@@ -1,5 +1,7 @@
1
1
  require 'remit/common'
2
2
 
3
+ #This actions seems to have been deprecated
4
+
3
5
  module Remit
4
6
  module GetPaymentInstruction
5
7
  class Request < Remit::Request
@@ -8,12 +8,16 @@ module Remit
8
8
  end
9
9
 
10
10
  class Response < Remit::Response
11
- class PrepaidBalance < Remit::BaseResponse
12
- parameter :available_balance, :type => Amount
13
- parameter :pending_in_balance, :type => Amount
11
+ class GetPrepaidBalanceResult < Remit::BaseResponse
12
+ class PrepaidBalance < Remit::BaseResponse
13
+ parameter :available_balance, :type => Amount
14
+ parameter :pending_in_balance, :type => Amount
15
+ end
16
+
17
+ parameter :prepaid_balance, :type => PrepaidBalance
14
18
  end
15
-
16
- parameter :prepaid_balance, :type => PrepaidBalance
19
+ parameter :get_prepaid_balance_result, :type=>GetPrepaidBalanceResult
20
+ parameter :response_metadata, :type=>ResponseMetadata
17
21
  end
18
22
 
19
23
  def get_prepaid_balance(request = Request.new)
@@ -0,0 +1,25 @@
1
+ require 'remit/common'
2
+
3
+ module Remit
4
+ module GetRecipientVerificationStatus
5
+ class Request < Remit::Request
6
+ action :GetRecipientVerificationStatus
7
+ parameter :recipient_token_id, :required => true
8
+ end
9
+
10
+ class Response < Remit::Response
11
+ parser :rexml
12
+ class GetRecipientVerificationStatusResult < Remit::BaseResponse
13
+ parameter :recipient_verification_status
14
+ end
15
+
16
+ parameter :get_recipient_verification_status_result, :type => GetRecipientVerificationStatusResult
17
+ parameter :response_metadata, :type=>ResponseMetadata
18
+
19
+ end
20
+
21
+ def get_recipient_verification_status(request = Request.new)
22
+ call(request, Response)
23
+ end
24
+ end
25
+ end
@@ -9,7 +9,11 @@ module Remit
9
9
  end
10
10
 
11
11
  class Response < Remit::Response
12
- parameter :token, :type => Token
12
+ class GetTokenByCallerResult < Remit::BaseResponse
13
+ parameter :token, :type => Token
14
+ end
15
+ parameter :get_token_by_caller_result, :type=>GetTokenByCallerResult
16
+ parameter :response_metadata, :type=>ResponseMetadata
13
17
  end
14
18
 
15
19
  def get_token_by_caller(request = Request.new)
@@ -8,7 +8,11 @@ module Remit
8
8
  end
9
9
 
10
10
  class Response < Remit::Response
11
- parameter :token_usage_limits, :type => TokenUsageLimit
11
+ class GetTokenUsageResult < Remit::BaseResponse
12
+ parameter :token_usage_limits, :type => TokenUsageLimit
13
+ end
14
+ parameter :get_token_usage_result, :type=>GetTokenUsageResult
15
+ parameter :response_metadata, :type=>ResponseMetadata
12
16
  end
13
17
 
14
18
  def get_token_usage(request = Request.new)
@@ -10,7 +10,11 @@ module Remit
10
10
  end
11
11
 
12
12
  class Response < Remit::Response
13
- parameter :tokens, :collection => Token
13
+ class GetTokensResult < Remit::BaseResponse
14
+ parameter :tokens, :element => 'Token', :collection => Remit::Token
15
+ end
16
+ parameter :get_tokens_result, :type=>GetTokensResult
17
+ parameter :response_metadata, :type=>ResponseMetadata
14
18
  end
15
19
 
16
20
  def get_tokens(request = Request.new)
@@ -7,12 +7,16 @@ module Remit
7
7
  end
8
8
 
9
9
  class Response < Remit::Response
10
- class OutstandingPrepaidLiability < Remit::BaseResponse
11
- parameter :outstanding_balance, :type => Amount
12
- parameter :panding_in_balance, :type => Amount
10
+ class GetTotalPrepaidLiabilityResult < Remit::BaseResponse
11
+ class OutstandingPrepaidLiability < Remit::BaseResponse
12
+ parameter :outstanding_balance, :type => Amount
13
+ parameter :panding_in_balance, :type => Amount
14
+ end
15
+
16
+ parameter :outstanding_prepaid_liability, :type => OutstandingPrepaidLiability
13
17
  end
14
-
15
- parameter :outstanding_prepaid_liability, :type => OutstandingPrepaidLiability
18
+ parameter :get_total_prepaid_liability_result, :type=>GetTotalPrepaidLiabilityResult
19
+ parameter :response_metadata, :type=>ResponseMetadata
16
20
  end
17
21
 
18
22
  def get_total_prepaid_liability(request = Request.new)
@@ -8,31 +8,7 @@ module Remit
8
8
  end
9
9
 
10
10
  class Response < Remit::Response
11
- class TransactionDetail < Remit::BaseResponse
12
- parameter :caller_name
13
- parameter :caller_token_id
14
- parameter :caller_transaction_date, :type => :time
15
- parameter :date_completed, :type => :time
16
- parameter :date_received, :type => :time
17
- parameter :error_code
18
- parameter :error_message
19
- parameter :fees, :type => Amount
20
- parameter :meta_data
21
- parameter :operation
22
- parameter :payment_method
23
- parameter :recipient_name
24
- parameter :recipient_token_id
25
- parameter :related_transactions
26
- parameter :sender_name
27
- parameter :sender_token_id
28
- parameter :status
29
- parameter :status_history
30
- parameter :transaction_amount, :type => Amount
31
- parameter :transaction_id
32
- parameter :transaction_parts
33
- end
34
-
35
- parameter :transaction, :type => TransactionDetail
11
+ parameter :transaction, :type => Transaction, :element=>"GetTransactionResult/Transaction"
36
12
  end
37
13
 
38
14
  def get_transaction(request = Request.new)
@@ -0,0 +1,28 @@
1
+ require 'remit/common'
2
+
3
+ module Remit
4
+ module GetTransactionStatus
5
+ class Request < Remit::Request
6
+ action :GetTransaction
7
+ parameter :transaction_id, :required => true
8
+ end
9
+
10
+ class Response < Remit::Response
11
+ class GetTransactionStatusResult < Remit::BaseResponse
12
+
13
+ parameter :caller_reference
14
+ parameter :status_code
15
+ parameter :status_message
16
+ parameter :transaction_id
17
+ parameter :transaction_status
18
+
19
+ end
20
+
21
+ parameter :get_transaction_status_result, :type => GetTransactionStatusResult, :element=>"GetTransactionStatusResult"
22
+ end
23
+
24
+ def get_transaction(request = Request.new)
25
+ call(request, Response)
26
+ end
27
+ end
28
+ end
@@ -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 InstallPaymentInstruction
5
7
  class Request < Remit::Request
@@ -12,7 +14,12 @@ module Remit
12
14
  end
13
15
 
14
16
  class Response < Remit::Response
15
- parameter :token_id
17
+ class InstallPaymentInstructionResult < Remit::BaseResponse
18
+ parameter :token_id
19
+ end
20
+
21
+ parameter :install_payment_instruction_result, :type =>InstallPaymentInstructionResult
22
+ alias :result :install_payment_instruction_result
16
23
  end
17
24
 
18
25
  def install_payment_instruction(request)
@@ -6,26 +6,22 @@ module Remit
6
6
  action :Pay
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 :descriptor_policy, :type => Remit::RequestTypes::DescriptorPolicy
12
11
  parameter :marketplace_fixed_fee, :type => Remit::RequestTypes::Amount
13
12
  parameter :marketplace_variable_fee
14
- parameter :meta_data
15
- parameter :recipient_description
16
- parameter :recipient_reference
17
- parameter :recipient_token_id, :required => true
13
+ parameter :recipient_token_id #, Only required for MarketPlace transactions
18
14
  parameter :sender_description
19
- parameter :sender_reference
20
15
  parameter :sender_token_id, :required => true
21
- parameter :temporary_decline_policy, :type => Remit::RequestTypes::TemporaryDeclinePolicy
22
16
  parameter :transaction_amount, :type => Remit::RequestTypes::Amount, :required => true
23
- parameter :transaction_date
17
+ parameter :transaction_timeout_in_mins
18
+ parameter :timestamp
24
19
  end
25
20
 
21
+ # The response is odd, when it succeeds. --JonMoses
26
22
  class Response < Remit::Response
27
23
  parser :rexml
28
- parameter :transaction_response, :namespace => 'ns3', :type => TransactionResponse
24
+ parameter :pay_result, :type => Remit::TransactionResponse
29
25
  end
30
26
 
31
27
  def pay(request = Request.new)