class PaymentRecipes::PayPal::SOAP::Action::ExecuteExpressCheckout

Public Instance Methods

do_express_checkout() click to toggle source
# File lib/payment_recipes/paypal/soap/action/execute_express_checkout_payment.rb, line 104
def do_express_checkout
  do_express_checkout_payment = api.build_do_express_checkout_payment(express_checkout_details)

  store(:do_express_checkout_response) do
    response = api.do_express_checkout_payment(do_express_checkout_payment)

    unless response.success?
      @error = response.errors

      response = nil
    end

    response
  end
end
load_transaction() click to toggle source
# File lib/payment_recipes/paypal/soap/action/execute_express_checkout_payment.rb, line 120
def load_transaction
  store(:transaction) do
    transaction_id = response.do_express_checkout_payment_response_details.payment_info.first.transaction_id
    
    ::PaymentRecipes::PayPal::SOAP::Transaction.find(transaction_id)
  end
end
modify_details() click to toggle source
# File lib/payment_recipes/paypal/soap/action/execute_express_checkout_payment.rb, line 77
def modify_details
  unless [:sale, :authorize].include?(intent)
    raise Exception, "Allowed values for intent: :sale, :authorize"
  end

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

    {
      :DoExpressCheckoutPaymentRequestDetails => {
        :PaymentAction => payment_action,
        :Token => token,
        :PayerID => payer_id,
        :PaymentDetails => [details] 
      } 
    }
  end
end
perform() click to toggle source
# File lib/payment_recipes/paypal/soap/action/execute_express_checkout_payment.rb, line 59
def perform
  prepare_soap_api
  modify_details
  do_express_checkout

  if response.success?
    load_transaction
  end

  response
end
prepare_soap_api() click to toggle source
# File lib/payment_recipes/paypal/soap/action/execute_express_checkout_payment.rb, line 71
def prepare_soap_api
  store(:api) do
    ::PaymentRecipes::PayPal::SOAP::Settings.api
  end
end
response() click to toggle source
# File lib/payment_recipes/paypal/soap/action/execute_express_checkout_payment.rb, line 100
def response
  do_express_checkout_response
end