ez_paypal 1.0.0
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.
- data/.gitignore +41 -0
 - data/README.md +136 -0
 - data/doc/EZPaypal.html +124 -0
 - data/doc/EZPaypal/Cart.html +125 -0
 - data/doc/EZPaypal/Cart/OneTimePurchaseCart.html +621 -0
 - data/doc/EZPaypal/Cart/RecurringProfile.html +278 -0
 - data/doc/EZPaypal/Cart/RecurringPurchaseCart.html +434 -0
 - data/doc/EZPaypal/Config.html +353 -0
 - data/doc/EZPaypal/Helper.html +296 -0
 - data/doc/EZPaypal/Request.html +926 -0
 - data/doc/EZPaypal/Response.html +678 -0
 - data/doc/_index.html +93 -0
 - data/doc/class_list.html +47 -0
 - data/doc/css/common.css +1 -0
 - data/doc/css/full_list.css +55 -0
 - data/doc/css/style.css +322 -0
 - data/doc/file.README.html +226 -0
 - data/doc/file_list.html +49 -0
 - data/doc/frames.html +13 -0
 - data/doc/index.html +226 -0
 - data/doc/js/app.js +205 -0
 - data/doc/js/full_list.js +173 -0
 - data/doc/js/jquery.js +16 -0
 - data/doc/method_list.html +46 -0
 - data/doc/top-level-namespace.html +95 -0
 - data/ez_paypal.gemspec +32 -0
 - data/lib/config.rb +55 -0
 - data/lib/core/data.rb +241 -0
 - data/lib/core/helper.rb +34 -0
 - data/lib/core/request.rb +159 -0
 - data/lib/core/response.rb +76 -0
 - data/lib/ez_paypal.rb +5 -0
 - data/lib/ez_paypal/version.rb +3 -0
 - metadata +129 -0
 
| 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'json'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'cgi'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require File.expand_path('../../config', __FILE__)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require File.expand_path('../helper', __FILE__)
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module EZPaypal
         
     | 
| 
      
 7 
     | 
    
         
            +
              class Response < HashWithIndifferentAccess
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                # Constructor for Response object, take string response from paypal api server as param
         
     | 
| 
      
 10 
     | 
    
         
            +
                # @param [String/Hash] response as a query string or hash including
         
     | 
| 
      
 11 
     | 
    
         
            +
                #                     { "TOKEN", "PAYERID", "TIMESTAMP", "CORRELATIONID", "ACK", "VERSION", "BUILD",
         
     | 
| 
      
 12 
     | 
    
         
            +
                #                     "L_ERRORCODE0", "L_SHORTMESSAGE0", "L_LONGMESSAGE0", "L_SEVERITYCODE0", ... }
         
     | 
| 
      
 13 
     | 
    
         
            +
                # @return [EZPaypal::Response < Hash] response will be encoded, content is same as param
         
     | 
| 
      
 14 
     | 
    
         
            +
                #
         
     | 
| 
      
 15 
     | 
    
         
            +
                def initialize (response)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  hash_response = EZPaypal::Helper.ConvertParamToHash(response)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  self.merge!(hash_response)
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                # Check current response is success or not
         
     | 
| 
      
 21 
     | 
    
         
            +
                # @return [Bool] true/false
         
     | 
| 
      
 22 
     | 
    
         
            +
                def success?
         
     | 
| 
      
 23 
     | 
    
         
            +
                  return self["ACK"].downcase == "success"
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                # Get current error message
         
     | 
| 
      
 27 
     | 
    
         
            +
                # @return [Hash] the error messages and error codes in hash array
         
     | 
| 
      
 28 
     | 
    
         
            +
                #               example return obj: {"error_codes" => [], "severity_codes"=[],
         
     | 
| 
      
 29 
     | 
    
         
            +
                #                                   "short_messages" =[], "long_messages" =[]}
         
     | 
| 
      
 30 
     | 
    
         
            +
                def errors
         
     | 
| 
      
 31 
     | 
    
         
            +
                  error_codes = []
         
     | 
