Class: ActivePayment::Gateways::PaypalAdaptivePayment
- Inherits:
-
Object
- Object
- ActivePayment::Gateways::PaypalAdaptivePayment
- Includes:
- ActionDispatch::Routing, ActionView::Helpers
- Defined in:
- lib/active_payment/gateways/paypal_adaptive_payment.rb
Instance Attribute Summary collapse
-
#purchase_token ⇒ Object
Returns the value of attribute purchase_token.
-
#sales ⇒ Object
Returns the value of attribute sales.
Instance Method Summary collapse
- #external_id_from_request(request) ⇒ Object
-
#initialize ⇒ PaypalAdaptivePayment
constructor
A new instance of PaypalAdaptivePayment.
- #livemode? ⇒ Boolean
- #setup_purchase(sales) ⇒ Object
-
#verify_purchase(params) ⇒ Object
return boolean.
Constructor Details
#initialize ⇒ PaypalAdaptivePayment
12 13 14 |
# File 'lib/active_payment/gateways/paypal_adaptive_payment.rb', line 12 def initialize @gateway = ActiveMerchant::Billing::PaypalAdaptivePayment.new() end |
Instance Attribute Details
#purchase_token ⇒ Object
Returns the value of attribute purchase_token.
10 11 12 |
# File 'lib/active_payment/gateways/paypal_adaptive_payment.rb', line 10 def purchase_token @purchase_token end |
#sales ⇒ Object
Returns the value of attribute sales.
10 11 12 |
# File 'lib/active_payment/gateways/paypal_adaptive_payment.rb', line 10 def sales @sales end |
Instance Method Details
#external_id_from_request(request) ⇒ Object
38 39 40 41 42 |
# File 'lib/active_payment/gateways/paypal_adaptive_payment.rb', line 38 def external_id_from_request(request) notify = ActiveMerchant::Billing::Integrations::PaypalAdaptivePayment.notification(request.raw_post) notify.params['pay_key'] end |
#livemode? ⇒ Boolean
34 35 36 |
# File 'lib/active_payment/gateways/paypal_adaptive_payment.rb', line 34 def livemode? ActiveMerchant::Billing::Base.mode != :test end |
#setup_purchase(sales) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_payment/gateways/paypal_adaptive_payment.rb', line 16 def setup_purchase(sales) @sales = sales response = @gateway.setup_purchase(purchase_data(sales)) raise ActivePayment::InvalidGatewayResponseError.new(response) unless response.success? @purchase_token = response['payKey'] @gateway.((@purchase_token, @sales)) @gateway.redirect_url_for(response['payKey']) end |
#verify_purchase(params) ⇒ Object
return boolean
28 29 30 31 32 |
# File 'lib/active_payment/gateways/paypal_adaptive_payment.rb', line 28 def verify_purchase(params) notify = ActiveMerchant::Billing::Integrations::PaypalAdaptivePayment.notification(params) notify.acknowledge && notify.complete? end |