Class: PaypalServerSdk::RefundRequest

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

Overview

Refunds a captured payment, by ID. For a full refund, include an empty request body. For a partial refund, include an amount object in the request body.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(amount: SKIP, custom_id: SKIP, invoice_id: SKIP, note_to_payer: SKIP, payment_instruction: SKIP) ⇒ RefundRequest

Returns a new instance of RefundRequest.



71
72
73
74
75
76
77
78
# File 'lib/paypal_server_sdk/models/refund_request.rb', line 71

def initialize(amount: SKIP, custom_id: SKIP, invoice_id: SKIP,
               note_to_payer: SKIP, payment_instruction: SKIP)
  @amount = amount unless amount == SKIP
  @custom_id = custom_id unless custom_id == SKIP
  @invoice_id = invoice_id unless invoice_id == SKIP
  @note_to_payer = note_to_payer unless note_to_payer == SKIP
  @payment_instruction = payment_instruction unless payment_instruction == SKIP
end

Instance Attribute Details

#amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



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

def amount
  @amount
end

#custom_idString

The API caller-provided external ID. Used to reconcile API caller-initiated transactions with PayPal transactions. Appears in transaction and settlement reports. The pattern is defined by an external party and supports Unicode.

Returns:

  • (String)


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

def custom_id
  @custom_id
end

#invoice_idString

The API caller-provided external invoice ID for this order. The pattern is defined by an external party and supports Unicode.

Returns:

  • (String)


29
30
31
# File 'lib/paypal_server_sdk/models/refund_request.rb', line 29

def invoice_id
  @invoice_id
end

#note_to_payerString

The reason for the refund. Appears in both the payer’s transaction history and the emails that the payer receives. The pattern is defined by an external party and supports Unicode.

Returns:

  • (String)


35
36
37
# File 'lib/paypal_server_sdk/models/refund_request.rb', line 35

def note_to_payer
  @note_to_payer
end

#payment_instructionRefundPaymentInstruction

Any additional payments instructions during refund payment processing. This object is only applicable to merchants that have been enabled for PayPal Commerce Platform for Marketplaces and Platforms capability. Please speak to your account manager if you want to use this capability.



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

def payment_instruction
  @payment_instruction
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/paypal_server_sdk/models/refund_request.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = Money.from_hash(hash['amount']) if hash['amount']
  custom_id = hash.key?('custom_id') ? hash['custom_id'] : SKIP
  invoice_id = hash.key?('invoice_id') ? hash['invoice_id'] : SKIP
  note_to_payer = hash.key?('note_to_payer') ? hash['note_to_payer'] : SKIP
  payment_instruction = RefundPaymentInstruction.from_hash(hash['payment_instruction']) if
    hash['payment_instruction']

  # Create object from extracted values.
  RefundRequest.new(amount: amount,
                    custom_id: custom_id,
                    invoice_id: invoice_id,
                    note_to_payer: note_to_payer,
                    payment_instruction: payment_instruction)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
# File 'lib/paypal_server_sdk/models/refund_request.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['custom_id'] = 'custom_id'
  @_hash['invoice_id'] = 'invoice_id'
  @_hash['note_to_payer'] = 'note_to_payer'
  @_hash['payment_instruction'] = 'payment_instruction'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



56
57
58
59
60
61
62
63
64
# File 'lib/paypal_server_sdk/models/refund_request.rb', line 56

def self.optionals
  %w[
    amount
    custom_id
    invoice_id
    note_to_payer
    payment_instruction
  ]
end