Class: Poundpay::Payment
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
#collection_name, collection_path, custom_method_collection_url, element_path, #encode, instantiate_collection, new_element_path
Class Method Details
.batch_update(params) ⇒ Object
74
75
76
77
78
|
# File 'lib/poundpay/elements.rb', line 74
def self.batch_update(params)
body = self.put('', {}, self.urlencode(params)).body
collection = self.format.decode(body)
return self.instantiate_collection(collection)
end
|
Instance Method Details
#authorize ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/poundpay/elements.rb', line 80
def authorize
unless state == 'CREATED'
raise PaymentAuthorizeException.new "Payment state is #{state}. Only CREATED payments may be AUTHORIZED."
end
attributes['state'] = 'AUTHORIZED'
save
end
|
#cancel ⇒ Object
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/poundpay/elements.rb', line 107
def cancel
states = ['CREATED', 'AUTHORIZED', 'ESCROWED']
unless states.include?(state)
raise PaymentCancelException.new "Payment state is #{state}. Only payments with states " \
"#{states.join(', ')} may be canceled"
end
attributes['state'] = 'CANCELED'
save
end
|
#escrow ⇒ Object
88
89
90
91
92
93
94
|
# File 'lib/poundpay/elements.rb', line 88
def escrow
unless state == 'AUTHORIZED'
raise PaymentEscrowException.new "Payment state is #{state}. Only AUTHORIZED payments may be ESCROWED."
end
attributes['state'] = 'ESCROWED'
save
end
|
#release ⇒ Object
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/poundpay/elements.rb', line 96
def release
states = ['ESCROWED']
unless states.include?(state)
raise PaymentReleaseException.new "Payment state is #{state}. Only ESCROWED payments may be RELEASED."
end
attributes['state'] = 'RELEASED'
save
end
|