Class: PaymentRecipes::PayPal::SOAP::Action::PerformDirectPayment

Inherits:
Utils::Action
  • Object
show all
Defined in:
lib/payment_recipes/paypal/soap/action/perform_direct_payment.rb

Instance Method Summary collapse

Methods inherited from Utils::Action

#debug, debug, #ensure_presence, #execute, #failure?, #get, #initialize, #make_instance_variables_available, prepare, rules, #set, #store, #stored_variables, #success?, variable

Constructor Details

This class inherits a constructor from PaymentRecipes::Utils::Action

Instance Method Details

#load_transactionObject



53
54
55
56
57
# File 'lib/payment_recipes/paypal/soap/action/perform_direct_payment.rb', line 53

def load_transaction
  store(:transaction) do
    ::PaymentRecipes::PayPal::SOAP::Transaction.find(response.transaction_id)
  end
end

#modify_detailsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/payment_recipes/paypal/soap/action/perform_direct_payment.rb', line 27

def modify_details
  unless [:sale, :authorize].include?(intent)
    raise Exception, "Allowed values for intent: :sale, :authorize"
  end

  store(:direct_payment_details) do
    payment_action = if intent == :sale
                       'Sale'
                     elsif intent == :authorize
                       'Authorization'
                     end

    details[:DoDirectPaymentRequestDetails][:PaymentAction] = payment_action

    details
  end
end

#performObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/payment_recipes/paypal/soap/action/perform_direct_payment.rb', line 9

def perform
  prepare_soap_api
  modify_details
  perform_request

  if response.success?
    load_transaction
  end

  response
end

#perform_requestObject



45
46
47
48
49
50
51
# File 'lib/payment_recipes/paypal/soap/action/perform_direct_payment.rb', line 45

def perform_request
  do_direct_payment = api.build_do_direct_payment(direct_payment_details)

  store(:response) do
    api.do_direct_payment(do_direct_payment)
  end
end

#prepare_soap_apiObject



21
22
23
24
25
# File 'lib/payment_recipes/paypal/soap/action/perform_direct_payment.rb', line 21

def prepare_soap_api
  store(:api) do
    ::PaymentRecipes::PayPal::SOAP::Settings.api
  end
end