Sha256: f401c6a6ca9c85a341416ca0237cc468cf8d124bec0e8c62ebe629219ecf0777

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

module EZPaypal
  module Config

    # Account setting
    @setting

    def self.Setting
      @setting
    end

    # API endpoint
    @endpoint

    def self.EndPoint
      @endpoint
    end

    # Setup config
    # @param [Hash] options = { "user", "password", "signature",
    #                         "version", "mode" => "sandbox / live",
    #                         "customer_service_tel"}
    #
    def self.Setup (options)
      # Setup account setting
      @setting={
          "USER" => options["user"],
          "PWD" => options["password"],
          "SIGNATURE" => options["signature"],
          "VERSION" => options["version"] || 84.0,
          "CUSTOMERSERVICENUMBER" => options["customer_service_tel"]
      }

      # Setup endpoint
      express_checkout_endpoint = {
          "sandbox" => "https://api-3t.sandbox.paypal.com/nvp",
          "live" => "https://api-3t.paypal.com/nvp"
      }
      set_express_checkout = {
          "sandbox" => "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout",
          "live" => "https://www.paypal.com/webscr?cmd=_express-checkout",
      }

      @endpoint ||= {}
      if (options["mode"] == 'sandbox')
        @endpoint.merge!("express_checkout_endpoint" => express_checkout_endpoint["sandbox"])
        @endpoint.merge!("express_checkout_url" => set_express_checkout["sandbox"])
      else
        @endpoint.merge!("express_checkout_endpoint" => express_checkout_endpoint["live"])
        @endpoint.merge!("express_checkout_url" => set_express_checkout["live"])
      end


    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ez_paypal-1.0.0 lib/config.rb