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
metadata CHANGED
@@ -1,79 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pboling-remit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Hunt
8
- autorequire:
8
+ autorequire: remit
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-27 00:00:00 -07:00
12
+ date: 2009-02-25 00:00:00 -08:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: relax
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 0.0.7
24
- version:
14
+ dependencies: []
15
+
25
16
  description: Ruby API for Amazon Web Services Flexible Payment Service
26
- email: tyler@tylerhunt.com
17
+ email: ""
27
18
  executables: []
28
19
 
29
20
  extensions: []
30
21
 
31
- extra_rdoc_files:
32
- - LICENSE
33
- - README.markdown
34
- files:
35
- - lib/remit.rb
36
- - lib/remit/common.rb
37
- - lib/remit/data_types.rb
38
- - lib/remit/error_codes.rb
39
- - lib/remit/get_pipeline.rb
40
- - lib/remit/ipn_request.rb
41
- - lib/remit/operations/cancel_token.rb
42
- - lib/remit/operations/discard_results.rb
43
- - lib/remit/operations/fund_prepaid.rb
44
- - lib/remit/operations/get_account_activity.rb
45
- - lib/remit/operations/get_account_balance.rb
46
- - lib/remit/operations/get_all_credit_instruments.rb
47
- - lib/remit/operations/get_all_prepaid_instruments.rb
48
- - lib/remit/operations/get_debt_balance.rb
49
- - lib/remit/operations/get_outstanding_debt_balance.rb
50
- - lib/remit/operations/get_payment_instruction.rb
51
- - lib/remit/operations/get_prepaid_balance.rb
52
- - lib/remit/operations/get_results.rb
53
- - lib/remit/operations/get_token_by_caller.rb
54
- - lib/remit/operations/get_token_usage.rb
55
- - lib/remit/operations/get_tokens.rb
56
- - lib/remit/operations/get_total_prepaid_liability.rb
57
- - lib/remit/operations/get_transaction.rb
58
- - lib/remit/operations/install_payment_instruction.rb
59
- - lib/remit/operations/pay.rb
60
- - lib/remit/operations/refund.rb
61
- - lib/remit/operations/reserve.rb
62
- - lib/remit/operations/retry_transaction.rb
63
- - lib/remit/operations/settle.rb
64
- - lib/remit/operations/settle_debt.rb
65
- - lib/remit/operations/subscribe_for_caller_notification.rb
66
- - lib/remit/operations/unsubscribe_for_caller_notification.rb
67
- - lib/remit/operations/write_off_debt.rb
68
- - lib/remit/pipeline_response.rb
69
- - LICENSE
70
- - README.markdown
71
- has_rdoc: true
72
- homepage: http://github.com/tylerhunt/remit
73
- licenses:
22
+ extra_rdoc_files: []
23
+
24
+ files: []
25
+
26
+ has_rdoc: false
27
+ homepage: http://github.com/tylerhunt/remit/tree/master
74
28
  post_install_message:
75
29
  rdoc_options:
76
- - --charset=UTF-8
30
+ - --title
31
+ - AWS FPS Ruby API
77
32
  require_paths:
78
33
  - lib
79
34
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -90,18 +45,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
45
  version:
91
46
  requirements: []
92
47
 
93
- rubyforge_project: remit
94
- rubygems_version: 1.3.5
48
+ rubyforge_project:
49
+ rubygems_version: 1.2.0
95
50
  signing_key:
96
51
  specification_version: 2
