Class: PaypalServerSdk::OrderRequest
- Defined in:
- lib/paypal_server_sdk/models/order_request.rb
Overview
The order request details.
Instance Attribute Summary collapse
-
#application_context ⇒ OrderApplicationContext
Customizes the payer experience during the approval process for the payment with PayPal.
-
#intent ⇒ CheckoutPaymentIntent
The intent to either capture payment immediately or authorize a payment for an order after order creation.
-
#payer ⇒ Payer
DEPRECATED.
-
#payment_source ⇒ PaymentSource
The payment source definition.
-
#purchase_units ⇒ Array[PurchaseUnitRequest]
An array of purchase units.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(intent:, purchase_units:, payer: SKIP, payment_source: SKIP, application_context: SKIP) ⇒ OrderRequest
constructor
A new instance of OrderRequest.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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:, payer: SKIP, payment_source: SKIP, application_context: SKIP) ⇒ OrderRequest
Returns a new instance of OrderRequest.
67 68 69 70 71 72 73 74 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 67 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_context ⇒ OrderApplicationContext
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.
40 41 42 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 40 def application_context @application_context end |
#intent ⇒ CheckoutPaymentIntent
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 |
#payer ⇒ Payer
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`.
23 24 25 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 23 def payer @payer end |
#payment_source ⇒ PaymentSource
The payment source definition.
33 34 35 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 33 def payment_source @payment_source end |
#purchase_units ⇒ Array[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.
29 30 31 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 29 def purchase_units @purchase_units end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 102 103 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 77 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 |
.names ⇒ Object
A mapping from model property names to API property names.
43 44 45 46 47 48 49 50 51 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 43 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 |
.nullables ⇒ Object
An array for nullable fields
63 64 65 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 63 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 60 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 54 def self.optionals %w[ payer payment_source application_context ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
113 114 115 116 117 118 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 113 def inspect class_name = self.class.name.split('::').last "<#{class_name} intent: #{@intent.inspect}, payer: #{@payer.inspect}, purchase_units:"\ " #{@purchase_units.inspect}, payment_source: #{@payment_source.inspect},"\ " application_context: #{@application_context.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
106 107 108 109 110 |
# File 'lib/paypal_server_sdk/models/order_request.rb', line 106 def to_s class_name = self.class.name.split('::').last "<#{class_name} intent: #{@intent}, payer: #{@payer}, purchase_units: #{@purchase_units},"\ " payment_source: #{@payment_source}, application_context: #{@application_context}>" end |