Class: PaypalServerSdk::CardStoredCredential

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

Overview

Provides additional details to process a payment using a ‘card` that has been stored or is intended to be stored (also referred to as stored_credential or card-on-file).<br/>Parameter compatibility:<br/><ul><li>`payment_type=ONE_TIME` is compatible only with `payment_initiator=CUSTOMER`.</li><li>`usage=FIRST` is compatible only with `payment_initiator=CUSTOMER`.</li><li>`previous_transaction_reference` or `previous_network_transaction_reference` is compatible only with `payment_initiator=MERCHANT`.</li><li>Only one of the parameters - `previous_transaction_reference` and `previous_network_transaction_reference` - can be present in the request.</li></ul>

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(payment_initiator:, payment_type:, usage: StoredPaymentSourceUsageType::DERIVED, previous_network_transaction_reference: SKIP) ⇒ CardStoredCredential

Returns a new instance of CardStoredCredential.



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/paypal_server_sdk/models/card_stored_credential.rb', line 63

def initialize(payment_initiator:, payment_type:,
               usage: StoredPaymentSourceUsageType::DERIVED,
               previous_network_transaction_reference: SKIP)
  @payment_initiator = payment_initiator
  @payment_type = payment_type
  @usage = usage unless usage == SKIP
  unless previous_network_transaction_reference == SKIP
    @previous_network_transaction_reference =
      previous_network_transaction_reference
  end
end

Instance Attribute Details

#payment_initiatorPaymentInitiator

The person or party who initiated or triggered the payment.

Returns:



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

def payment_initiator
  @payment_initiator
end

#payment_typeStoredPaymentSourcePaymentType

Indicates the type of the stored payment_source payment.



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

def payment_type
  @payment_type
end

#previous_network_transaction_referenceNetworkTransactionReference

Reference values used by the card network to identify a transaction.



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

def previous_network_transaction_reference
  @previous_network_transaction_reference
end

#usageStoredPaymentSourceUsageType

Indicates if this is a ‘first` or `subsequent` payment using a stored payment source (also referred to as stored credential or card on file).



33
34
35
# File 'lib/paypal_server_sdk/models/card_stored_credential.rb', line 33

def usage
  @usage
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  payment_initiator =
    hash.key?('payment_initiator') ? hash['payment_initiator'] : nil
  payment_type = hash.key?('payment_type') ? hash['payment_type'] : nil
  usage = hash['usage'] ||= StoredPaymentSourceUsageType::DERIVED
  if hash['previous_network_transaction_reference']
    previous_network_transaction_reference = NetworkTransactionReference.from_hash(hash['previous_network_transaction_reference'])
  end

  # Create object from extracted values.
  CardStoredCredential.new(payment_initiator: payment_initiator,
                           payment_type: payment_type,
                           usage: usage,
                           previous_network_transaction_reference: previous_network_transaction_reference)
end

.namesObject

A mapping from model property names to API property names.



40
41
42
43
44
45
46
47
48
# File 'lib/paypal_server_sdk/models/card_stored_credential.rb', line 40

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['payment_initiator'] = 'payment_initiator'
  @_hash['payment_type'] = 'payment_type'
  @_hash['usage'] = 'usage'
  @_hash['previous_network_transaction_reference'] =
    'previous_network_transaction_reference'
  @_hash
end

.nullablesObject

An array for nullable fields



59
60
61
# File 'lib/paypal_server_sdk/models/card_stored_credential.rb', line 59

def self.nullables
  []
end

.optionalsObject

An array for optional fields



51
52
53
54
55
56
# File 'lib/paypal_server_sdk/models/card_stored_credential.rb', line 51

def self.optionals
  %w[
    usage
    previous_network_transaction_reference
  ]
end