Skip to content

Commit 43b6dcc

Browse files
authored
added static method to return psp ref from body isntead of header if it exists (#166)
1 parent dccea0e commit 43b6dcc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Adyen/client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def _handle_response(self, url, raw_response, raw_request,
646646
else:
647647
try:
648648
response = json_lib.loads(raw_response)
649-
psp = headers.get('pspReference', response.get('pspReference'))
649+
psp = self._get_psp(response, headers)
650650
return AdyenResult(message=response, status_code=status_code,
651651
psp=psp, raw_request=raw_request,
652652
raw_response=raw_response)
@@ -794,3 +794,11 @@ def _error_from_hpp(html):
794794
match_obj = re.search(r'>Error:\s*(.*?)<br', html)
795795
if match_obj:
796796
return match_obj.group(1)
797+
798+
@staticmethod
799+
def _get_psp(response, header):
800+
psp_ref = response.get('pspReference')
801+
if psp_ref == "":
802+
return header.get('pspReference')
803+
else:
804+
return psp_ref

0 commit comments

Comments
 (0)