active_paypal_adaptive_accounts 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 21a8d3353c895bd60dca6db877849f73d91696a0
4
+ data.tar.gz: ff9b650c06e242d8864e955c37692e4ff2fee5f9
5
+ SHA512:
6
+ metadata.gz: d2eeeed6ae060477636442e7d745b01448f2e49a9620e52f4bd27d35d1917545710721f3830a1440941f4726b815e05a9b1aa5e55de57e1942c7b8efeda3d13f
7
+ data.tar.gz: 30c37eab547f0df3c7f010ada7189b421faf5c855aae85ae6e47cb3a38d698730a6447b26e61502b2d00a1cac58032977d0755289b4699bf76c3691d7631e0da
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.0.1 (2013-06-01)
2
+
3
+ - Initial Release.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Jonathan Lancar
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 PURPOa AND
17
+ NONINFRINGEMENT. IN NO EVENT SaALL 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.
data/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # Active PayPal Adaptive Accounts
2
+
3
+ This library is meant to interface with PayPal's Adaptive Payment Gateway.
4
+
5
+ [Active Merchant]:http://www.activemerchant.org
6
+
7
+ See the [Active PayPal Adaptive Accounts](https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/pp_adaptiveaccounts.pdf) manual.
8
+
9
+ ## Supported
10
+
11
+ * Get Verified Status API
12
+
13
+ ## Installation
14
+
15
+ Add the following line to your app's Gemfile:
16
+
17
+ gem "active_paypal_adaptive_accounts"
18
+
19
+ bundle install
20
+
21
+ ### Init
22
+ ```ruby
23
+ gateway = ActiveMerchant::Billing::PaypalAdaptiveAccounts.new(
24
+ login: "acutio_1313133342_biz_api1.gmail.com",
25
+ password: "1255043567",
26
+ signature: "Abg0gYcQlsdkls2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf",
27
+ appid: "APP-80W284485P519543T"
28
+ )
29
+ ```
30
+
31
+ ### Paypal Account Status Verification
32
+ ```ruby
33
+ response = gateway.get_verified_status (
34
+ email: "Seller Email Address",
35
+ account: {
36
+ email: "Seller Email",
37
+ phone: "Seller Phone Number",
38
+ id: "Seller Paypal ID"
39
+ }
40
+ )
41
+ ```
42
+
43
+ See the implementation of ActiveMerchant::Billing::PaypalAdaptivePayment#build_adaptive_set_payment_options_request
44
+ for all available options and [Operation SetPaymentOptions API](https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_AdaptivePayments.pdf)
45
+ for a description of them.
46
+
47
+ ## Testing
48
+
49
+ First modify the `test/fixtures.yml` to fit your app credentials (You
50
+ will need at least a PayPal developer account).
51
+
52
+ After that you can run them like this:
53
+
54
+ $ ruby -Ilib test/test_paypal_adaptive_accounts.rb
55
+
56
+ ## Debugging
57
+
58
+ Use either gateway.debug or response.debug this gives you the json
59
+ response, the xml sent and the url it was posted to.
60
+
61
+ From the Rails console it can be accessed like such:
62
+
63
+ ActiveMerchant::Billing::PaypalAdaptiveAccounts
64
+
65
+ `PaypalAdaptiveAccounts#debug` or `AdaptiveAccountsResponse#debug` return the raw
66
+ xml request, raw json response and the URL of the endpoint.
67
+
68
+ ## TODO
69
+
70
+ * Documentation.
71
+ * Implementing Other Features of AdaptiveAccounts
72
+
73
+ ## Contributors
74
+
75
+ * Jonathan Lancar (<http://www.genesx.com/>)
76
+
77
+ ## This Gem is heavily based on the work of:
78
+ * [Jose Pablo Barrantes](<http://jpablobr.com/>)
79
+ - [active_paypal_adaptive_payment](https://github.com/jpablobr/active_paypal_adaptive_payment)
80
+
81
+ ## Other previous contributors where some code was taken from.
82
+ * [Tommy Chheng](http://tommy.chheng.com)
83
+ - [Paypal Adaptive Ruby Gem Released](http://tommy.chheng.com/2009/12/29/paypal-adaptive-ruby-gem-released/)
84
+ - [paypal_adaptive](https://github.com/tc/paypal_adaptive)
85
+
86
+ * [lamp (Matt)](https://github.com/lamp)
87
+ - [paypal_adaptive_gateway](https://github.com/lamp/paypal_adaptive_gateway)
88
+
89
+ * [sentientmonkey (Scott Windsor)](https://github.com/sentientmonkey)
90
+ - [active_merchant](https://github.com/sentientmonkey/active_merchant)
91
+
92
+ * [sijokg](https://github.com/sijokg)
93
+ - [active_merchant](https://github.com/sijokg/active_merchant)
94
+
95
+ ## Note on Patches/Pull Requests:
96
+
97
+ * Fork the project.
98
+ * Make your feature addition or bug fix.
99
+ * Send me a pull request. Bonus points for topic branches.
100
+
101
+ ## Copyright:
102
+
103
+ (The MIT License)
104
+
105
+ Copyright 2011 Jonathan Lancar. MIT Licence, so go for it.
106
+
107
+ Permission is hereby granted, free of charge, to any person obtaining a
108
+ copy of this software and associated documentation files (the
109
+ 'Software'), to deal in the Software without restriction, including
110
+ without limitation the rights to use, copy, modify, merge, publish,
111
+ distribute, sublicense, an d/or sell copies of the Software, and to
112
+ permit persons to whom the Software is furnished to do so, subject to
113
+ the following conditions:
114
+
115
+ The above copyright notice and this permission notice shall be included
116
+ in all copies or substantial portions of the Software.
117
+
118
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS
119
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
120
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
121
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
122
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
123
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
124
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,48 @@
1
+ require 'multi_json'
2
+ require 'hashie'
3
+
4
+ module ActiveMerchant
5
+ module Billing
6
+ class AdaptiveAccountsResponse < Response
7
+
8
+ SUCCESS = 'Success'.freeze
9
+
10
+ attr_reader :json, :request, :action, :response, :xml_request
11
+ alias :raw :json
12
+ alias :raw_request :xml_request
13
+
14
+ def initialize(json, xml_request = nil, action = nil)
15
+ @json = json
16
+ @response = Hashie::Rash.new(MultiJson.decode(json))
17
+ @xml_request = xml_request
18
+ @request = Hashie::Rash.from_xml(xml_request)
19
+ @action = action
20
+ end
21
+
22
+ def method_missing(method, *args, &block)
23
+ @response.send(method, *args, &block)
24
+ end
25
+
26
+ def ack
27
+ response_envelope.ack
28
+ end
29
+
30
+ def timestamp
31
+ response_envelope.timestamp
32
+ end
33
+
34
+ def build
35
+ response_envelope.build
36
+ end
37
+
38
+ def correlation_id
39
+ response_envelope.correlation_id
40
+ end
41
+ alias :correlationId :correlation_id
42
+
43
+ def success?
44
+ ack == SUCCESS
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,13 @@
1
+ class PaypalAdaptiveAccountsApiError < StandardError
2
+
3
+ attr_reader :response
4
+
5
+ def initialize response
6
+ @response = response
7
+ end
8
+
9
+ def debug
10
+ @response.inspect
11
+ end
12
+
13
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # https://github.com/tallgreentree/rash/blob/master/lib/hashie/rash.rb
3
+
4
+ require 'hashie/mash'
5
+
6
+ module Hashie
7
+ class Rash < Mash
8
+
9
+ protected
10
+
11
+ def convert_key(key)
12
+ underscore_string(key.to_s)
13
+ end
14
+
15
+ # converts a camel_cased string to a underscore string
16
+ # subs spaces with underscores, strips whitespace
17
+ # Same way ActiveSupport does string.underscore
18
+ def underscore_string(str)
19
+ str.to_s.strip.
20
+ gsub(' ', '_').
21
+ gsub(/::/, '/').
22
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
23
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
24
+ tr("-", "_").
25
+ squeeze("_").
26
+ downcase
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,97 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'money'
3
+ require File.dirname(__FILE__) + '/paypal_adaptive_accounts/ext'
4
+ require File.dirname(__FILE__) + '/paypal_adaptive_accounts/exceptions'
5
+ require File.dirname(__FILE__) + '/paypal_adaptive_accounts/adaptive_accounts_response'
6
+
7
+ module ActiveMerchant
8
+ module Billing
9
+
10
+ class PaypalAdaptiveAccounts < Gateway
11
+ TEST_URL = 'https://svcs.sandbox.paypal.com/AdaptiveAccounts/'
12
+ LIVE_URL = 'https://svcs.paypal.com/AdaptiveAccounts'
13
+
14
+ self.supported_countries = ['US']
15
+ self.homepage_url = 'http://x.com/'
16
+ self.display_name = 'Paypal Adaptive Accounts'
17
+
18
+ def initialize(options = {})
19
+ requires!(options, :login, :password, :signature, :appid)
20
+ @options = options.dup
21
+ super
22
+ end
23
+
24
+ def get_verified_status(options)
25
+ commit('GetVerifiedStatus', build_get_verfied_status_request(options))
26
+ end
27
+
28
+ def debug
29
+ {:url => @url, :request => @xml, :response => @response.json}
30
+ end
31
+
32
+ private
33
+
34
+ def build_get_verfied_status_request(options)
35
+ @xml = ''
36
+ xml = Builder::XmlMarkup.new :target => @xml, :indent => 2
37
+ xml.instruct!
38
+ xml.GetVerifiedStatus do |x|
39
+ x.requestEnvelope do |x|
40
+ x.detailLevel 'ReturnAll'
41
+ x.errorLanguage options[:error_language] ||= 'en_US'
42
+ end
43
+ x.emailAddress options[:email] if options.has_key?(:email)
44
+ x.accountIdentifier do |x|
45
+ opts = options[:account]
46
+
47
+ x.emailAddress opts[:email] if opts.has_key?(:email)
48
+ x.mobilePhoneNumber opts[:phone] if opts.has_key?(:phone)
49
+ x.accountId opts[:id] if opts.has_key?(:id)
50
+ end if options.has_key?(:account)
51
+ x.firstName options[:first_name]
52
+ x.lastName options[:last_name]
53
+ x.matchCriteria options[:match] ||= 'NAME'
54
+ end
55
+ end
56
+
57
+ def commit(action, data)
58
+ @response = AdaptiveAccountsResponse.new(post_through_ssl(action, data), data, action)
59
+ end
60
+
61
+ def post_through_ssl(action, parameters = {})
62
+ headers = {
63
+ "X-PAYPAL-REQUEST-DATA-FORMAT" => "XML",
64
+ "X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON",
65
+ "X-PAYPAL-SECURITY-USERID" => @options[:login],
66
+ "X-PAYPAL-SECURITY-PASSWORD" => @options[:password],
67
+ "X-PAYPAL-SECURITY-SIGNATURE" => @options[:signature],
68
+ "X-PAYPAL-APPLICATION-ID" => @options[:appid],
69
+ }
70
+ action_url(action)
71
+ request = Net::HTTP::Post.new(@url.path)
72
+ request.body = @xml
73
+ headers.each_pair { |k,v| request[k] = v }
74
+ request.content_type = 'text/xml'
75
+ server = Net::HTTP.new(@url.host, 443)
76
+ server.use_ssl = true
77
+ # OSX: sudo port install curl-ca-bundle
78
+ server.verify_mode = OpenSSL::SSL::VERIFY_PEER
79
+ server.ca_path = '/etc/ssl/certs' if File.exists?('/etc/ssl/certs') # Ubuntu
80
+ server.ca_file = '/opt/local/share/curl/curl-ca-bundle.crt' if File.exists?('/opt/local/share/curl/curl-ca-bundle.crt') # Mac OS X
81
+ server.start { |http| http.request(request) }.body
82
+ end
83
+
84
+ def endpoint_url
85
+ test? ? TEST_URL : LIVE_URL
86
+ end
87
+
88
+ def test?
89
+ @options[:test] || Base.gateway_mode == :test
90
+ end
91
+
92
+ def action_url(action)
93
+ @url = URI.parse(endpoint_url + action)
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+ require 'active_merchant'
3
+ require File.dirname(__FILE__) + '/active_merchant/billing/gateways/paypal_adaptive_accounts'
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_paypal_adaptive_accounts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Lancar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemerchant
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.5.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.5.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.2.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: money
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.6.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 3.6.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.10.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.10.0
83
+ description: |2
84
+ This library is meant to interface with PayPal's Adaptive Payment Gateway.
85
+ email:
86
+ - jonaphin@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - lib/active_merchant/billing/gateways/paypal_adaptive_accounts/adaptive_accounts_response.rb
92
+ - lib/active_merchant/billing/gateways/paypal_adaptive_accounts/exceptions.rb
93
+ - lib/active_merchant/billing/gateways/paypal_adaptive_accounts/ext.rb
94
+ - lib/active_merchant/billing/gateways/paypal_adaptive_accounts.rb
95
+ - lib/active_paypal_adaptive_accounts.rb
96
+ - MIT-LICENSE
97
+ - README.md
98
+ - CHANGELOG.md
99
+ homepage: http://github.com/jonaphin/active_paypal_adaptive_accounts
100
+ licenses: []
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: 1.3.6
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.0.3
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: ActiveMerchant PayPal Adaptive Accounts Library
122
+ test_files: []