Class: PayPal::Api

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/paypal/api.rb

Constant Summary collapse

SANDBOX_APP_ID =
'APP-80W284485P519543T'
SITE_ENDPOINTS =
{
  :sandbox => "https://www.sandbox.paypal.com/webscr",
  :production => "https://www.paypal.com/webscr"
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_idObject

Return application id



44
45
46
# File 'lib/paypal/api.rb', line 44

def app_id
  @app_id
end

#emailObject

The seller e-mail. Will be used to verify IPN.



40
41
42
# File 'lib/paypal/api.rb', line 40

def email
  @email
end

#passwordObject

Set PayPal’s API password.



28
29
30
# File 'lib/paypal/api.rb', line 28

def password
  @password
end

#sandboxObject

Define if requests should be made to PayPal’s sandbox environment. This is specially useful when running on development or test mode.

PayPal::Api.sandbox = true


20
21
22
# File 'lib/paypal/api.rb', line 20

def sandbox
  @sandbox
end

#seller_idObject

Set seller id. Will be used to verify IPN.



36
37
38
# File 'lib/paypal/api.rb', line 36

def seller_id
  @seller_id
end

#signatureObject

Set PayPal’s API signature.



32
33
34
# File 'lib/paypal/api.rb', line 32

def signature
  @signature
end

#usernameObject

Set PayPal’s API username.



24
25
26
# File 'lib/paypal/api.rb', line 24

def username
  @username
end

Class Method Details

.configure(&block) ⇒ Object

Set PayPal’s API attributes

PayPal::Api.configure do |config|

config.username = "[email protected]"
config.password = "testing"
config.signature = "AAAAAAA"
config.email = "[email protected]"

end



55
56
57
# File 'lib/paypal/api.rb', line 55

def configure(&block)
  instance.configure(&block)
end

.environmentObject



63
64
65
# File 'lib/paypal/api.rb', line 63

def environment
  instance.environment
end

.sandbox=(testing) ⇒ Object



59
60
61
# File 'lib/paypal/api.rb', line 59

def sandbox=(testing)
  instance.sandbox = testing
end

.site_endpointObject



67
68
69
# File 'lib/paypal/api.rb', line 67

def site_endpoint
  SITE_ENDPOINTS[environment]
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (PayPal::Api)

    the object that the method was called on



72
73
74
# File 'lib/paypal/api.rb', line 72

def configure(&block)
  yield self
end

#environmentObject

Return a name for current environment mode (sandbox or production).



84
85
86
# File 'lib/paypal/api.rb', line 84

def environment
  sandbox? ? :sandbox : :production
end

#sandbox?Boolean

Detect if sandbox mode is enabled.

Returns:

  • (Boolean)


78
79
80
# File 'lib/paypal/api.rb', line 78

def sandbox?
  sandbox == true
end