Skip to content

Commit 74f36d5

Browse files
author
icipiracy
committed
Added extra validation for empty or 0 values for modification requests
1 parent 7c137d1 commit 74f36d5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Adyen/services.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,11 @@ def cancel(self, request="", **kwargs):
158158
return self.client.call_api(request, self.service, action, **kwargs)
159159

160160
def capture(self, request="", **kwargs):
161+
161162
action = "capture"
162163

163164
if validation.check_in(request,action):
164-
if request['modificationAmount']["value"] == "":
165+
if request['modificationAmount']["value"] == "" or request['modificationAmount']['value'] == "0":
165166
raise ValueError("Set the 'modificationAmount' to the original transaction amount, or less for a partial capture. modificationAmount should be an object with the following keys: {'currency':,'value':}")
166167
if request['originalReference'] == "":
167168
raise ValueError("Set the 'originalReference' to the psp reference of the transaction to be modified")
@@ -170,10 +171,14 @@ def capture(self, request="", **kwargs):
170171
return response
171172

172173
def refund(self, request="", **kwargs):
174+
173175
action = "refund"
174176

177+
print "REFUND:"
178+
print request
179+
175180
if validation.check_in(request,action):
176-
if request['modificationAmount']['value'] == "":
181+
if request['modificationAmount']['value'] == "" or request['modificationAmount']['value'] == "0":
177182
raise ValueError("To refund this payment, provide the original value. Set the value to less than the original amount, to partially refund this payment.")
178183
else:
179184
return self.client.call_api(request, self.service, action, **kwargs)

0 commit comments

Comments
 (0)