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
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/units_helper'
2
+
3
+ describe "the GetTotalPrepaidLiability API" do
4
+ describe "a successful response" do
5
+ it_should_behave_like 'a successful response'
6
+
7
+ before do
8
+ doc = File.read("spec/mocks/GetTotalPrepaidLiabilityResponse.xml")
9
+
10
+ @response = Remit::GetTotalPrepaidLiability::Response.new(doc)
11
+ end
12
+
13
+ it "has metadata" do
14
+ @response.response_metadata.should_not be_nil
15
+ end
16
+
17
+ it "has results" do
18
+ @response.get_total_prepaid_liability_result.should be_a_kind_of Remit::GetTotalPrepaidLiability::Response::GetTotalPrepaidLiabilityResult
19
+ end
20
+
21
+ it "has outstanding prepaid liability" do
22
+ @response.get_total_prepaid_liability_result.outstanding_prepaid_liability.should be_a_kind_of Remit::GetTotalPrepaidLiability::Response::GetTotalPrepaidLiabilityResult::OutstandingPrepaidLiability
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,103 @@
1
+ require File.dirname(__FILE__) + '/units_helper'
2
+
3
+ describe "the GetTransaction API" do
4
+ describe "a successful response" do
5
+ it_should_behave_like 'a successful response'
6
+
7
+ before(:all) do
8
+ doc = File.read("spec/mocks/GetTransactionResponse.xml")
9
+
10
+ @response = Remit::GetTransaction::Response.new(doc)
11
+ end
12
+
13
+ it "has one transaction" do
14
+ @response.transaction.should_not be_nil
15
+ end
16
+
17
+ describe "the result" do
18
+ before(:all) do
19
+ @transaction = @response.transaction
20
+ end
21
+
22
+ it "should have a transaction_id" do
23
+ @transaction.transaction_id.should_not be_nil
24
+ end
25
+
26
+ it "should have caller_reference" do
27
+ @transaction.caller_reference.should_not be_nil
28
+ end
29
+
30
+ it "should have caller_description" do
31
+ @transaction.caller_description.should_not be_nil
32
+ end
33
+
34
+ it "should have date_received" do
35
+ @transaction.date_received.should_not be_nil
36
+ end
37
+
38
+ it "should have date_completed" do
39
+ @transaction.date_completed.should_not be_nil
40
+ end
41
+
42
+ it "should have transaction_amount" do
43
+ @transaction.transaction_amount.should_not be_nil
44
+ end
45
+
46
+ it "should have transaction_amount.value" do
47
+ @transaction.transaction_amount.value.should == 0
48
+ end
49
+
50
+ it "should have fps_fess_paid_by" do
51
+ @transaction.fps_fees_paid_by.should_not be_nil
52
+ end
53
+
54
+ it "should have sender_token_id" do
55
+ @transaction.sender_token_id.strip.should_not be_nil
56
+ end
57
+
58
+ it "should have fps_operation" do
59
+ @transaction.fps_operation.should_not be_nil
60
+ end
61
+
62
+ it "should have payment_method" do
63
+ @transaction.payment_method.should_not be_nil
64
+ end
65
+
66
+ it "should have transaction_status" do
67
+ @transaction.transaction_status.should_not be_nil
68
+ end
69
+
70
+ it "should have status_code" do
71
+ @transaction.status_code.should_not be_nil
72
+ end
73
+
74
+ it "should have status_message" do
75
+ @transaction.status_message.should_not be_nil
76
+ end
77
+
78
+ it "should have sender name" do
79
+ @transaction.sender_name.should_not be_nil
80
+ end
81
+
82
+ it "should have sender email" do
83
+ @transaction.sender_email.should_not be_nil
84
+ end
85
+
86
+ it "should have caller name" do
87
+ @transaction.caller_name.should_not be_nil
88
+ end
89
+
90
+ it "should have recipient name" do
91
+ @transaction.recipient_name.should_not be_nil
92
+ end
93
+
94
+ it "should have recipient email" do
95
+ @transaction.recipient_email.should_not be_nil
96
+ end
97
+
98
+ it "reports the transaction's new status" do
99
+ @transaction.transaction_status.should_not be_nil
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/units_helper'
2
+
3
+ describe "the GetTransaction API" do
4
+ describe "a successful response" do
5
+ it_should_behave_like 'a successful response'
6
+
7
+ before do
8
+ doc = File.read("spec/mocks/GetTransactionStatusResponse.xml")
9
+
10
+ @response = Remit::GetTransactionStatus::Response.new(doc)
11
+ end
12
+
13
+ it "has one transaction" do
14
+ @response.get_transaction_status_result.should_not be_nil
15
+ end
16
+
17
+ describe "the result" do
18
+ before do
19
+ @transaction = @response.get_transaction_status_result
20
+ end
21
+
22
+ it "should have a transaction_id" do
23
+ @transaction.transaction_id.should_not be_nil
24
+ end
25
+
26
+
27
+ it "should have transaction_status" do
28
+ @transaction.transaction_status.should_not be_nil
29
+ end
30
+
31
+ it "should have status_code" do
32
+ @transaction.status_code.should_not be_nil
33
+ end
34
+
35
+ it "should have status_message" do
36
+ @transaction.status_message.should_not be_nil
37
+ end
38
+
39
+ it "reports the transaction's new status" do
40
+ @transaction.transaction_status.should_not be_nil
41
+ end
42
+ end
43
+ end
44
+ end
@@ -6,100 +6,79 @@ describe "the Pay API" do
6
6
 
