Class: ActivePayment::Gateways::PaypalAdaptivePayment

Inherits:
Object
  • Object
show all
Includes:
ActionDispatch::Routing, ActionView::Helpers
Defined in:
lib/active_payment/gateways/paypal_adaptive_payment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePaypalAdaptivePayment



12
13
14
# File 'lib/active_payment/gateways/paypal_adaptive_payment.rb', line 12

def initialize
  @gateway = ActiveMerchant::Billing::PaypalAdaptivePayment.new(paypal_options)
end

Instance Attribute Details

#purchase_tokenObject

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

#salesObject

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.set_payment_options(payment_options_data(@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