Class: PaypalServerSdk::StoredPaymentSourceUsageType

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

Overview

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

Constant Summary collapse

STORED_PAYMENT_SOURCE_USAGE_TYPE =
[
  # Indicates the Initial/First payment with a payment_source that is

  # intended to be stored upon successful processing of the payment.

  FIRST = 'FIRST'.freeze,

  # Indicates a payment using a stored payment_source which has been

  # successfully used previously for a payment.

  SUBSEQUENT = 'SUBSEQUENT'.freeze,

  # Indicates that PayPal will derive the value of `FIRST` or `SUBSEQUENT`

  # based on data available to PayPal.

  DERIVED = 'DERIVED'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = FIRST) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/paypal_server_sdk/models/stored_payment_source_usage_type.rb', line 30

def self.from_value(value, default_value = FIRST)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'first' then FIRST
  when 'subsequent' then SUBSEQUENT
  when 'derived' then DERIVED
  else
    default_value
  end
end

.validate(value) ⇒ Object



24
25
26
27
28
# File 'lib/paypal_server_sdk/models/stored_payment_source_usage_type.rb', line 24

def self.validate(value)
  return false if value.nil?

  true
end