Class: PaypalServerSdk::PurchaseUnitRequest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- PaypalServerSdk::PurchaseUnitRequest
- Defined in:
- lib/paypal_server_sdk/models/purchase_unit_request.rb
Overview
The purchase unit request. Includes required information for the payment contract.
Instance Attribute Summary collapse
-
#amount ⇒ AmountWithBreakdown
The total order amount with an optional breakdown that provides details, such as the total item amount, total tax amount, shipping, handling, insurance, and discounts, if any.
-
#custom_id ⇒ String
The API caller-provided external ID.
-
#description ⇒ String
This field supports up to 3,000 characters, but any content beyond 127 characters (including spaces) will be truncated.
-
#invoice_id ⇒ String
The API caller-provided external invoice number for this order.
-
#items ⇒ Array[ItemRequest]
An array of items that the customer purchases from the merchant.
-
#payee ⇒ PayeeBase
The merchant who receives the funds and fulfills the order.
-
#payment_instruction ⇒ PaymentInstruction
Any additional payment instructions to be consider during payment processing.
-
#reference_id ⇒ String
The API caller-provided external ID for the purchase unit.
-
#shipping ⇒ ShippingDetails
The shipping details.
-
#soft_descriptor ⇒ String
This field supports up to 127 characters, but any content beyond 22 characters (including spaces) will be truncated.
-
#supplementary_data ⇒ SupplementaryData
Supplementary data about a payment.
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(amount:, reference_id: SKIP, payee: SKIP, payment_instruction: SKIP, description: SKIP, custom_id: SKIP, invoice_id: SKIP, soft_descriptor: SKIP, items: SKIP, shipping: SKIP, supplementary_data: SKIP) ⇒ PurchaseUnitRequest
constructor
A new instance of PurchaseUnitRequest.
-
#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(amount:, reference_id: SKIP, payee: SKIP, payment_instruction: SKIP, description: SKIP, custom_id: SKIP, invoice_id: SKIP, soft_descriptor: SKIP, items: SKIP, shipping: SKIP, supplementary_data: SKIP) ⇒ PurchaseUnitRequest
Returns a new instance of PurchaseUnitRequest.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 139 def initialize(amount:, reference_id: SKIP, payee: SKIP, payment_instruction: SKIP, description: SKIP, custom_id: SKIP, invoice_id: SKIP, soft_descriptor: SKIP, items: SKIP, shipping: SKIP, supplementary_data: SKIP) @reference_id = reference_id unless reference_id == SKIP @amount = amount @payee = payee unless payee == SKIP @payment_instruction = payment_instruction unless payment_instruction == SKIP @description = description unless description == SKIP @custom_id = custom_id unless custom_id == SKIP @invoice_id = invoice_id unless invoice_id == SKIP @soft_descriptor = soft_descriptor unless soft_descriptor == SKIP @items = items unless items == SKIP @shipping = shipping unless shipping == SKIP @supplementary_data = supplementary_data unless supplementary_data == SKIP end |
Instance Attribute Details
#amount ⇒ AmountWithBreakdown
The total order amount with an optional breakdown that provides details, such as the total item amount, total tax amount, shipping, handling, insurance, and discounts, if any. If you specify ‘amount.breakdown`, the amount equals `item_total` plus `tax_total` plus `shipping` plus `handling` plus `insurance` minus `shipping_discount` minus discount. The amount must be a positive number. For listed of supported currencies and decimal precision, see the PayPal REST APIs Currency Codes.
28 29 30 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 28 def amount @amount end |
#custom_id ⇒ String
The API caller-provided external ID. Used to reconcile client transactions with PayPal transactions. Appears in transaction and settlement reports but is not visible to the payer.
56 57 58 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 56 def custom_id @custom_id end |
#description ⇒ String
This field supports up to 3,000 characters, but any content beyond 127 characters (including spaces) will be truncated. The 127 character limit is reflected in the response representation of this field. The purchase description. The maximum length of the character is dependent on the type of characters used. The character length is specified assuming a US ASCII character. Depending on type of character; (e.g. accented character, Japanese characters) the number of characters that that can be specified as input might not equal the permissible max length.
50 51 52 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 50 def description @description end |
#invoice_id ⇒ String
The API caller-provided external invoice number for this order. Appears in both the payer’s transaction history and the emails that the payer receives. invoice_id values are required to be unique within each merchant account by default. Although the uniqueness validation is configurable, disabling this behavior will remove the account’s ability to use invoice_id in other APIs as an identifier. It is highly recommended to keep a unique invoice_id for each Order.
66 67 68 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 66 def invoice_id @invoice_id end |
#items ⇒ Array[ItemRequest]
An array of items that the customer purchases from the merchant.
89 90 91 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 89 def items @items end |
#payee ⇒ PayeeBase
The merchant who receives the funds and fulfills the order. The merchant is also known as the payee.
33 34 35 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 33 def payee @payee end |
#payment_instruction ⇒ PaymentInstruction
Any additional payment instructions to be consider during payment processing. This processing instruction is applicable for Capturing an order or Authorizing an Order.
39 40 41 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 39 def payment_instruction @payment_instruction end |
#reference_id ⇒ String
The API caller-provided external ID for the purchase unit. Required for multiple purchase units when you must update the order through ‘PATCH`. If you omit this value and the order contains only one purchase unit, PayPal sets this value to `default`.
18 19 20 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 18 def reference_id @reference_id end |
#shipping ⇒ ShippingDetails
The shipping details.
93 94 95 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 93 def shipping @shipping end |
#soft_descriptor ⇒ String
This field supports up to 127 characters, but any content beyond 22 characters (including spaces) will be truncated. The 22 character limit is reflected in the response representation of this field. The soft descriptor is the dynamic text used to construct the statement descriptor that appears on a payer’s card statement. If an Order is paid using the “PayPal Wallet”, the statement descriptor will appear in following format on the payer’s card statement: PAYPAL_prefix+(space)merchant_descriptor(space)+ soft_descriptor Note: The merchant descriptor is the descriptor of the merchant’s payment receiving preferences which can be seen by logging into the merchant account www.sandbox.paypal.com/businessprofile/settings/info/edit The PAYPAL prefix uses 8 characters. Only the first 22 characters will be displayed in the statement. For example, if: The PayPal prefix toggle is PAYPAL *. The merchant descriptor in the profile is Janes Gift. The soft descriptor is 800-123-1234. Then, the statement descriptor on the card is PAYPAL * Janes Gift 80.
85 86 87 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 85 def soft_descriptor @soft_descriptor end |
#supplementary_data ⇒ SupplementaryData
Supplementary data about a payment. This object passes information that can be used to improve risk assessments and processing costs, for example, by providing Level 2 and Level 3 payment data.
99 100 101 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 99 def supplementary_data @supplementary_data end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 157 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = AmountWithBreakdown.from_hash(hash['amount']) if hash['amount'] reference_id = hash.key?('reference_id') ? hash['reference_id'] : SKIP payee = PayeeBase.from_hash(hash['payee']) if hash['payee'] payment_instruction = PaymentInstruction.from_hash(hash['payment_instruction']) if hash['payment_instruction'] description = hash.key?('description') ? hash['description'] : SKIP custom_id = hash.key?('custom_id') ? hash['custom_id'] : SKIP invoice_id = hash.key?('invoice_id') ? hash['invoice_id'] : SKIP soft_descriptor = hash.key?('soft_descriptor') ? hash['soft_descriptor'] : SKIP # Parameter is an array, so we need to iterate through it items = nil unless hash['items'].nil? items = [] hash['items'].each do |structure| items << (ItemRequest.from_hash(structure) if structure) end end items = SKIP unless hash.key?('items') shipping = ShippingDetails.from_hash(hash['shipping']) if hash['shipping'] supplementary_data = SupplementaryData.from_hash(hash['supplementary_data']) if hash['supplementary_data'] # Create object from extracted values. PurchaseUnitRequest.new(amount: amount, reference_id: reference_id, payee: payee, payment_instruction: payment_instruction, description: description, custom_id: custom_id, invoice_id: invoice_id, soft_descriptor: soft_descriptor, items: items, shipping: shipping, supplementary_data: supplementary_data) end |
.names ⇒ Object
A mapping from model property names to API property names.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 102 def self.names @_hash = {} if @_hash.nil? @_hash['reference_id'] = 'reference_id' @_hash['amount'] = 'amount' @_hash['payee'] = 'payee' @_hash['payment_instruction'] = 'payment_instruction' @_hash['description'] = 'description' @_hash['custom_id'] = 'custom_id' @_hash['invoice_id'] = 'invoice_id' @_hash['soft_descriptor'] = 'soft_descriptor' @_hash['items'] = 'items' @_hash['shipping'] = 'shipping' @_hash['supplementary_data'] = 'supplementary_data' @_hash end |
.nullables ⇒ Object
An array for nullable fields
135 136 137 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 135 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 119 def self.optionals %w[ reference_id payee payment_instruction description custom_id invoice_id soft_descriptor items shipping supplementary_data ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
209 210 211 212 213 214 215 216 217 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 209 def inspect class_name = self.class.name.split('::').last "<#{class_name} reference_id: #{@reference_id.inspect}, amount: #{@amount.inspect}, payee:"\ " #{@payee.inspect}, payment_instruction: #{@payment_instruction.inspect}, description:"\ " #{@description.inspect}, custom_id: #{@custom_id.inspect}, invoice_id:"\ " #{@invoice_id.inspect}, soft_descriptor: #{@soft_descriptor.inspect}, items:"\ " #{@items.inspect}, shipping: #{@shipping.inspect}, supplementary_data:"\ " #{@supplementary_data.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
200 201 202 203 204 205 206 |
# File 'lib/paypal_server_sdk/models/purchase_unit_request.rb', line 200 def to_s class_name = self.class.name.split('::').last "<#{class_name} reference_id: #{@reference_id}, amount: #{@amount}, payee: #{@payee},"\ " payment_instruction: #{@payment_instruction}, description: #{@description}, custom_id:"\ " #{@custom_id}, invoice_id: #{@invoice_id}, soft_descriptor: #{@soft_descriptor}, items:"\ " #{@items}, shipping: #{@shipping}, supplementary_data: #{@supplementary_data}>" end |