pboling-remit 0.0.8 → 0.2.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 (46) hide show
  1. metadata +19 -72
  2. data/LICENSE +0 -20
  3. data/README.markdown +0 -91
  4. data/lib/remit.rb +0 -127
  5. data/lib/remit/common.rb +0 -110
  6. data/lib/remit/data_types.rb +0 -170
  7. data/lib/remit/error_codes.rb +0 -118
  8. data/lib/remit/get_pipeline.rb +0 -212
  9. data/lib/remit/ipn_request.rb +0 -46
  10. data/lib/remit/operations/cancel_token.rb +0 -18
  11. data/lib/remit/operations/discard_results.rb +0 -18
  12. data/lib/remit/operations/fund_prepaid.rb +0 -31
  13. data/lib/remit/operations/get_account_activity.rb +0 -60
  14. data/lib/remit/operations/get_account_balance.rb +0 -29
  15. data/lib/remit/operations/get_all_credit_instruments.rb +0 -18
  16. data/lib/remit/operations/get_all_prepaid_instruments.rb +0 -18
  17. data/lib/remit/operations/get_debt_balance.rb +0 -23
  18. data/lib/remit/operations/get_outstanding_debt_balance.rb +0 -22
  19. data/lib/remit/operations/get_payment_instruction.rb +0 -21
  20. data/lib/remit/operations/get_prepaid_balance.rb +0 -23
  21. data/lib/remit/operations/get_results.rb +0 -27
  22. data/lib/remit/operations/get_token_by_caller.rb +0 -19
  23. data/lib/remit/operations/get_token_usage.rb +0 -18
  24. data/lib/remit/operations/get_tokens.rb +0 -20
  25. data/lib/remit/operations/get_total_prepaid_liability.rb +0 -22
  26. data/lib/remit/operations/get_transaction.rb +0 -54
  27. data/lib/remit/operations/install_payment_instruction.rb +0 -22
  28. data/lib/remit/operations/pay.rb +0 -30
  29. data/lib/remit/operations/refund.rb +0 -44
  30. data/lib/remit/operations/reserve.rb +0 -30
  31. data/lib/remit/operations/retry_transaction.rb +0 -18
  32. data/lib/remit/operations/settle.rb +0 -20
  33. data/lib/remit/operations/settle_debt.rb +0 -30
  34. data/lib/remit/operations/subscribe_for_caller_notification.rb +0 -18
  35. data/lib/remit/operations/unsubscribe_for_caller_notification.rb +0 -17
  36. data/lib/remit/operations/write_off_debt.rb +0 -28
  37. data/lib/remit/pipeline_response.rb +0 -64
  38. data/spec/integrations/get_account_activity_spec.rb +0 -36
  39. data/spec/integrations/get_tokens_spec.rb +0 -38
  40. data/spec/integrations/integrations_helper.rb +0 -8
  41. data/spec/spec_helper.rb +0 -36
  42. data/spec/units/get_pipeline_spec.rb +0 -165
  43. data/spec/units/get_results_spec.rb +0 -49
  44. data/spec/units/ipn_request_spec.rb +0 -32
  45. data/spec/units/pay_spec.rb +0 -133
  46. data/spec/units/units_helper.rb +0 -4
