Skip to content

Commit dccea0e

Browse files
shallow copy the payload (#155)
Co-authored-by: jillingk <93914435+jillingk@users.noreply.github.com>
1 parent 99c7bf3 commit dccea0e

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

Adyen/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def _handle_response(self, url, raw_response, raw_request,
611611
Returns:
612612
AdyenResult: Result object if successful.
613613
"""
614-
if (status_code != 200 and status_code != 201):
614+
if (status_code != 200 and status_code != 201):
615615
response = {}
616616
# If the result can't be parsed into json, most likely is raw html.
617617
# Some response are neither json or raw html, handle them here:

Adyen/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def escape_val(val):
3535

3636

3737
def is_valid_hmac(dict_object, hmac_key):
38+
dict_object = dict_object.copy()
39+
3840
if 'additionalData' in dict_object:
3941
if dict_object['additionalData']['hmacSignature'] == "":
4042
raise ValueError("Must Provide hmacSignature in additionalData")
@@ -85,6 +87,8 @@ def escape_val(val):
8587

8688

8789
def is_valid_hmac_notification(dict_object, hmac_key):
90+
dict_object = dict_object.copy()
91+
8892
if 'additionalData' in dict_object:
8993
if dict_object['additionalData']['hmacSignature'] == "":
9094
raise ValueError("Must Provide hmacSignature in additionalData")

test/CheckoutTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,4 +497,4 @@ def test_sessions_error(self):
497497
result = self.adyen.checkout.sessions(request)
498498
self.assertEqual(422, result.message['status'])
499499
self.assertEqual("130", result.message['errorCode'])
500-
self.assertEqual("validation", result.message['errorType'])
500+
self.assertEqual("validation", result.message['errorType'])

test/UtilTest.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def test_hpp_request_item_hmac(self):
3434
self.assertEqual(hmac_calculation_str, expected_hmac)
3535
request['additionalData'] = {'hmacSignature': hmac_calculation_str}
3636
hmac_validate = is_valid_hmac(request, key)
37+
self.assertIn('additionalData', request)
38+
self.assertDictEqual(request['additionalData'],
39+
{'hmacSignature': hmac_calculation_str})
3740
self.assertTrue(hmac_validate)
3841

3942
def test_notification_request_item_hmac(self):
@@ -49,9 +52,9 @@ def test_notification_request_item_hmac(self):
4952
"success": "true",
5053
"eventDate": "2019-05-06T17:15:34.121+02:00",
5154
"operations": [
52-
"CANCEL",
53-
"CAPTURE",
54-
"REFUND"
55+
"CANCEL",
56+
"CAPTURE",
57+
"REFUND"
5558
],
5659
"paymentMethod": "visa",
5760
}
@@ -64,4 +67,7 @@ def test_notification_request_item_hmac(self):
6467
self.assertEqual(hmac_calculation_str, expected_hmac)
6568
request['additionalData'] = {'hmacSignature': hmac_calculation_str}
6669
hmac_validate = is_valid_hmac_notification(request, key)
70+
self.assertIn('additionalData', request)
71+
self.assertDictEqual(request['additionalData'],
72+
{'hmacSignature': hmac_calculation_str})
6773
self.assertTrue(hmac_validate)

0 commit comments

Comments
 (0)