File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,11 @@ def payment_source
127127 res || payment_method
128128 end
129129
130+ # @return [Boolean] true when this payment is risky
131+ def risky?
132+ is_avs_risky? || is_cvv_risky? || state == 'failed'
133+ end
134+
130135 # @return [Boolean] true when this payment is risky based on address
131136 def is_avs_risky?
132137 return false if avs_response . blank? || NON_RISKY_AVS_CODES . include? ( avs_response )
Original file line number Diff line number Diff line change 5959 end
6060 end
6161
62+ context '#risky?' do
63+ it 'is true for risky payments' do
64+ aggregate_failures do
65+ expect ( payment_1 ) . not_to be_risky
66+ expect ( payment_2 ) . not_to be_risky
67+ expect ( payment_3 ) . to be_risky
68+ expect ( payment_4 ) . to be_risky
69+ expect ( payment_5 ) . to be_risky
70+ end
71+ end
6272 end
6373 end
6474
12121222 end
12131223 end
12141224
1215- describe "is_avs_risky?" do
1225+ describe "# is_avs_risky?" do
12161226 it "returns false if avs_response included in NON_RISKY_AVS_CODES" do
12171227 ( 'A' ..'Z' ) . reject { |x | subject . class ::RISKY_AVS_CODES . include? ( x ) } . to_a . each do |char |
12181228 payment . update_attribute ( :avs_response , char )
You can’t perform that action at this time.
0 commit comments