@@ -1,170 +0,0 @@
1
- require 'rubygems'
2
- require 'relax'
3
-
4
- require 'remit/common'
5
-
6
- module Remit
7
- class Amount < BaseResponse
8
- parameter :currency_code
9
- parameter :value, :type => :float
10
- end
11
-
12
- class DescriptorPolicy < BaseResponse
13
- parameter :soft_descriptor_type
14
- parameter :CS_number_of
15
- end
16
-
17
- class ChargeFeeTo
18
- CALLER = 'Caller'
19
- RECIPIENT = 'Recipient'
20
- end
21
-
22
- class Error < BaseResponse
23
- parameter :code
24
- parameter :message
25
- end
26
-
27
- class InstrumentStatus
28
- ALL = 'ALL'
29
- ACTIVE = 'Active'
30
- INACTIVE = 'Inactive'
31
- end
32
-
33
- class PaymentMethods
34
- BALANCE_TRANSFER = 'abt'
35
- BANK_ACCOUNT = 'ach'
36
- CREDIT_CARD = 'credit card'
37
- PREPAID = 'prepaid'
38
- DEBT = 'Debt'
39
- end
40
-
41
- class ServiceError < BaseResponse
42
- parameter :error_type
43
- parameter :is_retriable
44
- parameter :error_code
45
- parameter :reason_text
46
-
47
- class ErrorType
48
- SYSTEM = 'System'
49
- BUSINESS = 'Business'
50
- end
51
- end
52
-
53
- class ResponseStatus
54
- SUCCESS = 'Success'
55
- FAILURE = 'Failure'
56
- end
57
-
58
- class Token < BaseResponse
59
- parameter :token_id
60
- parameter :friendly_name
61
- parameter :status
62
- parameter :date_installed, :type => :time
63
- parameter :caller_installed
64
- parameter :caller_reference
65
- parameter :token_type
66
- parameter :old_token_id
67
- parameter :payment_reason
68
-
69
- class TokenStatus
70
- ACTIVE = 'Active'
71
- INACTIVE = 'Inactive'
72
- end
73
- end
74
-
75
- class TokenUsageLimit < BaseResponse
76
- parameter :count
77
- parameter :limit
78
- parameter :last_reset_amount
79
- parameter :last_reset_count
80
- parameter :last_reset_time_stamp
81
- end
82
-
83
- class TransactionResponse < BaseResponse
84
- parameter :transaction_id
85
- parameter :transaction_status
86
-
87
- %w(reserved success failure pending cancelled).each do |status_name|
88
- define_method("#{status_name}?") do
89
- self.transaction_status == Remit::TransactionStatus.const_get(status_name.sub('_', '').upcase)
90
- end
91
- end
92
- end
93
-
94
- class TransactionStatus
95
- RESERVED = 'Reserved'
96
- SUCCESS = 'Success'
97
- FAILURE = 'Failure'
98
- PENDING = 'Pending'
99
- CANCELLED = 'Cancelled'
100
- end
101
-
102
- class TokenType
103
- SINGLE_USE = 'SingleUse'
104
- MULTI_USE = 'MultiUse'
105
- RECURRING = 'Recurring'
106
- UNRESTRICTED = 'Unrestricted'
107
- end
108
-
109
- class PipelineName
110
- SINGLE_USE = 'SingleUse'
111
- MULTI_USE = 'MultiUse'
112
- RECURRING = 'Recurring'
113
- RECIPIENT = 'Recipient'
114
- SETUP_PREPAID = 'SetupPrepaid'
115
- SETUP_POSTPAID = 'SetupPostpaid'
116
- EDIT_TOKEN = 'EditToken'
117
- end
118
-
119
- class PipelineStatusCode
120
- CALLER_EXCEPTION = 'CE' # problem with your code
121
- SYSTEM_ERROR = 'SE' # system error, try again
122
- SUCCESS_ABT = 'SA' # successful payment with Amazon balance
123
- SUCCESS_ACH = 'SB' # successful payment with bank transfer
124
- SUCCESS_CC = 'SC' # successful payment with credit card
125
- ABORTED = 'A' # user aborted payment
126
- PAYMENT_METHOD_MISMATCH = 'PE' # user does not have payment method requested
127
- PAYMENT_METHOD_UNSUPPORTED = 'NP' # account doesn't support requested payment method
128
- INVALID_CALLER = 'NM' # you are not a valid 3rd party caller to the transaction
129
- SUCCESS_RECIPIENT_TOKEN_INSTALLED = 'SR'
130
- SUCCESS_NO_CHANGE = 'SU' # the existing token was not changed
131
- end
132
-
133
- module RequestTypes
134
- class Amount < Remit::Request
135
- parameter :value
136
- parameter :currency_code
137
- end
138
-
139
- class DescriptorPolicy < Remit::Request
140
- parameter :soft_descriptor_type
141
- parameter :CS_number_of
142
- end
143
-
144
- #Amazon Docs list MarketplaceRefundPolicy as a ComplexDataType, but it is not.
145
- #It really should be listed under Enumerated DataTypes
146
- #MarketplaceTxnOnly Caller refunds his fee to the recipient. String
147
- #MasterAndMarketplaceTxn Caller and Amazon FPS refund their fees to the String
148
- # sender, and the recipient refunds his amount
149
- #MasterTxnOnly Caller does not refund his fee. Amazon FPS String
150
- # refunds its fee and the recipient refunds his amount
151
- # plus the caller's fee to the sender.
152
- class MarketplaceRefundPolicy < Remit::Request
153
- POLICY = {
154
- :marketplace_txn_only => 'MarketplaceTxnOnly',
155
- :master_and_marketplace_txn => 'MasterAndMarketplaceTxn',
156
- :master_txn_only => 'MasterTxnOnly'
157
- }
158
- end
159
-
160
- end
161
-
162
- class Operation
163
- PAY = "Pay"
164
- REFUND = "Refund"
165
- SETTLE = "Settle"
166
- SETTLE_DEBT = "SettleDebt"
167
- WRITE_OFF_DEBT = "WriteOffDebt"
168
- FUND_PREPAID = "FundPrepaid"
169
- end
170
- end
@@ -1,118 +0,0 @@
1
- # Scraped and categorized from http://docs.amazonwebservices.com/AmazonFPS/\
2
- # 2007-01-08/FPSDeveloperGuide/index.html?ErrorCodesTable.html. You can use
3
- # these categories to specify default error handling in your application such
4
- # as asking users to retry or sending an exception email.
5
- module Remit::ErrorCodes
6
- class << self
7
- def sender_error?(code)
8
- SENDER.include? code.to_sym
9
- end
10
-
11
- def recipient_error?(code)
12
- RECIPIENT.include? code.to_sym
13
- end
14
-
15
- def caller_error?(code)
16
- CALLER.include?(code.to_sym)
17
- end
18
-
19
- def amazon_error?(code)
20
- AMAZON.include? code.to_sym
21
- end
22
-
23
- def api_error?(code)
24
- API.include? code.to_sym
25
- end
26
-
27
- def unknown_error?(code)
28
- UNKNOWN.include? code.to_sym
29
- end
30
- end
31
-
32
- SENDER = [
33
- :InactiveAccount_Sender, # The sender's account is in suspended or closed state.
34
- :InactiveInstrument, # The payment instrument used for this transaction is no longer active.
35
- :InstrumentExpired, # The prepaid or the postpaid instrument has expired.
36
- :InstrumentNotActive, # The prepaid or postpaid instrument used in the transaction is not active.
37
- :InvalidAccountState_Sender, # Sender account cannot participate in the transaction.
38
- :InvalidInstrumentForAccountType, # The sender account can use only credit cards
39
- :InvalidInstrumentState, # The prepaid or credit instrument should be active
40
- :InvalidTokenId_Sender, # The send token specified is either invalid or canceled or the token is not active.
41
- :PaymentInstrumentNotCC, # The payment method specified in the transaction is not a credit card. You can only use a credit card for this transaction.
42
- :PaymentInstrumentMissing, # There needs to be a payment instrument defined in the token which defines the payment method.
43
- :TokenNotActive_Sender, # The sender token is canceled.
44
- :UnverifiedAccount_Sender, # The sender's account must have a verified U.S. credit card or a verified U.S bank account before this transaction can be initiated
45
- :UnverifiedBankAccount, # A verified bank account should be used for this transaction
46
- :UnverifiedEmailAddress_Sender, # The sender account must have a verified e-mail address for this payment
47
- ]
48
-
49
- RECIPIENT = [
50
- :InactiveAccount_Recipient, # The recipient's account is in suspended or closed state.
51
- :InvalidAccountState_Recipient, # Recipient account cannot participate in the transaction
52
- :InvalidRecipientRoleForAccountType, # The recipient account is not allowed to receive payments
53
- :InvalidRecipientForCCTransaction, # This account cannot receive credit card payments.
54
- :InvalidTokenId_Recipient, # The recipient token specified is either invalid or canceled.
55
- :TokenNotActive_Recipient, # The recipient token is canceled.
56
- :UnverifiedAccount_Recipient, # The recipient's account must have a verified bank account or a credit card before this transaction can be initiated.
57
- :UnverifiedEmailAddress_Recipient, # The recipient account must have a verified e-mail address for receiving payments.
58
- ]
59
-
60
- CALLER = [
61
- :InactiveAccount_Caller, # The caller's account is in suspended or closed state.
62
- :InvalidAccountState_Caller, # The caller account cannot participate in the transaction
63
- :InvalidTokenId_Caller, # The caller token specified is either invalid or canceled or the specified token is not active.
64
- :TokenNotActive_Caller, # The caller token is canceled.
65
- :UnverifiedEmailAddress_Caller, # The caller account must have a verified e-mail address
66
- ]
67
-
68
- AMAZON = [
69
- :InternalError # A retriable error that happens due to some transient problem in the system.
70
- ]
71
-
72
- # bad syntax or logic
73
- API = [
74
- :AmountOutOfRange, # The transaction amount is more than the allowed range.
75
- :BadRule, # One of the GK constructs is not well defined
76
- :CannotSpecifyUsageForSingleUseToken, # Token usages cannot be specified for a single use token.
77
- :ConcurrentModification, # A retriable error can happen due to concurrent modification of data by two processes.
78
- :DuplicateRequest, # A different request associated with this caller reference already exists.
79
- :IncompatibleTokens, # The transaction could not be completed because the tokens have incompatible payment instructions.
80
- :InstrumentAccessDenied, # The external calling application is not the recipient for this postpaid or prepaid instrument. The caller should be the liability holder
81
- :InvalidCallerReference, # The CallerReferece does not have a token associated with it.
82
- :InvalidDateRange, # The end date specified is before the start date or the start date is in the future.
83
- :InvalidEvent, # The event specified was not subscribed using the SubscribeForCallerNotification operation.
84
- :InvalidParams, # One or more parameters in the request is invalid.
85
- :InvalidPaymentInstrument, # The payment method used in the transaction is invalid.
86
- :InvalidPaymentMethod, # Payment method specified in the GK construct is invalid.
87
- :InvalidSenderRoleForAccountType, # This token cannot be used for this operation.
88
- :InvalidTokenId, # The token that you are trying to cancel was not installed by you.
89
- :InvalidTokenType, # Invalid operation performed on the token. Example, getting the token usage information on a single use token.
90
- :InvalidTransactionId, # The specified transaction could not be found or the caller did not execute the transaction or this is not a Pay or Reserve call.
91
- :InvalidTransactionState, # The transaction is not completed or it has been temporarily failed.
92
- :InvalidUsageDuration, # The duration cannot be less than one hour.
93
- :InvalidUsageLimitCount, # The usage count is null or empty.
94
- :InvalidUsageStartTime, # The start time specified for the token is not valid.
95
- :InvalidUsageType, # The usage type specified is invalid.
96
- :OriginalTransactionIncomplete, # The original transaction is still in progress.
97
- :OriginalTransactionFailed, # The original transaction has failed
98
- :PaymentMethodNotDefined, # Payment method is not defined in the transaction.
99
- :RefundAmountExceeded, # The refund amount is more than the refundable amount.
100
- :SameTokenIdUsedMultipleTimes, # This token is already used in earlier transactions.
101
- :SenderNotOriginalRecipient, # The sender in the refund transaction is not the recipient of the original transaction.
102
- :SettleAmountGreaterThanReserveAmount, # The amount being settled is greater than the reserved amount.
103
- :TransactionDenied, # This transaction is not allowed.
104
- :TransactionExpired, # Returned when the Caller attempts to explicitly retry a transaction that is temporarily declined and is in queue for implicit retry.
105
- :TransactionFullyRefundedAlready, # The complete refund for this transaction is already completed
106
- :TransactionTypeNotRefundable, # You cannot refund this transaction.
107
- :TokenAccessDenied, # Permission is denied to cancel the token.
108
- :TokenUsageError, # The token usage limit is exceeded.
109
- :UsageNotDefined, # For a multi-use token or a recurring token the usage limits are not specified in the GateKeeper text.
110
- ]
111
-
112
- # these errors don't specify who is at fault
113
- UNKNOWN = [
114
- :InvalidAccountState, # The account is either suspended or closed. Payment instructions cannot be installed on this account.
115
- :InsufficientBalance, # The sender, caller, or recipient's account balance has insufficient funds to complete the transaction.
116
- :AccountLimitsExceeded, # The spending or the receiving limit on the account is exceeded
117
- ]
118
- end
@@ -1,212 +0,0 @@
1
- require 'erb'
2
-
3
- require 'remit/common'
4
-
5
- module Remit
6
- module GetPipeline
7
- class Pipeline
8
- @parameters = []
9
- attr_reader :parameters
10
-
11
- class << self
12
- # Create the parameters hash for the subclass.
13
- def inherited(subclass) #:nodoc:
14
- subclass.instance_variable_set('@parameters', [])
15
- end
16
-
17
- def parameter(name)
18
- attr_accessor name
19
- @parameters << name
20
- end
21
-
22
- def convert_key(key)
23
- key.to_s.gsub(/_(.)/) { $1.upcase }.to_sym
24
- end
25
-
26
- # Returns a hash of all of the parameters for this request, including
27
- # those that are inherited.
28
- def parameters #:nodoc:
29
- (superclass.respond_to?(:parameters) ? superclass.parameters : []) + @parameters
30
- end
31
- end
32
-
33
- attr_reader :api
34
-
35
- parameter :pipeline_name
36
- parameter :return_url
37
- parameter :caller_key
38
- parameter :version
39
- parameter :address_name
40
- parameter :address_line_1
41
- parameter :address_line_2
42
- parameter :city
43
- parameter :state
44
- parameter :zip
45
- parameter :country
46
- parameter :phone_number
47
-
48
- def initialize(api, options)
49
- @api = api
50
-
51
- options.each do |k,v|
52
- self.send("#{k}=", v)
53
- end
54
- end
55
-
56
- def url
57
- uri = URI.parse(@api.pipeline_url)
58
-
59
- query = {}
60
- self.class.parameters.each do |p|
61
- val = self.send(p)
62
-
63
- # Convert Time values to seconds from Epoch
64
- val = val.to_i if val.is_a?(Time)
65
-
66
- query[self.class.convert_key(p.to_s)] = val
67
- end
68
-
69
- # Remove any unused optional parameters
70
- query.reject! { |key, value| value.nil? || (value.is_a?(String) && value.empty?) }
71
-
72
- uri.query = SignedQuery.new(@api.pipeline_url, @api.secret_key, query).to_s
73
- uri.to_s
74
- end
75
-
76
- def method_missing(method, *args)
77
- if self.class.parameters.include?(method.to_sym)
78
- self.send(method.to_sym)
79
- else
80
- super
81
- end
82
- end
83
-
84
- end
85
-
86
- class SingleUsePipeline < Pipeline
87
- parameter :caller_reference
88
- parameter :payment_reason
89
- parameter :payment_method
90
- parameter :transaction_amount
91
- parameter :recipient_token
92
-
93
- def pipeline_name
94
- Remit::PipelineName::SINGLE_USE
95
- end
96
- end
97
-
98
- class MultiUsePipeline < Pipeline
99
- parameter :caller_reference
100
- parameter :payment_reason
101
- parameter :recipient_token_list
102
- parameter :amount_type
103
- parameter :transaction_amount
104
- parameter :validity_start
105
- parameter :validity_expiry
106
- parameter :payment_method
107
- parameter :global_amount_limit
108
- parameter :usage_limit_type_1
109
- parameter :usage_limit_period_1
110
- parameter :usage_limit_value_1
111
- parameter :usage_limit_type_2
112
- parameter :usage_limit_period_2
113
- parameter :usage_limit_value_2
114
- parameter :is_recipient_cobranding
115
-
116
- def pipeline_name
117
- Remit::PipelineName::MULTI_USE
118
- end
119
- end
120
-
121
- class RecipientPipeline < Pipeline
122
- parameter :caller_reference
123
- parameter :validity_start # Time or seconds from Epoch
124
- parameter :validity_expiry # Time or seconds from Epoch
125
- parameter :payment_method
126
- parameter :recipient_pays_fee
127
- parameter :caller_reference_refund
128
- parameter :max_variable_fee
129
- parameter :max_fixed_fee
130
-
131
- def pipeline_name
132
- Remit::PipelineName::RECIPIENT
133
- end
134
- end
135
-
136
- class RecurringUsePipeline < Pipeline
137
- parameter :caller_reference
138
- parameter :payment_reason
139
- parameter :recipient_token
140
- parameter :transaction_amount
141
- parameter :validity_start # Time or seconds from Epoch
142
- parameter :validity_expiry # Time or seconds from Epoch
143
- parameter :payment_method
144
- parameter :recurring_period
145
-
146
- def pipeline_name
147
- Remit::PipelineName::RECURRING
148
- end
149
- end
150
-
151
- class PostpaidPipeline < Pipeline
152
- parameter :caller_reference_sender
153
- parameter :caller_reference_settlement
154
- parameter :payment_reason
155
- parameter :payment_method
156
- parameter :validity_start # Time or seconds from Epoch
157
- parameter :validity_expiry # Time or seconds from Epoch
158
- parameter :credit_limit
159
- parameter :global_amount_limit
160
- parameter :usage_limit_type1
161
- parameter :usage_limit_period1
162
- parameter :usage_limit_value1
163
- parameter :usage_limit_type2
164
- parameter :usage_limit_period2
165
- parameter :usage_limit_value2
166
-
167
- def pipeline_name
168
- Remit::PipelineName::SETUP_POSTPAID
169
- end
170
- end
171
-
172
- class EditTokenPipeline < Pipeline
173
- parameter :caller_reference
174
- parameter :payment_method
175
- parameter :token_id
176
-
177
- def pipeline_name
178
- Remit::PipelineName::EDIT_TOKEN
179
- end
180
- end
181
-
182
- def get_single_use_pipeline(options)
183
- self.get_pipeline(SingleUsePipeline, options)
184
- end
185
-
186
- def get_multi_use_pipeline(options)
187
- self.get_pipeline(MultiUsePipeline, {:version => Date.new(2009, 1, 9).to_s}.merge(options))
188
- end
189
-
190
- def get_recipient_pipeline(options)
191
- self.get_pipeline(RecipientPipeline, {:version => Date.new(2009, 1, 9).to_s}.merge(options))
192
- end
193
-
194
- def get_recurring_use_pipeline(options)
195
- self.get_pipeline(RecurringUsePipeline, options)
196
- end
197
-
198
- def get_postpaid_pipeline(options)
199
- self.get_pipeline(PostpaidPipeline, options)
200
- end
201
-
202
- def get_edit_token_pipeline(options)
203
- self.get_pipeline(EditTokenPipeline, options)
204
- end
205
-
206
- def get_pipeline(pipeline_subclass, options)
207
- pipeline = pipeline_subclass.new(self, {
208
- :caller_key => @access_key
209
- }.merge(options))
210
- end
211
- end
212
- end