tylerhunt-remit 0.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.
- data/LICENSE +20 -0
- data/README +38 -0
- data/lib/remit/cancel_token.rb +18 -0
- data/lib/remit/common.rb +88 -0
- data/lib/remit/data_types.rb +107 -0
- data/lib/remit/discard_results.rb +18 -0
- data/lib/remit/fund_prepaid.rb +31 -0
- data/lib/remit/get_account_activity.rb +60 -0
- data/lib/remit/get_account_balance.rb +29 -0
- data/lib/remit/get_all_credit_instruments.rb +18 -0
- data/lib/remit/get_all_prepaid_instruments.rb +18 -0
- data/lib/remit/get_debt_balance.rb +23 -0
- data/lib/remit/get_outstanding_debt_balance.rb +22 -0
- data/lib/remit/get_payment_instruction.rb +21 -0
- data/lib/remit/get_pipeline.rb +123 -0
- data/lib/remit/get_prepaid_balance.rb +23 -0
- data/lib/remit/get_results.rb +26 -0
- data/lib/remit/get_token_by_caller.rb +19 -0
- data/lib/remit/get_token_usage.rb +18 -0
- data/lib/remit/get_tokens.rb +20 -0
- data/lib/remit/get_total_prepaid_liability.rb +22 -0
- data/lib/remit/get_transaction.rb +42 -0
- data/lib/remit/install_payment_instruction.rb +22 -0
- data/lib/remit/pay.rb +34 -0
- data/lib/remit/refund.rb +38 -0
- data/lib/remit/reserve.rb +30 -0
- data/lib/remit/retry_transaction.rb +18 -0
- data/lib/remit/settle.rb +20 -0
- data/lib/remit/settle_debt.rb +30 -0
- data/lib/remit/subscribe_for_caller_notification.rb +18 -0
- data/lib/remit/unsubscribe_for_caller_notification.rb +17 -0
- data/lib/remit/write_off_debt.rb +28 -0
- data/lib/remit.rb +123 -0
- data/spec/get_account_activity_spec.rb +36 -0
- data/spec/get_pipeline_spec.rb +106 -0
- data/spec/get_tokens_spec.rb +38 -0
- data/spec/spec_helper.rb +26 -0
- metadata +102 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module GetTokenByCaller
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :GetTokenByCaller
|
7
|
+
parameter :caller_reference
|
8
|
+
parameter :token_id
|
9
|
+
end
|
10
|
+
|
11
|
+
class Response < Remit::Response
|
12
|
+
parameter :token, :type => Token
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_token_by_caller(request = Request.new)
|
16
|
+
call(request, Response)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module GetTokenUsage
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :GetTokenUsage
|
7
|
+
parameter :token_id
|
8
|
+
end
|
9
|
+
|
10
|
+
class Response < Remit::Response
|
11
|
+
parameter :token_usage_limits, :type => TokenUsageLimit
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_token_usage(request = Request.new)
|
15
|
+
call(request, Response)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module GetTokens
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :GetTokens
|
7
|
+
parameter :caller_reference
|
8
|
+
parameter :token_friendly_name
|
9
|
+
parameter :token_status
|
10
|
+
end
|
11
|
+
|
12
|
+
class Response < Remit::Response
|
13
|
+
parameter :tokens, :collection => Token
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_tokens(request = Request.new)
|
17
|
+
call(request, Response)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module GetTotalPrepaidLiability
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :GetTotalPrepaidLiability
|
7
|
+
end
|
8
|
+
|
9
|
+
class Response < Remit::Response
|
10
|
+
class OutstandingPrepaidLiability < Remit::BaseResponse
|
11
|
+
parameter :outstanding_balance, :type => Amount
|
12
|
+
parameter :panding_in_balance, :type => Amount
|
13
|
+
end
|
14
|
+
|
15
|
+
parameter :outstanding_prepaid_liability, :type => OutstandingPrepaidLiability
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_total_prepaid_liability(request = Request.new)
|
19
|
+
call(request, Response)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module GetTransaction
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :GetTransaction
|
7
|
+
parameter :transaction_id
|
8
|
+
end
|
9
|
+
|
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
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_transaction(request = Request.new)
|
39
|
+
call(request, Response)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module InstallPaymentInstruction
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :InstallPaymentInstruction
|
7
|
+
parameter :payment_instruction
|
8
|
+
parameter :caller_reference
|
9
|
+
parameter :token_friendly_name
|
10
|
+
parameter :token_type
|
11
|
+
parameter :payment_reason
|
12
|
+
end
|
13
|
+
|
14
|
+
class Response < Remit::Response
|
15
|
+
parameter :token_id
|
16
|
+
end
|
17
|
+
|
18
|
+
def install_payment_instruction(request)
|
19
|
+
call(request, Response)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/remit/pay.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module Pay
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :Pay
|
7
|
+
parameter :caller_description
|
8
|
+
parameter :caller_reference
|
9
|
+
parameter :caller_token_id
|
10
|
+
parameter :charge_fee_to
|
11
|
+
parameter :meta_data
|
12
|
+
parameter :recipient_description
|
13
|
+
parameter :recipient_reference
|
14
|
+
parameter :recipient_token_id
|
15
|
+
parameter :sender_description
|
16
|
+
parameter :sender_reference
|
17
|
+
parameter :sender_token_id
|
18
|
+
parameter :transaction_amount, :type => Remit::RequestTypes::Amount
|
19
|
+
parameter :transaction_date
|
20
|
+
end
|
21
|
+
|
22
|
+
class Response < Remit::Response
|
23
|
+
# FIXME: Due to an issue with Hpricot, Relax-0.0.4, and namespaces, the
|
24
|
+
# transaction_response parameter is not parsed correctly and will always
|
25
|
+
# be nil (http://groups.google.com/group/remit/t/1e0af072200d1bb3).
|
26
|
+
# The suggested course of action is to operate on the raw XML.
|
27
|
+
parameter :transaction_response, :type => TransactionResponse
|
28
|
+
end
|
29
|
+
|
30
|
+
def pay(request = Request.new)
|
31
|
+
call(request, Response)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/remit/refund.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module Refund
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :Refund
|
7
|
+
parameter :caller_description
|
8
|
+
parameter :caller_reference
|
9
|
+
parameter :caller_token_id
|
10
|
+
parameter :charge_fee_to
|
11
|
+
parameter :meta_data
|
12
|
+
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
|
18
|
+
parameter :transaction_date
|
19
|
+
parameter :transaction_id
|
20
|
+
|
21
|
+
|
22
|
+
# The RefundAmount parameter has multiple components. It is specified on the query string like
|
23
|
+
# so: RefundAmount.Amount=XXX&RefundAmount.CurrencyCode=YYY
|
24
|
+
def convert_complex_key(key, parameter)
|
25
|
+
"#{convert_key(key).to_s}.#{convert_key(parameter).to_s}"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
class Response < Remit::Response
|
31
|
+
parameter :transaction_response, :type => TransactionResponse
|
32
|
+
end
|
33
|
+
|
34
|
+
def refund(request = Request.new)
|
35
|
+
call(request, Response)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module Reserve
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :Reserve
|
7
|
+
parameter :recipient_token_id
|
8
|
+
parameter :sender_token_id
|
9
|
+
parameter :caller_token_id
|
10
|
+
parameter :sender_reference
|
11
|
+
parameter :recipient_reference
|
12
|
+
parameter :caller_reference
|
13
|
+
parameter :transaction_date
|
14
|
+
parameter :transaction_amount
|
15
|
+
parameter :charge_fee_to
|
16
|
+
parameter :sender_description
|
17
|
+
parameter :recipient_description
|
18
|
+
parameter :caller_description
|
19
|
+
parameter :meta_data
|
20
|
+
end
|
21
|
+
|
22
|
+
class Response < Remit::Response
|
23
|
+
parameter :transaction_response, :type => TransactionResponse
|
24
|
+
end
|
25
|
+
|
26
|
+
def reserve(request = Request.new)
|
27
|
+
call(request, Response)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module RetryTransaction
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :RetryTransaction
|
7
|
+
parameter :original_transaction_id
|
8
|
+
end
|
9
|
+
|
10
|
+
class Response < Remit::Response
|
11
|
+
parameter :transaction_response, :type => TransactionResponse
|
12
|
+
end
|
13
|
+
|
14
|
+
def retry_transaction(request = Request.new)
|
15
|
+
call(request, Response)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/remit/settle.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module Settle
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :Settle
|
7
|
+
parameter :settlement_amount
|
8
|
+
parameter :transaction_id
|
9
|
+
parameter :transaction_date
|
10
|
+
end
|
11
|
+
|
12
|
+
class Response < Remit::Response
|
13
|
+
parameter :transaction_response, :type => TransactionResponse
|
14
|
+
end
|
15
|
+
|
16
|
+
def settle(request = Request.new)
|
17
|
+
call(request, Response)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module SettleDebt
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :SettleDebt
|
7
|
+
parameter :caller_description
|
8
|
+
parameter :caller_reference
|
9
|
+
parameter :caller_token_id
|
10
|
+
parameter :charge_fee_to
|
11
|
+
parameter :credit_instrument_id
|
12
|
+
parameter :meta_data
|
13
|
+
parameter :recipient_description
|
14
|
+
parameter :recipient_reference
|
15
|
+
parameter :sender_description
|
16
|
+
parameter :sender_reference
|
17
|
+
parameter :sender_token_id
|
18
|
+
parameter :settlement_amount
|
19
|
+
parameter :transaction_date
|
20
|
+
end
|
21
|
+
|
22
|
+
class Response < Remit::Response
|
23
|
+
parameter :transaction_response, :type => TransactionResponse
|
24
|
+
end
|
25
|
+
|
26
|
+
def settle_debt(request = Request.new)
|
27
|
+
call(request, Response)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module SubscribeForCallerNotification
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :SubscribeForCallerNotification
|
7
|
+
parameter :notification_operation_name
|
8
|
+
parameter :web_service_api_url
|
9
|
+
end
|
10
|
+
|
11
|
+
class Response < Remit::Response
|
12
|
+
end
|
13
|
+
|
14
|
+
def subscribe_for_caller_notification(request = Request.new)
|
15
|
+
call(request, Response)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module UnsubscribeForCallerNotification
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :UnSubscribeForCallerNotification
|
7
|
+
parameter :notification_operation_name
|
8
|
+
end
|
9
|
+
|
10
|
+
class Response < Remit::Response
|
11
|
+
end
|
12
|
+
|
13
|
+
def unsubscribe_for_caller_notification(request = Request.new)
|
14
|
+
call(request, Response)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'remit/common'
|
2
|
+
|
3
|
+
module Remit
|
4
|
+
module WriteOffDebt
|
5
|
+
class Request < Remit::Request
|
6
|
+
action :WriteOffDebt
|
7
|
+
parameter :caller_token_id
|
8
|
+
parameter :credit_instrument_id
|
9
|
+
parameter :adjustment_amount
|
10
|
+
parameter :transaction_date
|
11
|
+
parameter :sender_reference
|
12
|
+
parameter :caller_reference
|
13
|
+
parameter :recipient_reference
|
14
|
+
parameter :sender_description
|
15
|
+
parameter :recipient_description
|
16
|
+
parameter :caller_description
|
17
|
+
parameter :meta_data
|
18
|
+
end
|
19
|
+
|
20
|
+
class Response < Remit::Response
|
21
|
+
parameter :transaction_response, :type => TransactionResponse
|
22
|
+
end
|
23
|
+
|
24
|
+
def write_off_debt(request = Request.new)
|
25
|
+
call(request, Response)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/remit.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
|
3
|
+
require 'openssl'
|
4
|
+
require 'net/https'
|
5
|
+
require 'uri'
|
6
|
+
require 'date'
|
7
|
+
require 'base64'
|
8
|
+
require 'erb'
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
require 'relax'
|
12
|
+
|
13
|
+
require 'remit/common'
|
14
|
+
require 'remit/data_types'
|
15
|
+
|
16
|
+
require 'remit/cancel_token'
|
17
|
+
require 'remit/discard_results'
|
18
|
+
require 'remit/fund_prepaid'
|
19
|
+
require 'remit/get_account_activity'
|
20
|
+
require 'remit/get_account_balance'
|
21
|
+
require 'remit/get_all_credit_instruments'
|
22
|
+
require 'remit/get_all_prepaid_instruments'
|
23
|
+
require 'remit/get_debt_balance'
|
24
|
+
require 'remit/get_outstanding_debt_balance'
|
25
|
+
require 'remit/get_payment_instruction'
|
26
|
+
require 'remit/get_pipeline'
|
27
|
+
require 'remit/get_prepaid_balance'
|
28
|
+
require 'remit/get_results'
|
29
|
+
require 'remit/get_token_usage'
|
30
|
+
require 'remit/get_tokens'
|
31
|
+
require 'remit/get_token_by_caller'
|
32
|
+
require 'remit/get_total_prepaid_liability'
|
33
|
+
require 'remit/get_transaction'
|
34
|
+
require 'remit/install_payment_instruction'
|
35
|
+
require 'remit/pay'
|
36
|
+
require 'remit/refund'
|
37
|
+
require 'remit/reserve'
|
38
|
+
require 'remit/retry_transaction'
|
39
|
+
require 'remit/settle'
|
40
|
+
require 'remit/settle_debt'
|
41
|
+
require 'remit/subscribe_for_caller_notification'
|
42
|
+
require 'remit/unsubscribe_for_caller_notification'
|
43
|
+
require 'remit/write_off_debt'
|
44
|
+
|
45
|
+
module Remit
|
46
|
+
class API < Relax::Service
|
47
|
+
include CancelToken
|
48
|
+
include DiscardResults
|
49
|
+
include FundPrepaid
|
50
|
+
include GetAccountActivity
|
51
|
+
include GetAccountBalance
|
52
|
+
include GetAllCreditInstruments
|
53
|
+
include GetAllPrepaidInstruments
|
54
|
+
include GetDebtBalance
|
55
|
+
include GetOutstandingDebtBalance
|
56
|
+
include GetPaymentInstruction
|
57
|
+
include GetPipeline
|
58
|
+
include GetPrepaidBalance
|
59
|
+
include GetResults
|
60
|
+
include GetTokenUsage
|
61
|
+
include GetTokens
|
62
|
+
include GetTokenByCaller
|
63
|
+
include GetTotalPrepaidLiability
|
64
|
+
include GetTransaction
|
65
|
+
include InstallPaymentInstruction
|
66
|
+
include Pay
|
67
|
+
include Refund
|
68
|
+
include Reserve
|
69
|
+
include RetryTransaction
|
70
|
+
include Settle
|
71
|
+
include SettleDebt
|
72
|
+
include SubscribeForCallerNotification
|
73
|
+
include UnsubscribeForCallerNotification
|
74
|
+
include WriteOffDebt
|
75
|
+
|
76
|
+
API_ENDPOINT = 'https://fps.amazonaws.com/'
|
77
|
+
API_SANDBOX = 'https://fps.sandbox.amazonaws.com/'
|
78
|
+
PIPELINE_ENDPOINT = 'https://authorize.payments.amazon.com/cobranded-ui/actions/start'
|
79
|
+
PIPELINE_SANDBOX = 'https://authorize.payments-sandbox.amazon.com/cobranded-ui/actions/start'
|
80
|
+
API_VERSION = Date.new(2007, 1, 8).to_s
|
81
|
+
SIGNATURE_VERSION = 1
|
82
|
+
|
83
|
+
attr_reader :pipeline
|
84
|
+
attr_reader :access_key
|
85
|
+
attr_reader :secret_key
|
86
|
+
|
87
|
+
def initialize(access_key, secret_key, sandbox = false)
|
88
|
+
super((not sandbox) ? API_ENDPOINT : API_SANDBOX)
|
89
|
+
@pipeline = ((not sandbox) ? PIPELINE_ENDPOINT : PIPELINE_SANDBOX)
|
90
|
+
@access_key = access_key
|
91
|
+
@secret_key = secret_key
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def new_query(query = {})
|
97
|
+
SignedQuery.new(@endpoint, @secret_key, query)
|
98
|
+
end
|
99
|
+
|
100
|
+
def default_query
|
101
|
+
new_query({
|
102
|
+
:AWSAccessKeyId => @access_key,
|
103
|
+
:SignatureVersion => SIGNATURE_VERSION,
|
104
|
+
:Version => API_VERSION,
|
105
|
+
:Timestamp => Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
|
106
|
+
})
|
107
|
+
end
|
108
|
+
|
109
|
+
def query(request)
|
110
|
+
query = super
|
111
|
+
query[:Signature] = sign(query)
|
112
|
+
query
|
113
|
+
end
|
114
|
+
|
115
|
+
def sign(values)
|
116
|
+
keys = values.keys.sort { |a, b| a.to_s.downcase <=> b.to_s.downcase }
|
117
|
+
signature = keys.inject('') do |signature, key|
|
118
|
+
signature += key.to_s + values[key].to_s
|
119
|
+
end
|
120
|
+
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, @secret_key, signature)).strip
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe 'a GetAccountActivity call' do
|
4
|
+
it_should_behave_like 'a successful request'
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
request = Remit::API::GetAccountActivityRequest.new
|
8
|
+
request.start_date = Date.today - 7
|
9
|
+
@response = @remit.get_account_activity(request)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have a collection of transactions' do
|
13
|
+
@response.should have_at_least(1).transactions
|
14
|
+
end
|
15
|
+
|
16
|
+
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_nil
|
25
|
+
transaction.error_message.should be_nil
|
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
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe 'A pipeline', :shared => true do
|
4
|
+
before do
|
5
|
+
@remit = Remit::API.new(ACCESS_KEY, SECRET_KEY, true)
|
6
|
+
|
7
|
+
@pipeline_options = {
|
8
|
+
:return_URL => 'http://example.com/'
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should sign its URL' do
|
13
|
+
uri = URI.parse(@pipeline.url)
|
14
|
+
pipeline = Remit::SignedQuery.parse(uri, @remit.secret_key, uri.query)
|
15
|
+
query = Relax::Query.parse(uri)
|
16
|
+
|
17
|
+
pipeline[:awsSignature].should == query[:awsSignature]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'A single-use pipeline' do
|
22
|
+
it_should_behave_like 'A pipeline'
|
23
|
+
|
24
|
+
before do
|
25
|
+
@pipeline_options.merge!({
|
26
|
+
:transaction_amount => 10,
|
27
|
+
:caller_reference => 'N2PCBEIA5864E27EL7C86PJL1FGUGPBL61QTJJM5GQK265SPEN8ZKIJPMQARDVJK',
|
28
|
+
:recipient_token => 'N5PCME5A5Q6FE2QEB7CD64JLGFTUGXBE61HTCJMGGAK2R5IPEQ8EKIVP3QAVD7JP',
|
29
|
+
:pipeline_name => Remit::PipelineName::SINGLE_USE
|
30
|
+
})
|
31
|
+
|
32
|
+
@pipeline = @remit.get_single_use_pipeline(@pipeline_options)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should ignore unused parameters' do
|
36
|
+
uri = URI.parse(@pipeline.url)
|
37
|
+
query = Relax::Query.parse(uri)
|
38
|
+
|
39
|
+
query[:paymentReason].should be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'A recurring-use pipeline' do
|
44
|
+
it_should_behave_like 'A pipeline'
|
45
|
+
|
46
|
+
before do
|
47
|
+
@validity_start = Time.now + (3600 * 24) # 1 day from now
|
48
|
+
@validity_expiry = Time.now + (3600 * 24 * 180) # ~6 months from now
|
49
|
+
@recurring_period = '1 Month'
|
50
|
+
|
51
|
+
@pipeline_options.merge!({
|
52
|
+
:pipeline_name => Remit::PipelineName::RECURRING,
|
53
|
+
:validity_start => @validity_start,
|
54
|
+
:validity_expiry => @validity_expiry,
|
55
|
+
:recurring_period => @recurring_period,
|
56
|
+
:transaction_amount => 10,
|
57
|
+
:caller_reference => 'N2PCBEIA5864E27EL7C86PJL1FGUGPBL61QTJJM5GQK265SPEN8ZKIJPMQARDVJK',
|
58
|
+
:recipient_token => 'N5PCME5A5Q6FE2QEB7CD64JLGFTUGXBE61HTCJMGGAK2R5IPEQ8EKIVP3QAVD7JP'
|
59
|
+
})
|
60
|
+
|
61
|
+
@pipeline = @remit.get_recurring_use_pipeline(@pipeline_options)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should convert times to seconds from epoch' do
|
65
|
+
uri = URI.parse(@pipeline.url)
|
66
|
+
query = Relax::Query.parse(uri)
|
67
|
+
|
68
|
+
@validity_start.to_i.to_s.should == query[:validityStart]
|
69
|
+
@validity_expiry.to_i.to_s.should == query[:validityExpiry]
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should allow time in seconds' do
|
73
|
+
options = @pipeline_options.merge({
|
74
|
+
:validity_start => @validity_start.to_i,
|
75
|
+
:validity_expiry => @validity_expiry.to_i
|
76
|
+
})
|
77
|
+
@pipeline = @remit.get_recurring_use_pipeline(options)
|
78
|
+
|
79
|
+
uri = URI.parse(@pipeline.url)
|
80
|
+
query = Relax::Query.parse(uri)
|
81
|
+
|
82
|
+
@validity_start.to_i.to_s.should == query[:validityStart]
|
83
|
+
@validity_expiry.to_i.to_s.should == query[:validityExpiry]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe 'A postpaid pipeline' do
|
88
|
+
it_should_behave_like 'A pipeline'
|
89
|
+
|
90
|
+
before do
|
91
|
+
@credit_limit = 100
|
92
|
+
@global_amount_limit = 100
|
93
|
+
|
94
|
+
@pipeline_options.merge!({
|
95
|
+
:pipeline_name => Remit::PipelineName::SETUP_POSTPAID,
|
96
|
+
:credit_limit => @credit_limit,
|
97
|
+
:global_amount_limit => @global_amount_limit
|
98
|
+
})
|
99
|
+
|
100
|
+
@pipeline = @remit.get_postpaid_pipeline(@pipeline_options)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should create a PostpaidPipeline' do
|
104
|
+
@pipeline.class.should == Remit::GetPipeline::PostpaidPipeline
|
105
|
+
end
|
106
|
+
end
|