Class: PaypalServerSdk::OrderRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/order_request.rb

Overview

The order request details.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(intent:, purchase_units:, processing_instruction: SKIP, payer: SKIP, payment_source: SKIP, application_context: SKIP) ⇒ OrderRequest

Returns a new instance of OrderRequest.



73
74
75
76
77
78
79
80
81
# File 'lib/paypal_server_sdk/models/order_request.rb', line 73

def initialize(intent:, purchase_units:, processing_instruction: SKIP,
               payer: SKIP, payment_source: SKIP, application_context: SKIP)
  @intent = intent
  @processing_instruction = processing_instruction unless processing_instruction == SKIP
  @payer = payer unless payer == SKIP
  @purchase_units = purchase_units
  @payment_source = payment_source unless payment_source == SKIP
  @application_context = application_context unless application_context == SKIP
end

Instance Attribute Details

#application_contextOrderApplicationContext

Customizes the payer experience during the approval process for the payment with PayPal. Note: Partners and Marketplaces might configure brand_name and shipping_preference during partner account setup, which overrides the request values.



44
45
46
# File 'lib/paypal_server_sdk/models/order_request.rb', line 44

def application_context
  @application_context
end

#intentCheckoutPaymentIntent

The intent to either capture payment immediately or authorize a payment for an order after order creation.



15
16
17
# File 'lib/paypal_server_sdk/models/order_request.rb', line 15

def intent
  @intent
end

#payerPayer

DEPRECATED. The customer is also known as the payer. The Payer object was intended to only be used with the ‘payment_source.paypal` object. In order to make this design more clear, the details in the `payer` object are now available under `payment_source.paypal`. Please use `payment_source.paypal`.

Returns:



27
28
29
# File 'lib/paypal_server_sdk/models/order_request.rb', line 27

def payer
  @payer
end

#payment_sourcePaymentSource

The payment source definition.

Returns:



37
38
39
# File 'lib/paypal_server_sdk/models/order_request.rb', line 37

def payment_source
  @payment_source
end

#processing_instructionProcessingInstruction

The instruction to process an order.



19
20
21
# File 'lib/paypal_server_sdk/models/order_request.rb', line 19

def processing_instruction
  @processing_instruction
end

#purchase_unitsArray[PurchaseUnitRequest]

An array of purchase units. Each purchase unit establishes a contract between a payer and the payee. Each purchase unit represents either a full or partial order that the payer intends to purchase from the payee.

Returns:



33
34
35
# File 'lib/paypal_server_sdk/models/order_request.rb', line 33

def purchase_units
  @purchase_units
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/paypal_server_sdk/models/order_request.rb', line 84

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  intent = hash.key?('intent') ? hash['intent'] : nil
  # Parameter is an array, so we need to iterate through it
  purchase_units = nil
  unless hash['purchase_units'].nil?
    purchase_units = []
    hash['purchase_units'].each do |structure|
      purchase_units << (PurchaseUnitRequest.from_hash(structure) if structure)
    end
  end

  purchase_units = nil unless hash.key?('purchase_units')
  processing_instruction =
    hash.key?('processing_instruction') ? hash['processing_instruction'] : SKIP
  payer = Payer.from_hash(hash['payer']) if hash['payer']
  payment_source = PaymentSource.from_hash(hash['payment_source']) if hash['payment_source']
  application_context = OrderApplicationContext.from_hash(hash['application_context']) if
    hash['application_context']

  # Create object from extracted values.
  OrderRequest.new(intent: intent,
                   purchase_units: purchase_units,
                   processing_instruction: processing_instruction,
                   payer: payer,
                   payment_source: payment_source,
                   application_context: application_context)
end

.namesObject

A mapping from model property names to API property names.



47
48
49
50
51
52
53
54
55
56
# File 'lib/paypal_server_sdk/models/order_request.rb', line 47

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['intent'] = 'intent'
  @_hash['processing_instruction'] = 'processing_instruction'
  @_hash['payer'] = 'payer'
  @_hash['purchase_units'] = 'purchase_units'
  @_hash['payment_source'] = 'payment_source'
  @_hash['application_context'] = 'application_context'
  @_hash
end

.nullablesObject

An array for nullable fields



69
70
71
# File 'lib/paypal_server_sdk/models/order_request.rb', line 69

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
66
# File 'lib/paypal_server_sdk/models/order_request.rb', line 59

def self.optionals
  %w[
    processing_instruction
    payer
    payment_source
    application_context
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



124
125
126
127
128
129
130
# File 'lib/paypal_server_sdk/models/order_request.rb', line 124

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} intent: #{@intent.inspect}, processing_instruction:"\
  " #{@processing_instruction.inspect}, payer: #{@payer.inspect}, purchase_units:"\
  " #{@purchase_units.inspect}, payment_source: #{@payment_source.inspect},"\
  " application_context: #{@application_context.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



116
117
118
119
120
121
# File 'lib/paypal_server_sdk/models/order_request.rb', line 116

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} intent: #{@intent}, processing_instruction: #{@processing_instruction},"\
  " payer: #{@payer}, purchase_units: #{@purchase_units}, payment_source: #{@payment_source},"\
  " application_context: #{@application_context}>"
end