Class: Poundpay::Payment

Inherits:
Resource
  • Object
show all
Defined in:
lib/poundpay/elements.rb

Instance Method Summary collapse

Methods inherited from Resource

#collection_name, collection_path, element_path, #encode, instantiate_collection, new_element_path

Instance Method Details

#authorizeObject



74
75
76
77
78
79
80
# File 'lib/poundpay/elements.rb', line 74

def authorize
  unless status == 'STAGED'
    raise PaymentAuthorizeException.new "Payment status is #{status}.  Only STAGED payments may be AUTHORIZED."
  end
  attributes['status'] = 'AUTHORIZED'
  save
end

#cancelObject



101
102
103
104
105
106
107
108
109
110
# File 'lib/poundpay/elements.rb', line 101

def cancel
  statuses = ['AUTHORIZED', 'ESCROWED']
  unless statuses.include?(status)
    raise PaymentCancelException.new "Payment status is #{status}.  Only payments with statuses " \
    "#{statuses.join(', ')} may be canceled"
  end

  attributes['status'] = 'CANCELED'
  save
end

#escrowObject



82
83
84
85
86
87
88
# File 'lib/poundpay/elements.rb', line 82

def escrow
  unless status == 'AUTHORIZED'
    raise PaymentEscrowException.new "Payment status is #{status}.  Only AUTHORIZED payments may be ESCROWED."
  end
  attributes['status'] = 'ESCROWED'
  save
end

#releaseObject



90
91
92
93
94
95
96
97
98
99
# File 'lib/poundpay/elements.rb', line 90

def release
  statuses = ['ESCROWED']
  unless statuses.include?(status)
    raise PaymentReleaseException.new "Payment status is #{status}.  Only ESCROWED payments may be RELEASED."
  end
  # Tried setting status with status=, but save still had status == 'ESCROWED'.
  # Setting the status through the attributes, however, does work.
  attributes['status'] = 'RELEASED'
  save
end