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

#to_hash, #to_json

Constructor Details

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

Returns a new instance of OrderRequest.



65
66
67
68
69
70
71
72
# File 'lib/paypal_server_sdk/models/order_request.rb', line 65

def initialize(intent:, purchase_units:, payer: SKIP, payment_source: SKIP,
               application_context: SKIP)
  @intent = intent
  @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.<blockquote><strong>Note:</strong> Partners and Marketplaces might configure brand_name and shipping_preference during partner account setup, which overrides the request values.</blockquote>



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

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

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

Returns:



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

def payer
  @payer
end

#payment_sourcePaymentSource

The payment source definition.

Returns:



30
31
32
# File 'lib/paypal_server_sdk/models/order_request.rb', line 30

def payment_source
  @payment_source
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:



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

def purchase_units
  @purchase_units
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/paypal_server_sdk/models/order_request.rb', line 75

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')
  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,
                   payer: payer,
                   payment_source: payment_source,
                   application_context: application_context)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
# File 'lib/paypal_server_sdk/models/order_request.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['intent'] = 'intent'
  @_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



61
62
63
# File 'lib/paypal_server_sdk/models/order_request.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



52
53
54
55
56
57
58
# File 'lib/paypal_server_sdk/models/order_request.rb', line 52

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