Module: Payment
Defined Under Namespace
Classes: PaymentDetails, PurchaseDetails
Class Method Summary collapse
Instance Method Summary collapse
-
#complete_payment(params) ⇒ Object
returns a PurchaseDetails.
-
#get_gateway_payment_details(params) ⇒ Object
returns a PaymentDetails.
-
#payment_gateway ⇒ Object
private TODO this is the test paypal account, needs to come from configuration.
-
#setup_payment(params) ⇒ Object
returns a url.
Class Method Details
.gateway_creator=(creator) ⇒ Object
71 72 73 |
# File 'lib/bizLogic/payment.rb', line 71 def self.gateway_creator=(creator) @@gateway_creator = creator end |
Instance Method Details
#complete_payment(params) ⇒ Object
returns a PurchaseDetails
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bizLogic/payment.rb', line 43 def complete_payment(params) amount = params[:payment_amount].to_i if amount < 1 #TODO localise error message return PurchaseDetails.new(false, "Amount to pay must be greater than 0") else purchase = payment_gateway.purchase(amount, :ip => params[:ip], :payer_id => params[:payer_id], :token => params[:token]) return PurchaseDetails.new(purchase.success?, purchase.) end end |
#get_gateway_payment_details(params) ⇒ Object
returns a PaymentDetails
25 26 27 28 |
# File 'lib/bizLogic/payment.rb', line 25 def get_gateway_payment_details(params) details_response = payment_gateway.details_for(params[:token]) return PaymentDetails.new(details_response.success?, details_response., details_response.address) end |
#payment_gateway ⇒ Object
private TODO this is the test paypal account, needs to come from configuration
67 68 69 |
# File 'lib/bizLogic/payment.rb', line 67 def payment_gateway @payment_gateway ||= @@gateway_creator.call end |
#setup_payment(params) ⇒ Object
returns a url
14 15 16 17 18 19 20 21 22 |
# File 'lib/bizLogic/payment.rb', line 14 def setup_payment(params) amount = params[:payment_amount].to_i if amount < 1 return params[:cancel_return_url] else setup_response = payment_gateway.setup_purchase(amount, :ip => params[:ip], :return_url => params[:return_url], :cancel_return_url => params[:cancel_return_url]) return payment_gateway.redirect_url_for(setup_response.token) end end |