class PaymentRecipes::PayPal::REST::Action::CreatePayment
Public Instance Methods
create_paypal_payment!()
click to toggle source
# File lib/payment_recipes/paypal/rest/action/create_payment.rb, line 24 def create_paypal_payment! store(:paypal_payment) do new_paypal_payment = ::PayPal::SDK::REST::Payment.new(payment_attributes) new_paypal_payment.create new_paypal_payment end end
find_payment!()
click to toggle source
# File lib/payment_recipes/paypal/rest/action/create_payment.rb, line 33 def find_payment! store(:payment) do ::PaymentRecipes::PayPal::REST::Payment.find(paypal_payment.id) end end
payment_attributes()
click to toggle source
# File lib/payment_recipes/paypal/rest/action/create_payment.rb, line 55 def payment_attributes { "intent" => convert_to_string(intent), "transactions" => [ { "amount" => { "total" => amount.to_s, "currency" => amount.currency.iso_code }, "description" => description } ] }.merge(attributes) end
perform()
click to toggle source
# File lib/payment_recipes/paypal/rest/action/create_payment.rb, line 13 def perform unless [:sale, :authorize].include?(intent) raise Exception, "Allowed values for intent: :sale, :authorize" end create_paypal_payment! find_payment! payment end
redirect_url()
click to toggle source
# File lib/payment_recipes/paypal/rest/action/create_payment.rb, line 39 def redirect_url paypal_payment.links.select { |link| link.rel == 'approval_url' }.first.href rescue nil end
sale()
click to toggle source
# File lib/payment_recipes/paypal/rest/action/create_payment.rb, line 43 def sale return nil unless payment payment.sale end