Class: PayPal::SDK::REST::DataTypes::Payment

Inherits:
Base show all
Includes:
RequestDataType
Defined in:
lib/paypal-sdk/rest/data_types.rb

Direct Known Subclasses

FuturePayment

Constant Summary

Constants inherited from Core::API::DataTypes::Base

Core::API::DataTypes::Base::ContentKey, Core::API::DataTypes::Base::HashOptions

Instance Attribute Summary

Attributes inherited from Base

#error, #header, #request_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RequestDataType

#api, api, #error=, included

Methods included from SetAPI

#client_id=, #client_secret=, #set_config, #token=

Methods inherited from Base

#http_header, #merge!, #success?

Methods inherited from Core::API::DataTypes::Base

add_attribute, add_member, array_of, #convert_array, #convert_object, define_alias_methods, #hash_key, #initialize, #member_names, members, #members, #merge!, object_of, #set, #skip_value?, snakecase, #to_hash, #value_to_hash

Methods included from Core::Logging

#log_event, #logger, logger, logger=

Constructor Details

This class inherits a constructor from PayPal::SDK::Core::API::DataTypes::Base

Class Method Details

.all(options = {}) ⇒ Object


88
89
90
91
# File 'lib/paypal-sdk/rest/data_types.rb', line 88

def all(options = {})
  path = "v1/payments/payment"
  PaymentHistory.new(api.get(path, options))
end

.find(resource_id) ⇒ Object

Raises:

  • (ArgumentError)

82
83
84
85
86
# File 'lib/paypal-sdk/rest/data_types.rb', line 82

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_membersObject


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/paypal-sdk/rest/data_types.rb', line 40

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 :redirect_urls, RedirectUrls
  object_of :create_time, String
  object_of :update_time, String
  array_of  :links, Links
end

Instance Method Details

#createObject


59
60
61
62
63
64
# File 'lib/paypal-sdk/rest/data_types.rb', line 59

def create()
  path = "v1/payments/payment"
  response = api.post(path, self.to_hash, http_header)
  self.merge!(response)
  success?
end

#execute(payment_execution) ⇒ Object


73
74
75
76
77
78
79
# File 'lib/paypal-sdk/rest/data_types.rb', line 73

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

#update(patch_request) ⇒ Object


66
67
68
69
70
71
# File 'lib/paypal-sdk/rest/data_types.rb', line 66

def update(patch_request)
  patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
  path = "v1/payments/payment/#{self.id}"
  response = api.patch(path, patch_request.to_hash, http_header)
  object.new(response)
end