7
7
  before do
8
8
  doc = <<-XML
9
- <ns3:PayResponse xmlns:ns3="http://fps.amazonaws.com/doc/2007-01-08/">
10
- <ns3:TransactionResponse>
9
+ <PayResponse xmlns="http://fps.amazonaws.com/doc/2008-09-17/">
10
+ <PayResult>
11
11
  <TransactionId>abc123</TransactionId>
12
- <Status>Initiated</Status>
13
- </ns3:TransactionResponse>
14
- <Status>Success</Status>
15
- <RequestId>foo</RequestId>
16
- </ns3:PayResponse>
12
+ <TransactionStatus>Success</TransactionStatus>
13
+ </PayResult>
14
+ <ResponseMetadata>
15
+ <RequestId>foo-bar</RequestId>
16
+ </ResponseMetadata>
17
+ </PayResponse>
17
18
  XML
18
19
 
19
20
  @response = Remit::Pay::Response.new(doc)
20
21
  end
21
22
 
22
23
  it "has a transaction response" do
23
- @response.transaction_response.should_not be_nil
24
+ @response.pay_result.should_not be_nil
24
25
  end
25
26
 
26
27
  it "has a transaction id" do
27
- @response.transaction_response.transaction_id.should == 'abc123'
28
+ @response.pay_result.transaction_id.should == 'abc123'
28
29
  end
29
30
 
30
31
  it "has a transaction status" do
31
- @response.transaction_response.status.should == 'Initiated'
32
+ @response.pay_result.transaction_status.should == 'Success'
32
33
  end
33
34
 
34
- it "has status shortcuts" do
35
- @response.transaction_response.should be_initiated
36
- end
35
+ #it "has status shortcuts" do
36
+ # @response.pay_result.should be_initiated
37
+ #end
37
38
  end
38
39
 
39
- describe "for a failed request" do
40
+ describe "for a pending request" do
40
41
  before do
41
42
  doc = <<-XML
42
- <?xml version=\"1.0\"?>
43
- <ns3:PayResponse xmlns:ns3=\"http://fps.amazonaws.com/doc/2007-01-08/\">
44
- <Status>Failure</Status>
45
- <Errors>
46
- <Errors>
47
- <ErrorType>Business</ErrorType>
48
- <IsRetriable>false</IsRetriable>
49
- <ErrorCode>InvalidParams</ErrorCode>
50
- <ReasonText>callerTokenId can not be empty</ReasonText>
51
- </Errors>
52
- </Errors>
53
- <RequestId>7966a2d9-5ce9-4902-aefc-b01d254c931a:0</RequestId>
54
- </ns3:PayResponse>
43
+ <PayResponse xmlns="http://fps.amazonaws.com/doc/2008-09-17/">
44
+ <PayResult>
45
+ <TransactionId>14GK6BGKA7U6OU6SUTNLBI5SBBV9PGDJ6UL</TransactionId>
46
+ <TransactionStatus>Pending</TransactionStatus>
47
+ </PayResult>
48
+ <ResponseMetadata>
49
+ <RequestId>c21e7735-9c08-4cd8-99bf-535a848c79b4:0</RequestId>
50
+ </ResponseMetadata>
51
+ </PayResponse>
55
52
  XML
