class PayPal::SDK::REST::DataTypes::Payment
Public Class Methods
all(options = {})
click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 130 def all(options = {}) path = "v1/payments/payment" PaymentHistory.new(api.get(path, options)) end
find(resource_id)
click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 124 def find(resource_id) raise ArgumentError.new("id required") if resource_id.to_s.strip.empty? path = "v1/payments/payment/#{resource_id}" self.new(api.get(path)) end
load_members()
click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 56 def self.load_members object_of :id, String object_of :intent, String object_of :payer, Payer object_of :payee, Payee object_of :cart, String array_of :transactions, Transaction array_of :failed_transactions, Error object_of :payment_instruction, PaymentInstruction object_of :state, String object_of :experience_profile_id, String object_of :note_to_payer, String object_of :redirect_urls, RedirectUrls object_of :failure_reason, String object_of :create_time, String object_of :update_time, String array_of :links, Links object_of :note_to_payer, String array_of :billing_agreement_tokens, String object_of :potential_payer_info, PotentialPayerInfo object_of :credit_financing_offered, CreditFinancingOffered object_of :failure_reason, String end
Public Instance Methods
approval_url(immediate = false)
click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 111 def approval_url(immediate = false) link = links.detect { |l| l.rel == 'approval_url' } return nil unless link link.href + (immediate ? '&useraction=commit' : '') end
create()
click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 82 def create() path = "v1/payments/payment" response = api.post(path, self.to_hash, http_header) self.merge!(response) success? end
execute(payment_execution)
click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 101 def execute(payment_execution) payment_execution = PaymentExecution.new(payment_execution) unless payment_execution.is_a? PaymentExecution path = "v1/payments/payment/#{self.id}/execute" response = api.post(path, payment_execution.to_hash, http_header) self.merge!(response) success? end
token()
click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 117 def token url = approval_url return nil unless url CGI.parse(URI.parse(url).query)['token'].first end
update(patch_requests)
click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 89 def update(patch_requests) patch_request_array = [] patch_requests.each do |patch_request| patch_request = Patch.new(patch_request) unless patch_request.is_a? Patch patch_request_array << patch_request.to_hash end path = "v1/payments/payment/#{self.id}" response = api.patch(path, patch_request_array, http_header) self.merge!(response) success? end