Class: Paypal::AdaptivePaymentsRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/paypal_api/apis/adaptive_payments.rb

Constant Summary

Constants inherited from Request

Request::PAYPAL_VERSION

Instance Attribute Summary collapse

Attributes inherited from Request

#error_message, #payload, #test_request

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#initialize, #make, #paypal_endpoint_with_defaults, #request_host, #request_string, required_keys, sequential_keys, #sequentials_string, #valid?

Methods included from Formatters

#escape_uri_component

Constructor Details

This class inherits a constructor from Paypal::Request

Instance Attribute Details

#ip_addressObject

customize validation here



81
82
83
# File 'lib/paypal_api/apis/adaptive_payments.rb', line 81

def ip_address
  @ip_address
end

Class Method Details

.api_endpointObject



83
84
85
# File 'lib/paypal_api/apis/adaptive_payments.rb', line 83

def self.api_endpoint
  "https://svcs.paypal.com/AdaptivePayments/#{api_method.capitalize}"
end

.api_sandbox_endpointObject



87
88
89
# File 'lib/paypal_api/apis/adaptive_payments.rb', line 87

def self.api_sandbox_endpoint
  "https://svcs.sandbox.paypal.com/AdaptivePayments/#{api_method.capitalize}"
end

Instance Method Details

#headersObject



91
92
93
94
95
96
97
98
99
100
101
# File 'lib/paypal_api/apis/adaptive_payments.rb', line 91

def headers
  {
    "X-PAYPAL-SECURITY-USERID" => user,
    "X-PAYPAL-SECURITY-PASSWORD" => password,
    "X-PAYPAL-SECURITY-SIGNATURE" => signature,
    "X-PAYPAL-DEVICE-IPADDRESS" => @ip_address,
    "X-PAYPAL-REQUEST-DATA-FORMAT" => "NV",
    "X-PAYPAL-RESPONSE-DATA-FORMAT" => "NV",
    "X-PAYPAL-APPLICATION-ID" => application_id
  }
end

#make_requestObject



107
108
109
110
111
112
113
# File 'lib/paypal_api/apis/adaptive_payments.rb', line 107

def make_request
  if @ip_address.nil?
    throw Paypal::InvalidRequest, "need an ip address"
  else
    super
  end
end

#process_response(response) ⇒ Object



103
104
105
# File 'lib/paypal_api/apis/adaptive_payments.rb', line 103

def process_response(response)
  return AdaptivePaymentsResponse.new(response)
end

#to_key(symbol) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/paypal_api/apis/adaptive_payments.rb', line 115

def to_key(symbol)
  if symbol.is_a?(String)
    return symbol
  else
    case symbol
    when :request_envelope_error_language then
      return "requestEnvelope.errorLanguage"
    # when :reverse_all_parallel_payments_on_error then
    #   return "reverseAllParallelPaymentsonError" # may just be a typo in docs, need to test
    when :request_envelope_detail_level then
      return "requestEnvelope.detailLevel"
    when :sender_use_credentials
      return "sender.useCredentials"
    when :method
      return "METHOD"
    else
      #camelcaps but first letter is lowercase
      return Paypal::Api.symbol_to_lower_camel(symbol)
    end
  end
end