Class: FdxV660Api::PaymentStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/fdx_v660_api/models/payment_status.rb

Overview

Defines the payment lifecycle. * CANCELLED: Payment was cancelled by the user * FAILED: Payment failed for reasons other than "No Funds" For example: fraud, invalid payee, source account was closed etc. * NOFUNDS: Payment failed because of the lack of funds * PROCESSED: The payment has been executed by the payment service provider * PROCESSING: Payment is in the process of being executed by the payment service provider * SCHEDULED: Payment has been scheduled

Constant Summary collapse

PAYMENT_STATUS =
[
  # TODO: Write general description for CANCELLED
  CANCELLED = 'CANCELLED'.freeze,

  # TODO: Write general description for FAILED
  FAILED = 'FAILED'.freeze,

  # TODO: Write general description for NOFUNDS
  NOFUNDS = 'NOFUNDS'.freeze,

  # TODO: Write general description for PROCESSED
  PROCESSED = 'PROCESSED'.freeze,

  # TODO: Write general description for PROCESSING
  PROCESSING = 'PROCESSING'.freeze,

  # TODO: Write general description for SCHEDULED
  SCHEDULED = 'SCHEDULED'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = CANCELLED) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fdx_v660_api/models/payment_status.rb', line 41

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

  str = value.to_s.strip

  case str.downcase
  when 'cancelled' then CANCELLED
  when 'failed' then FAILED
  when 'nofunds' then NOFUNDS
  when 'processed' then PROCESSED
  when 'processing' then PROCESSING
  when 'scheduled' then SCHEDULED
  else
    default_value
  end
end

.validate(value) ⇒ Object



35
36
37
38
39
# File 'lib/fdx_v660_api/models/payment_status.rb', line 35

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

  true
end