56
53
 
57
54
  @response = Remit::Pay::Response.new(doc)
58
55
  @error = @response.errors.first
59
56
  end
60
57
 
61
- it_should_behave_like 'a failed response'
58
+ it_should_behave_like 'a pending response'
62
59
 
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
60
  end
85
61
 
86
62
  describe "for a failed request" do
87
63
  before do
88
64
  doc = <<-XML
89
- <?xml version=\"1.0\"?>
90
- <ns3:PayResponse xmlns:ns3=\"http://fps.amazonaws.com/doc/2007-01-08/\">
91
- <Status>Failure</Status>
65
+ <PayResponse xmlns="http://fps.amazonaws.com/doc/2008-09-17/">
66
+ <PayResult>
67
+ <TransactionId>14GK6BGKA7U6OU6SUTNLBI5SBBV9PGDJ6UL</TransactionId>
68
+ <TransactionStatus>Pending</TransactionStatus>
69
+ </PayResult>
70
+ <ResponseMetadata>
71
+ <RequestId>c21e7735-9c08-4cd8-99bf-535a848c79b4:0</RequestId>
72
+ </ResponseMetadata>
92
73
  <Errors>
93
74
  <Errors>
94
75
  <ErrorType>Business</ErrorType>
95
76
  <IsRetriable>false</IsRetriable>
96
77
  <ErrorCode>TokenUsageError</ErrorCode>
97
- <ReasonText>The token \"45XU7TLBN995ZQA2U1PS1ZCTJXJMJ3H1GH6VZAB82C1BGLK9X3AXUQDA3QDLJVPX\" has violated its usage policy.</ReasonText>
98
- </Errors>
78
+ <ReasonText>The token "45XU7TLBN995ZQA2U1PS1ZCTJXJMJ3H1GH6VZAB82C1BGLK9X3AXUQDA3QDLJVPX" has violated its usage policy.</ReasonText>
99
79
  </Errors>
100
- <RequestId>78acff80-b740-4b57-9301-18d0576e6855:0
101
- </RequestId>
102
- </ns3:PayResponse>
80
+ </Errors>
81
+ </PayResponse>
103
82
  XML
104
83
 
105
84
  @response = Remit::Pay::Response.new(doc)
