Class: ActiveMerchant::Billing::PaypalPermissionsGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::PaypalPermissionsGateway
- Defined in:
- lib/paypal_permissions/paypal_permissions_gateway.rb
Overview
:nodoc
Class Method Summary collapse
Instance Method Summary collapse
- #get_access_token(request_token, request_token_verifier) ⇒ Object
- #get_access_token_url ⇒ Object
- #get_advanced_personal_data(access_token, access_token_verifier) ⇒ Object
- #get_advanced_personal_data_url ⇒ Object
- #get_basic_personal_data(access_token, access_token_verifier) ⇒ Object
- #get_basic_personal_data_url ⇒ Object
- #get_permissions_url ⇒ Object
-
#initialize(options = {}) ⇒ PaypalPermissionsGateway
constructor
A new instance of PaypalPermissionsGateway.
- #redirect_user_to_paypal_url(token) ⇒ Object
- #request_permissions(callback_url, scope) ⇒ Object
- #request_permissions_url ⇒ Object
Methods included from XPPAuthorization
#paypal_encode, #x_pp_authorization_header, #x_pp_authorization_signature
Constructor Details
#initialize(options = {}) ⇒ PaypalPermissionsGateway
Returns a new instance of PaypalPermissionsGateway.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 21 def initialize( = {}) requires!(, :login, :password, :signature, :app_id) @login = .delete(:login) @password = .delete(:password) @app_id = .delete(:app_id) @api_signature = .delete(:signature) = { 'X-PAYPAL-SECURITY-USERID' => @login, 'X-PAYPAL-SECURITY-PASSWORD' => @password, 'X-PAYPAL-SECURITY-SIGNATURE' => @api_signature, 'X-PAYPAL-APPLICATION-ID' => @app_id, 'X-PAYPAL-REQUEST-DATA-FORMAT' => 'NV', 'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'NV', } get_access_token_headers = .dup get_basic_personal_data_headers = lambda { |access_token, access_token_verifier| { #'X-PAYPAL-SECURITY-USERID' => @login, #'X-PAYPAL-SECURITY-PASSWORD' => @password, #'X-PAYPAL-SECURITY-SIGNATURE' => @api_signature, 'X-PAYPAL-APPLICATION-ID' => @app_id, 'X-PAYPAL-REQUEST-DATA-FORMAT' => 'NV', 'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'NV', }.update((get_basic_personal_data_url, @login, @password, access_token, access_token_verifier)) } get_advanced_personal_data_headers = lambda { |access_token, access_token_verifier| { #'X-PAYPAL-SECURITY-USERID' => @login, #'X-PAYPAL-SECURITY-PASSWORD' => @password, #'X-PAYPAL-SECURITY-SIGNATURE' => @api_signature, 'X-PAYPAL-APPLICATION-ID' => @app_id, 'X-PAYPAL-REQUEST-DATA-FORMAT' => 'NV', 'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'NV', }.update((get_advanced_personal_data_url, @login, @password, access_token, access_token_verifier)) } @options = { :request_permissions_headers => , :get_access_token_headers => get_access_token_headers, :get_basic_personal_data_headers => get_basic_personal_data_headers, :get_advanced_personal_data_headers => get_advanced_personal_data_headers, }.update() super end |
Class Method Details
.setup {|_self| ... } ⇒ Object
16 17 18 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 16 def self.setup yield self end |
Instance Method Details
#get_access_token(request_token, request_token_verifier) ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 82 def get_access_token(request_token, request_token_verifier) query_string = build_get_access_token_query_string request_token, request_token_verifier nvp_response = ssl_get "#{get_access_token_url}?#{query_string}", @options[:get_access_token_headers] if nvp_response =~ /error\(\d+\)/ # puts "request: #{get_access_token_url}?#{query_string}\n" # puts "nvp_response: #{nvp_response}\n" end response = GetAccessTokenNVParser.parse nvp_response end |
#get_access_token_url ⇒ Object
123 124 125 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 123 def get_access_token_url test? ? URLS[:test][:get_access_token] : URLS[:live][:get_access_token] end |
#get_advanced_personal_data(access_token, access_token_verifier) ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 111 def get_advanced_personal_data(access_token, access_token_verifier) body = personal_data_post_body(GetAdvancedPersonalDataNVParser.personal_data_mappings) opts = @options[:get_advanced_personal_data_headers].call(access_token, access_token_verifier) nvp_response = ssl_post(get_advanced_personal_data_url, body, opts) if nvp_response =~ /error\(\d+\)/ # puts "request: #{get_advanced_personal_data_url} post_body:#{body}\n" # puts "nvp_response: #{nvp_response}\n" end response = GetAdvancedPersonalDataNVParser.parse nvp_response end |
#get_advanced_personal_data_url ⇒ Object
138 139 140 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 138 def get_advanced_personal_data_url test? ? URLS[:test][:get_advanced_personal_data] : URLS[:live][:get_advanced_personal_data] end |
#get_basic_personal_data(access_token, access_token_verifier) ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 99 def get_basic_personal_data(access_token, access_token_verifier) body = personal_data_post_body(GetBasicPersonalDataNVParser.personal_data_mappings) opts = @options[:get_basic_personal_data_headers].call(access_token, access_token_verifier) nvp_response = ssl_post(get_basic_personal_data_url, body, opts) if nvp_response =~ /error\(\d+\)/ # puts "request: #{get_basic_personal_data_url} post_body:#{body}\n" # puts "nvp_response: #{nvp_response}\n" end response = GetBasicPersonalDataNVParser.parse nvp_response end |
#get_basic_personal_data_url ⇒ Object
133 134 135 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 133 def get_basic_personal_data_url test? ? URLS[:test][:get_basic_personal_data] : URLS[:live][:get_basic_personal_data] end |
#get_permissions_url ⇒ Object
128 129 130 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 128 def test? ? URLS[:test][:get_permissions] : URLS[:live][:get_permissions] end |
#redirect_user_to_paypal_url(token) ⇒ Object
93 94 95 96 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 93 def redirect_user_to_paypal_url token template = test? ? URLS[:test][:redirect_user_to_paypal] : URLS[:live][:redirect_user_to_paypal] template % token end |
#request_permissions(callback_url, scope) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 66 def (callback_url, scope) query_string = callback_url, scope nvp_response = ssl_get "#{}?#{query_string}", @options[:request_permissions_headers] if nvp_response =~ /error\(\d+\)/ # puts "request: #{request_permissions_url}?#{query_string}\n" # puts "nvp_response: #{nvp_response}\n" end response = RequestPermissionsNVParser.parse nvp_response end |
#request_permissions_url ⇒ Object
77 78 79 |
# File 'lib/paypal_permissions/paypal_permissions_gateway.rb', line 77 def test? ? URLS[:test][:request_permissions] : URLS[:live][:request_permissions] end |