Class: PaypalServerSdk::Order

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

Overview

The order details.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(create_time: SKIP, update_time: SKIP, id: SKIP, payment_source: SKIP, intent: SKIP, processing_instruction: SKIP, payer: SKIP, purchase_units: SKIP, status: SKIP, links: SKIP) ⇒ Order

Returns a new instance of Order.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/paypal_server_sdk/models/order.rb', line 113

def initialize(create_time: SKIP, update_time: SKIP, id: SKIP,
               payment_source: SKIP, intent: SKIP,
               processing_instruction: SKIP, payer: SKIP,
               purchase_units: SKIP, status: SKIP, links: SKIP)
  @create_time = create_time unless create_time == SKIP
  @update_time = update_time unless update_time == SKIP
  @id = id unless id == SKIP
  @payment_source = payment_source unless payment_source == SKIP
  @intent = intent unless intent == SKIP
  @processing_instruction = processing_instruction unless processing_instruction == SKIP
  @payer = payer unless payer == SKIP
  @purchase_units = purchase_units unless purchase_units == SKIP
  @status = status unless status == SKIP
  @links = links unless links == SKIP
end

Instance Attribute Details

#create_timeString

The date and time, in [Internet date and time format](tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote>

Returns:

  • (String)


18
19
20
# File 'lib/paypal_server_sdk/models/order.rb', line 18

def create_time
  @create_time
end

#idString

The ID of the order.

Returns:

  • (String)


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

def id
  @id
end

#intentCheckoutPaymentIntent

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



39
40
41
# File 'lib/paypal_server_sdk/models/order.rb', line 39

def intent
  @intent
end

An array of request-related HATEOAS links. To complete payer approval, use the ‘approve` link to redirect the payer. The API caller has 6 hours (default setting, this which can be changed by your account manager to 24/48/72 hours to accommodate your use case) from the time the order is created, to redirect your payer. Once redirected, the API caller has 6 hours for the payer to approve the order and either authorize or capture the order. If you are not using the PayPal JavaScript SDK to initiate PayPal Checkout (in context) ensure that you include `application_context.return_url` is specified or you will get “We’re sorry, Things don’t appear to be working at the moment” after the payer approves the payment.

Returns:



74
75
76
# File 'lib/paypal_server_sdk/models/order.rb', line 74

def links
  @links
end

#payerPayer

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

Returns:



49
50
51
# File 'lib/paypal_server_sdk/models/order.rb', line 49

def payer
  @payer
end

#payment_sourcePaymentSourceResponse

The payment source used to fund the payment.



34
35
36
# File 'lib/paypal_server_sdk/models/order.rb', line 34

def payment_source
  @payment_source
end

#processing_instructionObject

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

Returns:

  • (Object)


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

def processing_instruction
  @processing_instruction
end

#purchase_unitsArray[PurchaseUnit]

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

Returns:



56
57
58
# File 'lib/paypal_server_sdk/models/order.rb', line 56

def purchase_units
  @purchase_units
end

#statusOrderStatus

The order status.

Returns:



60
61
62
# File 'lib/paypal_server_sdk/models/order.rb', line 60

def status
  @status
end

#update_timeString

The date and time, in [Internet date and time format](tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote>

Returns:

  • (String)


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

def update_time
  @update_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/paypal_server_sdk/models/order.rb', line 130

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  create_time = hash.key?('create_time') ? hash['create_time'] : SKIP
  update_time = hash.key?('update_time') ? hash['update_time'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  payment_source = PaymentSourceResponse.from_hash(hash['payment_source']) if
    hash['payment_source']
  intent = hash.key?('intent') ? hash['intent'] : SKIP
  processing_instruction =
    hash.key?('processing_instruction') ? hash['processing_instruction'] : SKIP
  payer = Payer.from_hash(hash['payer']) if hash['payer']
  # 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 << (PurchaseUnit.from_hash(structure) if structure)
    end
  end

  purchase_units = SKIP unless hash.key?('purchase_units')
  status = hash.key?('status') ? hash['status'] : SKIP
  # Parameter is an array, so we need to iterate through it
  links = nil
  unless hash['links'].nil?
    links = []
    hash['links'].each do |structure|
      links << (LinkDescription.from_hash(structure) if structure)
    end
  end

  links = SKIP unless hash.key?('links')

  # Create object from extracted values.
  Order.new(create_time: create_time,
            update_time: update_time,
            id: id,
            payment_source: payment_source,
            intent: intent,
            processing_instruction: processing_instruction,
            payer: payer,
            purchase_units: purchase_units,
            status: status,
            links: links)
end

.namesObject

A mapping from model property names to API property names.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/paypal_server_sdk/models/order.rb', line 77

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['create_time'] = 'create_time'
  @_hash['update_time'] = 'update_time'
  @_hash['id'] = 'id'
  @_hash['payment_source'] = 'payment_source'
  @_hash['intent'] = 'intent'
  @_hash['processing_instruction'] = 'processing_instruction'
  @_hash['payer'] = 'payer'
  @_hash['purchase_units'] = 'purchase_units'
  @_hash['status'] = 'status'
  @_hash['links'] = 'links'
  @_hash
end

.nullablesObject

An array for nullable fields



109
110
111
# File 'lib/paypal_server_sdk/models/order.rb', line 109

def self.nullables
  []
end

.optionalsObject

An array for optional fields



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/paypal_server_sdk/models/order.rb', line 93

def self.optionals
  %w[
    create_time
    update_time
    id
    payment_source
    intent
    processing_instruction
    payer
    purchase_units
    status
    links
  ]
end