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

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

Constructor Details

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

Returns a new instance of Order.



104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/paypal_server_sdk/models/order.rb', line 104

def initialize(create_time: SKIP, update_time: SKIP, id: SKIP,
               payment_source: SKIP, intent: 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
  @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. Note: The regular expression provides guidance but does not reject all invalid dates.

Returns:

  • (String)


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

def create_time
  @create_time
end

#idString

The ID of the order.

Returns:

  • (String)


28
29
30
# File 'lib/paypal_server_sdk/models/order.rb', line 28

def id
  @id
end

#intentCheckoutPaymentIntent

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



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

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:



67
68
69
# File 'lib/paypal_server_sdk/models/order.rb', line 67

def links
  @links
end

#payerPayer

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

Returns:



42
43
44
# File 'lib/paypal_server_sdk/models/order.rb', line 42

def payer
  @payer
end

#payment_sourcePaymentSourceResponse

The payment source used to fund the payment.



32
33
34
# File 'lib/paypal_server_sdk/models/order.rb', line 32

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



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

def purchase_units
  @purchase_units
end

#statusOrderStatus

The order status.

Returns:



53
54
55
# File 'lib/paypal_server_sdk/models/order.rb', line 53

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. Note: The regular expression provides guidance but does not reject all invalid dates.

Returns:

  • (String)


24
25
26
# File 'lib/paypal_server_sdk/models/order.rb', line 24

def update_time
  @update_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



119
120
121
122
123
124
125
126
127
128
129
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
# File 'lib/paypal_server_sdk/models/order.rb', line 119

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
  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,
            payer: payer,
            purchase_units: purchase_units,
            status: status,
            links: links)
end

.namesObject

A mapping from model property names to API property names.



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/paypal_server_sdk/models/order.rb', line 70

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['payer'] = 'payer'
  @_hash['purchase_units'] = 'purchase_units'
  @_hash['status'] = 'status'
  @_hash['links'] = 'links'
  @_hash
end

.nullablesObject

An array for nullable fields



100
101
102
# File 'lib/paypal_server_sdk/models/order.rb', line 100

def self.nullables
  []
end

.optionalsObject

An array for optional fields



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/paypal_server_sdk/models/order.rb', line 85

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



173
174
175
176
177
178
179
# File 'lib/paypal_server_sdk/models/order.rb', line 173

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

#to_sObject

Provides a human-readable string representation of the object.



165
166
167
168
169
170
# File 'lib/paypal_server_sdk/models/order.rb', line 165

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