Class: PaymentRecipes::PayPal::SOAP::Action::CaptureAuthorization

Inherits:
Utils::Action
  • Object
show all
Defined in:
lib/payment_recipes/paypal/soap/action/capture_authorization.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

#capture_idObject



97
98
99
# File 'lib/payment_recipes/paypal/soap/action/capture_authorization.rb', line 97

def capture_id
  response.do_capture_response_details.payment_info.transaction_id
end

#do_capture_authorizationObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/payment_recipes/paypal/soap/action/capture_authorization.rb', line 68

def do_capture_authorization
  do_capture = api.build_do_capture({
    :AuthorizationID => authorization_id,
    :Amount => amount,
    :CompleteType => "Complete" })

  store(:do_capture_response) do
    capture_response = api.do_capture(do_capture)

    unless capture_response.success?
      @error = capture_response.errors

      capture_response = nil
    end

    capture_response
  end
end

#load_transactionObject



87
88
89
90
91
92
93
94
95
# File 'lib/payment_recipes/paypal/soap/action/capture_authorization.rb', line 87

def load_transaction
  store(:authorization_transaction) do
    ::PaymentRecipes::PayPal::SOAP::Transaction.find(authorization_id)
  end

  store(:capture_transaction) do
    ::PaymentRecipes::PayPal::SOAP::Transaction.find(capture_id)
  end
end

#performObject



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/payment_recipes/paypal/soap/action/capture_authorization.rb', line 46

def perform
  prepare_soap_api

  do_capture_authorization

  if response.success?
    load_transaction
  end

  response
end

#prepare_soap_apiObject



58
59
60
61
62
# File 'lib/payment_recipes/paypal/soap/action/capture_authorization.rb', line 58

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

#responseObject



64
65
66
# File 'lib/payment_recipes/paypal/soap/action/capture_authorization.rb', line 64

def response
  do_capture_response
end