Class: EZPaypal::Response
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- EZPaypal::Response
- Defined in:
- lib/core/response.rb
Instance Method Summary collapse
-
#confirmPurchase ⇒ Hash
Confirm purchase, only works if token and payer_id is obtained.
-
#errors ⇒ Hash
Get current error message.
-
#getCheckoutDetails ⇒ Hash
Get current checkout details, only works if token is obtained.
-
#getCheckoutURL ⇒ String
Get current checkout url to redirect user to, only works if token is obtained.
-
#initialize(response) ⇒ EZPaypal::Response < Hash] response will be encoded, content is same as param
constructor
Constructor for Response object, take string response from paypal api server as param.
-
#success? ⇒ Bool
Check current response is success or not.
Constructor Details
#initialize(response) ⇒ EZPaypal::Response < Hash] response will be encoded, content is same as param
Constructor for Response object, take string response from paypal api server as param
15 16 17 18 |
# File 'lib/core/response.rb', line 15 def initialize (response) hash_response = EZPaypal::Helper.ConvertParamToHash(response) self.merge!(hash_response) end |
Instance Method Details
#confirmPurchase ⇒ Hash
Confirm purchase, only works if token and payer_id is obtained
71 72 73 |
# File 'lib/core/response.rb', line 71 def confirmPurchase EZPaypal::Request.ConfirmPurchase(self["TOKEN"], self["PAYERID"]) end |
#errors ⇒ Hash
Get current error message
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 |
# File 'lib/core/response.rb', line 30 def errors error_codes = [] severity_codes = [] = [] = [] self.each do |key, value| if key.match(/^L_ERRORCODE/) error_codes.push(value) end if key.match(/^L_SEVERITYCODE/) severity_codes.push(value) end if key.match(/^L_SHORTMESSAGE/) .push(value) end if key.match(/^L_LONGMESSAGE/) .push(value) end end = {"error_codes" => error_codes, "severity_codes" => severity_codes, "short_messages" => , "long_messages" => } return end |
#getCheckoutDetails ⇒ Hash
Get current checkout details, only works if token is obtained
65 66 67 |
# File 'lib/core/response.rb', line 65 def getCheckoutDetails EZPaypal::Request.GetCheckoutDetails(self["TOKEN"]) end |
#getCheckoutURL ⇒ String
Get current checkout url to redirect user to, only works if token is obtained
59 60 61 |
# File 'lib/core/response.rb', line 59 def getCheckoutURL EZPaypal::Request.GetCheckoutURL(self["TOKEN"]) if success? end |
#success? ⇒ Bool
Check current response is success or not
22 23 24 |
# File 'lib/core/response.rb', line 22 def success? return self["ACK"].downcase == "success" end |