| 
      
 32 
     | 
    
         
            +
                  severity_codes = []
         
     | 
| 
      
 33 
     | 
    
         
            +
                  short_messages = []
         
     | 
| 
      
 34 
     | 
    
         
            +
                  long_messages = []
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  self.each do |key, value|
         
     | 
| 
      
 37 
     | 
    
         
            +
                    if key.match(/^L_ERRORCODE/)
         
     | 
| 
      
 38 
     | 
    
         
            +
                      error_codes.push(value)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
                    if key.match(/^L_SEVERITYCODE/)
         
     | 
| 
      
 41 
     | 
    
         
            +
                      severity_codes.push(value)
         
     | 
| 
      
 42 
     | 
    
         
            +
                    end
         
     | 
| 
      
 43 
     | 
    
         
            +
                    if key.match(/^L_SHORTMESSAGE/)
         
     | 
| 
      
 44 
     | 
    
         
            +
                      short_messages.push(value)
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
                    if key.match(/^L_LONGMESSAGE/)
         
     | 
| 
      
 47 
     | 
    
         
            +
                      long_messages.push(value)
         
     | 
| 
      
 48 
     | 
    
         
            +
                    end
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  error_messages = {"error_codes" => error_codes, "severity_codes" => severity_codes,
         
     | 
| 
      
 52 
     | 
    
         
            +
                                    "short_messages" => short_messages, "long_messages" => long_messages}
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                  return error_messages
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                # Get current checkout url to redirect user to, only works if token is obtained
         
     | 
| 
      
 58 
     | 
    
         
            +
                # @return [String] paypal checkout url to redirect user to
         
     | 
| 
      
 59 
     | 
    
         
            +
                def getCheckoutURL
         
     | 
| 
      
 60 
     | 
    
         
            +
                  EZPaypal::Request.GetCheckoutURL(self["TOKEN"]) if success?
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                # Get current checkout details, only works if token is obtained
         
     | 
| 
      
 64 
     | 
    
         
            +
                # @return [Hash] checkout details associated with the given token
         
     | 
| 
      
 65 
     | 
    
         
            +
                def getCheckoutDetails
         
     | 
| 
      
 66 
     | 
    
         
            +
                  EZPaypal::Request.GetCheckoutDetails(self["TOKEN"])
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                # Confirm purchase, only works if token and payer_id is obtained
         
     | 
| 
      
 70 
     | 
    
         
            +
                # @return [Hash] payment details associated with the given token and payer_id
         
     | 
| 
      
 71 
     | 
    
         
            +
                def confirmPurchase
         
     | 
| 
      
 72 
     | 
    
         
            +
                  EZPaypal::Request.ConfirmPurchase(self["TOKEN"], self["PAYERID"])
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/ez_paypal.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,129 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: ez_paypal
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Tianyu Huang
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-04-26 00:00:00.000000000 Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 15 
     | 
    
         
            +
              name: ez_http
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: 1.0.4
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 25 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 26 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: 1.0.4
         
     | 
| 
      
 30 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 31 
     | 
    
         
            +
              name: json
         
     | 
| 
      
 32 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 33 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 34 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 35 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 36 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 37 
     | 
    
         
            +
                    version: 1.6.6
         
     | 
| 
      
 38 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 39 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 40 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 41 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 42 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 43 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 44 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 45 
     | 
    
         
            +
                    version: 1.6.6
         
     | 
| 
      
 46 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 47 
     | 
    
         
            +
              name: activesupport
         
     | 
| 
      
 48 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 49 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 50 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 51 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 52 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 53 
     | 
    
         
            +
                    version: 3.2.2
         
     | 
| 
      
 54 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 55 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 56 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 57 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: 3.2.2
         
     | 
| 
      
 62 
     | 
    
         
            +
            description: Paypal express checkout plugin
         
     | 
| 
      
 63 
     | 
    
         
            +
            email:
         
     | 
| 
      
 64 
     | 
    
         
            +
            - tianhsky@yahoo.com
         
     | 
| 
      
 65 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 66 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 67 
     | 
    
         
            +
            extra_rdoc_files:
         
     | 