@@ -0,0 +1,41 @@
1
+ require File.dirname(__FILE__) + '/units_helper'
2
+
3
+ describe "the Refund API" do
4
+ describe "a successful response" do
5
+ it_should_behave_like 'a successful response'
6
+
7
+ before do
8
+ doc = <<-XML
9
+ <RefundResponse xmlns="http://fps.amazonaws.com/doc/2008-09-17/">
10
+ <RefundResult>
11
+ <TransactionId>14GK6F2QU755ODS27SGHEURLKPG72Z54KMF</TransactionId>
12
+ <TransactionStatus>Pending</TransactionStatus>
13
+ </RefundResult>
14
+ <ResponseMetadata>
15
+ <RequestId>1a146b9a-b37b-4f5f-bda6-012a5b9e45c3:0</RequestId>
16
+ </ResponseMetadata>
17
+ </RefundResponse>
18
+ XML
19
+
20
+ @response = Remit::Refund::Response.new(doc)
21
+ end
22
+
23
+ it "has metadata" do
24
+ @response.response_metadata.should_not be_nil
25
+ end
26
+
27
+ it "has results" do
28
+ @response.refund_result.should_not be_nil
29
+ end
30
+
31
+
32
+ it "has a transaction id" do
33
+ @response.refund_result.transaction_id.should_not be_nil
34
+ end
35
+
36
+ it "has a transaction status" do
37
+ @response.refund_result.transaction_status.should_not be_nil
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ require File.dirname(__FILE__) + '/units_helper'
2
+
3
+ describe "the Reserve API" do
4
+ describe "a successful response" do
5
+ it_should_behave_like 'a successful response'
6
+
7
+ before do
8
+ doc = <<-XML
9
+ <ReserveResponse xmlns="http://fps.amazonaws.com/doc/2008-09-17/">
10
+ <ReserveResult>
11
+ <TransactionId>14GK6F2QU755ODS27SGHEURLKPG72Z54KMF</TransactionId>
12
+ <TransactionStatus>Pending</TransactionStatus>
13
+ </ReserveResult>
14
+ <ResponseMetadata>
15
+ <RequestId>1a146b9a-b37b-4f5f-bda6-012a5b9e45c3:0</RequestId>
16
+ </ResponseMetadata>
17
+ </ReserveResponse>
18
+ XML
19
+
20
+ @response = Remit::Reserve::Response.new(doc)
21
+ end
22
+
23
+ it "has metadata" do
24
+ @response.response_metadata.should_not be_nil
25
+ end
26
+
27
+ it "has results" do
28
+ @response.reserve_result.should_not be_nil
29
+ end
30
+
31
+
32
+ it "has a transaction id" do
33
+ @response.reserve_result.transaction_id.should_not be_nil
34
+ end
35
+
36
+ it "has a transaction status" do
37
+ @response.reserve_result.transaction_status.should_not be_nil
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ require File.dirname(__FILE__) + '/units_helper'
2
+
3
+ describe "the SettleDebt API" do
4
+ describe "a successful response" do
5
+ it_should_behave_like 'a successful response'
6
+
7
+ before do
8
+ doc = <<-XML
9
+ <SettleDebtResponse xmlns="http://fps.amazonaws.com/doc/2008-09-17/">
10
+ <SettleDebtResult>
11
+ <TransactionId>14GK6F2QU755ODS27SGHEURLKPG72Z54KMF</TransactionId>
12
+ <TransactionStatus>Pending</TransactionStatus>
13
+ </SettleDebtResult>
14
+ <ResponseMetadata>
15
+ <RequestId>1a146b9a-b37b-4f5f-bda6-012a5b9e45c3:0</RequestId>
16
+ </ResponseMetadata>
17
+ </SettleDebtResponse>
18
+ XML
19
+
20
+ @response = Remit::SettleDebt::Response.new(doc)
21
+ end
22
+
23
+ it "has metadata" do
24
+ @response.response_metadata.should_not be_nil
25
+ end
26
+
27
+ it "has results" do
28
+ @response.settle_debt_result.should_not be_nil
29
+ end
30
+
31
+
32
+ it "has a transaction id" do
33
+ @response.settle_debt_result.transaction_id.should_not be_nil
34
+ end
35
+
36
+ it "has a transaction status" do
37
+ @response.settle_debt_result.transaction_status.should_not be_nil
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ require File.dirname(__FILE__) + '/units_helper'
2
+
3
+ describe "the Settle API" do
4
+ describe "a successful response" do
5
+ it_should_behave_like 'a successful response'
6
+
7
+ before do
8
+ doc = <<-XML
9
+ <SettleResponse xmlns="http://fps.amazonaws.com/doc/2008-09-17/">
10
+ <SettleResult>
11
+ <TransactionId>14GK6F2QU755ODS27SGHEURLKPG72Z54KMF</TransactionId>
12
+ <TransactionStatus>Pending</TransactionStatus>
13
+ </SettleResult>
14
+ <ResponseMetadata>
15
+ <RequestId>1a146b9a-b37b-4f5f-bda6-012a5b9e45c3:0</RequestId>
16
+ </ResponseMetadata>
17
+ </SettleResponse>
18
+ XML
19
+
20
+ @response = Remit::Settle::Response.new(doc)
21
+ end
22
+
23
+ it "has metadata" do
24
+ @response.response_metadata.should_not be_nil
25
+ end
26
+
27
+ it "has results" do
28
+ @response.settle_result.should_not be_nil
29
+ end
30
+
31
+
32
+ it "has a transaction id" do
33
+ @response.settle_result.transaction_id.should_not be_nil
34
+ end
35
+
36
+ it "has a transaction status" do
37
+ @response.settle_result.transaction_status.should_not be_nil
38
+ end
39
+
40
+ end
41
+ end