-
Notifications
You must be signed in to change notification settings - Fork 47
Adding-Modification-Functionality-For-Checkout-Api #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
993d1b8
28eb420
2530b4d
9bf9188
ce3dff7
d89344c
04ffb98
219817e
cd10fc8
7eb7196
5532943
be78ec7
e5d319f
0634330
15e08f2
c87c504
800b613
0140d4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -280,6 +280,13 @@ class AdyenCheckoutApi(AdyenServiceBase): | |||||
payments/details | ||||||
originKeys | ||||||
|
||||||
Modifications: | ||||||
capture | ||||||
refunds | ||||||
cancels | ||||||
reversals | ||||||
|
||||||
|
||||||
Please refer to the checkout documentation for specifics around the API. | ||||||
https://docs.adyen.com/developers/checkout | ||||||
|
||||||
|
@@ -322,6 +329,42 @@ def payment_result(self, request=None, **kwargs): | |||||
action = "paymentsResult" | ||||||
return self.client.call_checkout_api(request, action, **kwargs) | ||||||
|
||||||
def payment_captures(self, path_param, request=None, idempotency_key=None, **kwargs): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if path_param == "": | ||||||
raise ValueError( | ||||||
'must contain a pspReference in the path_param, path_param cannot be empty' | ||||||
) | ||||||
action = "paymentsCapture" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please add this action in the |
||||||
return self.client.call_checkout_api(request, action, path_param, idempotency_key, **kwargs) | ||||||
|
||||||
def payments_cancels_without_reference(self, request=None, idempotency_key=None, **kwargs): | ||||||
action = "paymentsCancelsWithoutReference" | ||||||
return self.client.call_checkout_api(request, action, idempotency_key, **kwargs) | ||||||
|
||||||
def payments_cancels_with_reference(self, path_param, request=None, idempotency_key=None, **kwargs): | ||||||
if path_param == "": | ||||||
raise ValueError( | ||||||
'must contain a pspReference in the path_param, path_param cannot be empty' | ||||||
) | ||||||
action = "paymentsCancelsWithReference" | ||||||
return self.client.call_checkout_api(request, action, path_param, idempotency_key, **kwargs) | ||||||
|
||||||
def payments_reversals(self, path_param, request=None, idempotency_key=None, **kwargs): | ||||||
if path_param == "": | ||||||
raise ValueError( | ||||||
'must contain a pspReference in the path_param, path_param cannot be empty' | ||||||
) | ||||||
action = "paymentsReversals" | ||||||
return self.client.call_checkout_api(request, action, path_param, idempotency_key, **kwargs) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not work: Same comment probably also applies to all other uses of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see :) Thanks for the comment! |
||||||
|
||||||
def payments_refunds(self, path_param, request=None, idempotency_key=None, **kwargs): | ||||||
if path_param == "": | ||||||
raise ValueError( | ||||||
'must contain a pspReference in the path_param, path_param cannot be empty' | ||||||
) | ||||||
action = "paymentsRefunds" | ||||||
return self.client.call_checkout_api(request, action, path_param, idempotency_key, **kwargs) | ||||||
|
||||||
def origin_keys(self, request=None, **kwargs): | ||||||
action = "originKeys" | ||||||
return self.client.call_checkout_api(request, action, **kwargs) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -236,6 +236,201 @@ def test_payments_result_error_mocked(self): | |||||
self.assertEqual("Invalid payload provided", result.message['message']) | ||||||
self.assertEqual("validation", result.message['errorType']) | ||||||
|
||||||
def test_payments_cancels_without_reference(self): | ||||||
requests = { | ||||||
"paymentReference": "Payment123", | ||||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||||||
"reference": "YourCancelReference", | ||||||
} | ||||||
self.adyen.client = self.test.create_client_from_file(200, requests, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentscancel-" | ||||||
"withoutreference-succes.json") | ||||||
results = self.adyen.checkout.payments_cancels_without_reference(request=requests) | ||||||
self.assertIsNotNone(results.message['paymentReference']) | ||||||
self.assertEqual("8412534564722331", results.message['pspReference']) | ||||||
self.assertEqual("received", results.message['status']) | ||||||
|
||||||
def test_payments_cancels_without_reference_error_mocked(self): | ||||||
requests = { | ||||||
"paymentReference": "Payment123", | ||||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||||||
"reference": "YourCancelReference", | ||||||
} | ||||||
self.adyen.client = self.test.create_client_from_file(200, requests, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentsresult" | ||||||
"-error-invalid-" | ||||||
"data-payload-" | ||||||
"422.json") | ||||||
|
||||||
result = self.adyen.checkout.payments_cancels_without_reference(requests) | ||||||
self.assertEqual(422, result.message['status']) | ||||||
self.assertEqual("14_018", result.message['errorCode']) | ||||||
self.assertEqual("Invalid payload provided", result.message['message']) | ||||||
self.assertEqual("validation", result.message['errorType']) | ||||||
|
||||||
def test_payments_cancels_success_mocked(self): | ||||||
requests = {"reference": "Your wro order number", "merchantAccount": "YOUR_MERCHANT_ACCOUNT"} | ||||||
reference_id = "8836183819713023" | ||||||
self.adyen.client = self.test.create_client_from_file(200, requests, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentscancels" | ||||||
"-success.json") | ||||||
result = self.adyen.checkout.payments_cancels_with_reference(request=requests, path_param=reference_id) | ||||||
self.assertEqual(reference_id, result.message["paymentPspReference"]) | ||||||
self.assertEqual("received", result.message['status']) | ||||||
|
||||||
def test_payments_cancels_error_mocked(self): | ||||||
requests = {"reference": "Your wro order number"} | ||||||
psp_reference = "8836183819713023" | ||||||
self.adyen.client = self.test.create_client_from_file(200, requests, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentsresult-error-invalid-" | ||||||
"data-payload-422.json") | ||||||
result = self.adyen.checkout.payments_cancels_with_reference(request=requests, path_param=psp_reference) | ||||||
self.assertEqual(422, result.message['status']) | ||||||
self.assertEqual("14_018", result.message['errorCode']) | ||||||
self.assertEqual("Invalid payload provided", result.message['message']) | ||||||
self.assertEqual("validation", result.message['errorType']) | ||||||
|
||||||
def test_payments_refunds_success_mocked(self): | ||||||
requests = { | ||||||
"paymentReference": "Payment123", | ||||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||||||
"reference": "YourCancelReference", | ||||||
} | ||||||
psp_reference = "Payment123" | ||||||
self.adyen.client = self.test.create_client_from_file(200, requests, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentscancel-" | ||||||
"withoutreference-succes.json") | ||||||
|
||||||
result = self.adyen.checkout.payments_cancels_without_reference(request=requests, path_param=psp_reference) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
self.assertEqual(psp_reference, result.message["paymentReference"]) | ||||||
self.assertIsNotNone(result.message["pspReference"]) | ||||||
self.assertEqual("received", result.message['status']) | ||||||
|
||||||
def test_payments_refunds_error_mocked(self): | ||||||
requests = { | ||||||
"paymentReference": "Payment123", | ||||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||||||
"reference": "YourCancelReference", | ||||||
} | ||||||
reference_id = "Payment123" | ||||||
self.adyen.client = self.test.create_client_from_file(200, requests, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentsresult-error-invalid-" | ||||||
"data-payload-422.json") | ||||||
|
||||||
result = self.adyen.checkout.payments_cancels_without_reference(request=requests, path_param=reference_id) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
self.assertEqual(422, result.message['status']) | ||||||
self.assertEqual("14_018", result.message['errorCode']) | ||||||
self.assertEqual("Invalid payload provided", result.message['message']) | ||||||
self.assertEqual("validation", result.message['errorType']) | ||||||
|
||||||
def test_payments_refunds_raises_vaulue_error(self): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
requests = { | ||||||
"paymentReference": "Payment123", | ||||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||||||
"reference": "YourCancelReference", | ||||||
} | ||||||
self.adyen.client = self.test.create_client_from_file(200, requests, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentscancel-" | ||||||
"withoutreference-succes.json") | ||||||
with self.assertRaises(ValueError) as exc: | ||||||
self.adyen.checkout.payments_cancels_with_reference(request=requests, path_param="") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
self.assertEqual(exc.exception.__class__, ValueError) | ||||||
self.assertEqual(exc.exception.__str__(), 'must contain a pspReference in the path_param, path_param cannot ' | ||||||
'be empty') | ||||||
|
||||||
def test_reversals_success_mocked(self): | ||||||
requests = { | ||||||
"reference": "YourReversalReference", | ||||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT" | ||||||
} | ||||||
psp_reference = "8836183819713023" | ||||||
self.adyen.client = self.test.create_client_from_file(200, requests, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentsreversals-" | ||||||
"success.json") | ||||||
|
||||||
result = self.adyen.checkout.payments_reversals(request=requests, path_param=psp_reference) | ||||||
self.assertEqual(psp_reference, result.message["paymentPspReference"]) | ||||||
self.assertIsNotNone(result.message["pspReference"]) | ||||||
self.assertEqual("received", result.message['status']) | ||||||
|
||||||
def test_payments_reversals_failure_mocked(self): | ||||||
requests = { | ||||||
"reference": "YourReversalReference", | ||||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT" | ||||||
} | ||||||
psp_reference = "8836183819713023" | ||||||
self.adyen.client = self.test.create_client_from_file(200, requests, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentsresult-error-invalid-" | ||||||
"data-payload-422.json") | ||||||
|
||||||
result = self.adyen.checkout.payments_reversals(request=requests, path_param=psp_reference) | ||||||
self.assertEqual(422, result.message['status']) | ||||||
self.assertEqual("14_018", result.message['errorCode']) | ||||||
self.assertEqual("Invalid payload provided", result.message['message']) | ||||||
self.assertEqual("validation", result.message['errorType']) | ||||||
|
||||||
def test_payments_capture_success_mocked(self): | ||||||
request = { | ||||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||||||
"amount": { | ||||||
"value": 2500, | ||||||
"currency": "EUR" | ||||||
}, | ||||||
"reference": "YOUR_UNIQUE_REFERENCE" | ||||||
} | ||||||
psp_reference = "8536214160615591" | ||||||
self.adyen.client = self.test.create_client_from_file(200, request, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentcapture-" | ||||||
"success.json") | ||||||
|
||||||
result = self.adyen.checkout.payment_captures(request=request, path_param=psp_reference) | ||||||
self.assertEqual(psp_reference, result.message["paymentPspReference"]) | ||||||
self.assertIsNotNone(result.message["pspReference"]) | ||||||
self.assertEqual("received", result.message['status']) | ||||||
self.assertEqual(2500, result.message['amount']['value']) | ||||||
|
||||||
def test_payments_capture_error_mocked(self): | ||||||
request = { | ||||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||||||
"amount": { | ||||||
"value": 2500, | ||||||
"currency": "EUR" | ||||||
}, | ||||||
"reference": "YOUR_UNIQUE_REFERENCE" | ||||||
} | ||||||
psp_reference = "8536214160615591" | ||||||
self.adyen.client = self.test.create_client_from_file(200, request, | ||||||
"test/mocks/" | ||||||
"checkout/" | ||||||
"paymentsresult-error-invalid-" | ||||||
"data-payload-422.json") | ||||||
|
||||||
result = self.adyen.checkout.payment_captures(request=request, path_param=psp_reference) | ||||||
self.assertEqual(422, result.message['status']) | ||||||
self.assertEqual("14_018", result.message['errorCode']) | ||||||
self.assertEqual("Invalid payload provided", result.message['message']) | ||||||
self.assertEqual("validation", result.message['errorType']) | ||||||
|
||||||
def test_orders_success(self): | ||||||
request = {'merchantAccount': "YourMerchantAccount"} | ||||||
self.adyen.client = self.test.create_client_from_file(200, request, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||
"paymentPspReference": "8536214160615591", | ||
"pspReference": "8836226171638872", | ||
"reference": "YOUR_UNIQUE_REFERENCE", | ||
"status": "received", | ||
"amount": { | ||
"currency": "EUR", | ||
"value": 2500 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||
"paymentReference": "Payment123", | ||
"pspReference" : "8412534564722331", | ||
"reference": "YourCancelReference", | ||
"status" : "received" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||
"paymentPspReference": "8836183819713023", | ||
"pspReference" : "8412534564722331", | ||
"reference": "Cancel123", | ||
"status" : "received" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT", | ||
"paymentPspReference": "8836183819713023", | ||
"pspReference" : "8863534564726784", | ||
"reference": "YourReversalReference", | ||
"status" : "received" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you referring to this endpoint? https://docs.adyen.com/api-explorer/#/CheckoutService/v67/post/cancels
it should be just
/cancels
? without thepayments
prefix. Maybe we can call the action justcancels
if this is the case.