| 
      
 68 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 69 
     | 
    
         
            +
            - doc/index.html
         
     | 
| 
      
 70 
     | 
    
         
            +
            files:
         
     | 
| 
      
 71 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 72 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 73 
     | 
    
         
            +
            - doc/EZPaypal.html
         
     | 
| 
      
 74 
     | 
    
         
            +
            - doc/EZPaypal/Cart.html
         
     | 
| 
      
 75 
     | 
    
         
            +
            - doc/EZPaypal/Cart/OneTimePurchaseCart.html
         
     | 
| 
      
 76 
     | 
    
         
            +
            - doc/EZPaypal/Cart/RecurringProfile.html
         
     | 
| 
      
 77 
     | 
    
         
            +
            - doc/EZPaypal/Cart/RecurringPurchaseCart.html
         
     | 
| 
      
 78 
     | 
    
         
            +
            - doc/EZPaypal/Config.html
         
     | 
| 
      
 79 
     | 
    
         
            +
            - doc/EZPaypal/Helper.html
         
     | 
| 
      
 80 
     | 
    
         
            +
            - doc/EZPaypal/Request.html
         
     | 
| 
      
 81 
     | 
    
         
            +
            - doc/EZPaypal/Response.html
         
     | 
| 
      
 82 
     | 
    
         
            +
            - doc/_index.html
         
     | 
| 
      
 83 
     | 
    
         
            +
            - doc/class_list.html
         
     | 
| 
      
 84 
     | 
    
         
            +
            - doc/css/common.css
         
     | 
| 
      
 85 
     | 
    
         
            +
            - doc/css/full_list.css
         
     | 
| 
      
 86 
     | 
    
         
            +
            - doc/css/style.css
         
     | 
| 
      
 87 
     | 
    
         
            +
            - doc/file.README.html
         
     | 
| 
      
 88 
     | 
    
         
            +
            - doc/file_list.html
         
     | 
| 
      
 89 
     | 
    
         
            +
            - doc/frames.html
         
     | 
| 
      
 90 
     | 
    
         
            +
            - doc/index.html
         
     | 
| 
      
 91 
     | 
    
         
            +
            - doc/js/app.js
         
     | 
| 
      
 92 
     | 
    
         
            +
            - doc/js/full_list.js
         
     | 
| 
      
 93 
     | 
    
         
            +
            - doc/js/jquery.js
         
     | 
| 
      
 94 
     | 
    
         
            +
            - doc/method_list.html
         
     | 
| 
      
 95 
     | 
    
         
            +
            - doc/top-level-namespace.html
         
     | 
| 
      
 96 
     | 
    
         
            +
            - ez_paypal.gemspec
         
     | 
| 
      
 97 
     | 
    
         
            +
            - lib/config.rb
         
     | 
| 
      
 98 
     | 
    
         
            +
            - lib/core/data.rb
         
     | 
| 
      
 99 
     | 
    
         
            +
            - lib/core/helper.rb
         
     | 
| 
      
 100 
     | 
    
         
            +
            - lib/core/request.rb
         
     | 
| 
      
 101 
     | 
    
         
            +
            - lib/core/response.rb
         
     | 
| 
      
 102 
     | 
    
         
            +
            - lib/ez_paypal.rb
         
     | 
| 
      
 103 
     | 
    
         
            +
            - lib/ez_paypal/version.rb
         
     | 
| 
      
 104 
     | 
    
         
            +
            homepage: http://rubygems.org/gems/ez_paypal
         
     | 
| 
      
 105 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 106 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 107 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 108 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 109 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 110 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 111 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 112 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 113 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 114 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 115 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 116 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 117 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 118 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 119 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 120 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 121 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 122 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 123 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 124 
     | 
    
         
            +
            rubygems_version: 1.8.22
         
     | 
| 
      
 125 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 126 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 127 
     | 
    
         
            +
            summary: Paypal express checkout plugin
         
     | 
| 
      
 128 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 129 
     | 
    
         
            +
            has_rdoc: 
         
     |