97
- summary: An API for using the Amazon Flexible Payment Service (FPS).
98
- test_files:
99
- - spec/integrations/get_account_activity_spec.rb
100
- - spec/integrations/get_tokens_spec.rb
101
- - spec/units/get_pipeline_spec.rb
102
- - spec/units/get_results_spec.rb
103
- - spec/units/ipn_request_spec.rb
104
- - spec/units/pay_spec.rb
105
- - spec/integrations/integrations_helper.rb
106
- - spec/spec_helper.rb
107
- - spec/units/units_helper.rb
52
+ summary: AWS FPS API
53
+ test_files: []
54
+
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2007-2009 Tyler Hunt
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,91 +0,0 @@
1
- Remit
2
- =====
3
-
4
- This API provides access to the Amazon Flexible Payment Service (FPS). After
5
- trying to get the SOAP version of the API written, I began working on this REST
6
- version to provide a cohesive means of access to all of the functionality of
7
- the FPS without having to get dirty dealing with SOAP requests.
8
-
9
- I hope you enjoy using it as much as I've enjoyed writing it. I'm interested to
10
- hear what sort of uses you find for it. If you find any bugs, let me know (or
11
- better yet, submit a patch).
12
-
13
-
14
- Sandbox
15
- -------
16
-
17
- Amazon provides a testing environment for the FPS called a sandbox. You may
18
- (and should) use the sandbox while testing your application. It can be enabled
19
- by passing a value of true to the last argument of the API constructor.
20
-
21
-
22
- Getting Started
23
- ---------------
24
-
25
- The following example shows how to load up the API, initialize the service, and
26
- make a simple call to get the tokens stored on the account:
27
-
28
- gem 'remit'
29
- require 'remit'
30
-
31
- ACCESS_KEY = '<your AWS access key>'
32
- SECRET_KEY = '<your AWS secret key>'
33
-
34
- # connect using the API's sandbox mode
35
- remit = Remit::API.new(ACCESS_KEY, SECRET_KEY, true)
36
-
37
- response = remit.get_tokens
38
- puts response.tokens.first.token_id
39
-
40
-
41
- Using with Rails
42
- ----------------
43
-
44
- To use Remit in a Rails application, you must first specify a dependency on the
45
- Remit gem in your config/environment.rb file:
46
-
47
- config.gem 'remit', :version => '~> 0.0.1'
48
-
49
- Then you should create an initializer to configure your Amazon keys. Create the
50
- file config/initializers/remit.rb with the following contents:
51
-
52
- config_file = File.join(Rails.root, 'config', 'amazon_fps.yml')
53
- config = YAML.load_file(config_file)[RAILS_ENV].symbolize_keys
54
-
55
- FPS_ACCESS_KEY = config[:access_key]
56
- FPS_SECRET_KEY = config[:secret_key]
57
-
58
- Then create the YAML file config/amazon_fps.yml:
59
-
60
- development: &sandbox
61
- access_key: <your sandbox access key>
62
- secret_key: <your sandbox secret key>
63
-
64
- test:
65
- <<: *sandbox
66
-
67
- production:
68
- access_key: <your access key>
69
- secret_key: <your secret key>
70
-
71
- To instantiate and use the Remit API in your application, you could define a
72
- method in your ApplicationController like this:
73
-
74
- def remit
75
- @remit ||= begin
76
- sandbox = !Rails.env.production?
77
- Remit::API.new(FPS_ACCESS_KEY, FPS_SECRET_KEY, sandbox)
78
- end
79
- end
80
-
81
-
82
- Sites Using Remit
83
- -----------------
84
-
85
- The following production sites are currently using Remit:
86
-
87
- * http://www.storenvy.com/
88
- * http://www.obsidianportal.com/
89
-
90
-
91
- Copyright (c) 2007-2009 Tyler Hunt, released under the MIT license
@@ -1,127 +0,0 @@
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
-
12
- gem 'pboling-relax', '0.0.7.1'
13
- require 'relax'
14
-
15
- require 'remit/common'
16
- require 'remit/data_types'
17
- require 'remit/error_codes'
18
- require 'remit/ipn_request'
19
- require 'remit/get_pipeline'
20
- require 'remit/pipeline_response'
21
-
22
- require 'remit/operations/cancel_token'
23
- require 'remit/operations/discard_results'
24
- require 'remit/operations/fund_prepaid'
25
- require 'remit/operations/get_account_activity'
26
- require 'remit/operations/get_account_balance'
27
- require 'remit/operations/get_all_credit_instruments'
28
- require 'remit/operations/get_all_prepaid_instruments'
29
- require 'remit/operations/get_debt_balance'
30
- require 'remit/operations/get_outstanding_debt_balance'
31
- require 'remit/operations/get_payment_instruction'
32
- require 'remit/operations/get_prepaid_balance'
33
- require 'remit/operations/get_results'
34
- require 'remit/operations/get_token_by_caller'
35
- require 'remit/operations/get_token_usage'
36
- require 'remit/operations/get_tokens'
37
- require 'remit/operations/get_total_prepaid_liability'
38
- require 'remit/operations/get_transaction'
39
- require 'remit/operations/install_payment_instruction'
40
- require 'remit/operations/pay'
41
- require 'remit/operations/refund'
42
- require 'remit/operations/reserve'
43
- require 'remit/operations/retry_transaction'
44
- require 'remit/operations/settle'
45
- require 'remit/operations/settle_debt'
46
- require 'remit/operations/subscribe_for_caller_notification'
47
- require 'remit/operations/unsubscribe_for_caller_notification'
48
- require 'remit/operations/write_off_debt'
49
-
50
- module Remit
51
- class API < Relax::Service
52
- include CancelToken
53
- include DiscardResults
54
- include FundPrepaid
55
- include GetAccountActivity
56
- include GetAccountBalance
57
- include GetAllCreditInstruments
58
- include GetAllPrepaidInstruments
59
- include GetDebtBalance
60
- include GetOutstandingDebtBalance
61
- include GetPaymentInstruction
62
- include GetPipeline
63
- include GetPrepaidBalance
64
- include GetResults
65
- include GetTokenUsage
66
- include GetTokens
67
- include GetTokenByCaller
68
- include GetTotalPrepaidLiability
69
- include GetTransaction
70
- include InstallPaymentInstruction
71
- include Pay
72
- include Refund
73
- include Reserve
74
- include RetryTransaction
75
- include Settle
76
- include SettleDebt
77
- include SubscribeForCallerNotification
78
- include UnsubscribeForCallerNotification
79
- include WriteOffDebt
80
-
81
- API_ENDPOINT = 'https://fps.amazonaws.com/'.freeze
82
- API_SANDBOX_ENDPOINT = 'https://fps.sandbox.amazonaws.com/'.freeze
83
- PIPELINE_URL = 'https://authorize.payments.amazon.com/cobranded-ui/actions/start'.freeze
84
- PIPELINE_SANDBOX_URL = 'https://authorize.payments-sandbox.amazon.com/cobranded-ui/actions/start'.freeze
85
- API_VERSION = Date.new(2008, 9, 17).to_s.freeze
86
- SIGNATURE_VERSION = 1.freeze
87
-
88
- attr_reader :access_key
89
- attr_reader :secret_key
90
- attr_reader :pipeline_url
91
-
92
- def initialize(access_key, secret_key, sandbox=false)
93
- @access_key = access_key
94
- @secret_key = secret_key
95
- @pipeline_url = sandbox ? PIPELINE_SANDBOX_URL : PIPELINE_URL
96
-
97
- super(sandbox ? API_SANDBOX_ENDPOINT : API_ENDPOINT)
98
- end
99
-
100
- def new_query(query={})
101
- SignedQuery.new(@endpoint, @secret_key, query)
102
- end
103
- private :new_query
104
-
105
- def default_query
106
- new_query({
107
- :AWSAccessKeyId => @access_key,
108
- :SignatureVersion => SIGNATURE_VERSION,
109
- :Version => API_VERSION,
110
- :Timestamp => Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
111
- })
112
- end
113
- private :default_query
114
-
115
- def query(request)
116
- query = super
117
- query[:Signature] = sign(query)
118
- query
119
- end
120
- private :query
121
-
122
- def sign(values)
123
- SignedQuery.signature(@secret_key,values)
124
- end
125
- private :sign
126
- end
127
- end
@@ -1,110 +0,0 @@
1
- require 'base64'
2
- require 'erb'
3
- require 'uri'
4
-
5
- require 'rubygems'
6
- require 'relax'
7
-
8
- module Remit
9
- class Request < Relax::Request
10
- def self.action(name)
11
- parameter :action, :value => name
12
- end
13
-
14
- def convert_key(key)
15
- key.to_s.gsub(/(^|_)(.)/) { $2.upcase }.to_sym
16
- end
17
- protected :convert_key
18
- end
19
-
20
- class BaseResponse < Relax::Response
21
- def node_name(name, namespace=nil)
22
- super(name.to_s.gsub(/(^|_)(.)/) { $2.upcase }, namespace)
23
- end
24
- end
25
-
26
- class Response < BaseResponse
27
- parameter :request_id
28
-
29
- attr_accessor :errors
30
- attr_accessor :xml
31
-
32
- def initialize(xml)
33
- super
34
-
35
- @xml = xml
36
- @errors = []
37
- if is?(:Response) && has?(:Errors)
38
- @errors = elements(:Errors).collect do |error|
39
- Error.new(error)
40
- end
41
- else
42
- @errors = elements('Errors/Errors').collect do |error|
43
- ServiceError.new(error)
44
- end unless successful?
45
- end
46
- end
47
-
48
- def successful?
49
- @errors.empty?
50
- end
51
-
52
- def node_name(name, namespace=nil)
53
- super(name.to_s.split('/').collect{ |tag|
54
- tag.gsub(/(^|_)(.)/) { $2.upcase }
55
- }.join('/'), namespace)
56
- end
57
- end
58
-
59
- #do we really need to pass in a uri and query params? Can't we just pass in the uri?
60
- class SignedQuery < Relax::Query
61
- def initialize(uri, secret_key, query={})
62
- super(query)
63
- @uri = URI.parse(uri.to_s)
64
- parse_uri #values in the uri take precedence over the ones in the query
65
- @secret_key = secret_key
66
- end
67
-
68
- def sign
69
- delete(signature_key)
70
- store(signature_key, signature)
71
- end
72
-
73
- def to_s(signed=true)
74
- sign if signed
75
- super()
76
- end
77
-
78
- def signature
79
- self.class.signature(@secret_key,self)
80
- end
81
-
82
- def signature_key
83
- :awsSignature
84
- end
85
-
86
- def parse_uri
87
- if @uri.query
88
- @uri.query.split('&').each do |parameter|
89
- key, value = parameter.split('=', 2)
90
- self[key] = self.class.unescape_value(value)
91
- end
92
- end
93
- end
94
- private :parse_uri
95
-
96
- class << self
97
-
98
- def signature(secret_key,hashable = {})
99
- keys = hashable.keys.sort { |a, b| a.to_s.downcase <=> b.to_s.downcase }
100
-
101
- signature = keys.inject('') do |signature, key|
102
- value = hashable[key]
103
- signature += key.to_s + value.to_s if value
104
- end
105
-
106
- Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, secret_key, signature)).strip
107
- end
108
- end
109
- end
110
- end