forked from mathie/sage_pay
/
authorise.rb
44 lines (33 loc) · 1.37 KB
/
authorise.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module SagePay
module Server
class Authorise < Command
self.tx_type = :authorise
attr_accessor :description, :related_transaction, :apply_avs_cv2
decimal_accessor :amount
validates_presence_of :amount, :description, :related_transaction
validates_length_of :description, :maximum => 100
validates_inclusion_of :apply_avs_cv2, :allow_blank => true, :in => (0..3).to_a
validates :amount, :numericality => {:message => "is less than the minimum value (0.01)", :greater_than_or_equal_to => BigDecimal.new("0.01")}
validates :amount, :numericality => {:message => "is greater than the maximum value (100,000.00)", :less_than_or_equal_toi => BigDecimal.new("100000")}
def post_params
params = super.merge({
"Amount" => ("%.2f" % amount),
"Description" => description
}).merge(related_transaction.post_params)
params['ApplyAVSCV2'] = apply_avs_cv2.to_s if apply_avs_cv2.present?
params
end
def response_from_response_body(response_body)
# FIXME: Since RepeatResponse is being shared for repeats and
# authorisations, it should probably be renamed.
RepeatResponse.from_response_body(response_body)
end
def live_service
"authorise"
end
def simulator_service
"VendorAuthoriseTx"
end
end
end
end