Module: EZPaypal::Config

Defined in:
lib/config.rb

Class Method Summary collapse

Class Method Details

.EndPointObject



14
15
16
# File 'lib/config.rb', line 14

def self.EndPoint
  @endpoint
end

.SettingObject



7
8
9
# File 'lib/config.rb', line 7

def self.Setting
  @setting
end

.Setup(options) ⇒ Object

Setup config

Parameters:

  • options (Hash)

    { “user”, “password”, “signature”,

    “version”, “mode” => “sandbox / live”, “customer_service_tel”}



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
# File 'lib/config.rb', line 23

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