Module: Paypal::Ipn

Includes:
HTTParty
Defined in:
lib/paypal/ipn/ipn.rb,
lib/paypal/ipn/types/masspay.rb,
lib/paypal/ipn/variables/item.rb,
lib/paypal/ipn/variables/buyer.rb

Defined Under Namespace

Modules: Buyer, ClassMethods, Item, Masspay

Constant Summary collapse

LIVE_POSTBACK_URI =
"https://www.paypal.com/cgi-bin/webscr"
SANDBOX_POSTBACK_URI =
"https://www.sandbox.paypal.com/cgi-bin/webscr"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
# File 'lib/paypal/ipn/ipn.rb', line 8

def self.included(base)
  base.extend ClassMethods
end

.postback_uriObject



12
13
14
15
16
# File 'lib/paypal/ipn/ipn.rb', line 12

def self.postback_uri
  Paypal.environment == "live" ?
  LIVE_POSTBACK_URI :
  SANDBOX_POSTBACK_URI
end

.verify(params) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/paypal/ipn/ipn.rb', line 18

def self.verify(params)
  request_uri = URI.parse(postback_uri)
  request_uri.scheme = "https" # force https
  self.post(
    request_uri.to_s,
    :body => params.merge("cmd"=>"_notify-validate")
  ).body == "VERIFIED"
end

Instance Method Details

#payment_completed?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/paypal/ipn/ipn.rb', line 31

def payment_completed?
  payment_status == "Completed"
end

#payment_statusObject



27
28
29
# File 'lib/paypal/ipn/ipn.rb', line 27

def payment_status
  params["payment_status"] if params
end

#txn_idObject Also known as: transaction_id



35
36
37
# File 'lib/paypal/ipn/ipn.rb', line 35

def txn_id
  params["txn_id"] if params
end