Class: Yukon::PaymentProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/yukon/payment_processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(seller_email) ⇒ PaymentProcessor

Returns a new instance of PaymentProcessor.



4
5
6
# File 'lib/yukon/payment_processor.rb', line 4

def initialize(seller_email)
  @gateway = PaymentGateway.create(seller_email)      
end

Instance Method Details

#do_express_checkout_payment(price, ip, token, payer_id) ⇒ Object

Part of Web Request 2

Step 3 : DoExpressCheckoutPayment

Arguments

price : Amount to be charged in cents ip, token and payer_id Returns PaypalExpressResponse object



66
67
68
69
70
71
# File 'lib/yukon/payment_processor.rb', line 66

def do_express_checkout_payment(price, ip, token, payer_id)      
  @gateway.purchase(price,          
                    ip:       ip, 
                    token:    token,
                    payer_id: payer_id)
end

#get_express_checkout_details(token) ⇒ Object

Part of Web Request 2

Step 2 : GetExpressCheckoutDetails

Argument - token in string format

Returns : details



52
53
54
# File 'lib/yukon/payment_processor.rb', line 52

def get_express_checkout_details(token)
  @gateway.details_for(token)
end

#redirect_url_for(response) ⇒ Object

Part of Web Request 1

End of Step 1 : Redirect to Paypal URL : args - response

Argument : PaypalExpressResponse

Returns URL : www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-5TC81926SR152035B



40
41
42
# File 'lib/yukon/payment_processor.rb', line 40

def redirect_url_for(response)
  @gateway.redirect_url_for(response.token)    
end

#set_express_checkout(price, ip, return_url, cancel_return_url, custom) ⇒ Object

Part of Web Request 1

Step 1 : SetExpressCheckout

price : Amount to be charged in cents ip : Buyer IP address return_url : URL to return after completing the purchase cancel_return_url : URL to return if purchase is cancelled notify_url : IPN notification URL (optional) custom : custom variable

Returns : PaypalExpressResponse object



22
23
24
25
26
27
28
29
30
# File 'lib/yukon/payment_processor.rb', line 22

def set_express_checkout(price, ip, return_url, cancel_return_url, custom)
  response = @gateway.setup_purchase(price,
                                     ip:                   ip,
                                     return_url:           return_url,
                                     cancel_return_url:    cancel_return_url,
                                     allow_guest_checkout: true,
                                     custom:               custom)        
  response
end