Skip to content

Conversation

eraserhead0705
Copy link

@eraserhead0705 eraserhead0705 commented Jul 13, 2021

What problem you’re solving:
The Adyen Python Library lacks support for the full Checkout API actions.
Capture
Refund
Reversals
Cancel/Technical Cancel

Our Team at Tier needs this functionality implemented in the Python library in order to fully integrate with our backend system.

Your approach to fixing the problem:
Implemented the above functionality by building on the current service/client in the code base. I added a new parameter to send a path parameter to the Adyen Api.

Any tests you wrote:
Each new action has two tests written, one success and one that mocks an error.
Additionally a test that checks for race condition.

Aleffio and others added 17 commits October 23, 2017 16:46
* [PW-4392] Update README based on the new template (Adyen#140)

* Update README based on the new template

* Update the endpoints versions

* Add the api versions in the description

* Add the example with xapi key

* Apply suggestions from code review

Co-authored-by: Ángel Campos <angel.campos@adyen.com>

* Update README.md

Co-authored-by: Alessio Zampatti <alessio.zampatti@adyen.com>

Co-authored-by: Ángel Campos <angel.campos@adyen.com>
Co-authored-by: Alessio Zampatti <alessio.zampatti@adyen.com>

* Adding cancels action

* [PW-4392] Update README based on the new template (Adyen#140)

* Update README based on the new template

* Update the endpoints versions

* Add the api versions in the description

* Add the example with xapi key

* Apply suggestions from code review

Co-authored-by: Ángel Campos <angel.campos@adyen.com>

* Update README.md

Co-authored-by: Alessio Zampatti <alessio.zampatti@adyen.com>

Co-authored-by: Ángel Campos <angel.campos@adyen.com>
Co-authored-by: Alessio Zampatti <alessio.zampatti@adyen.com>

* Adding cancels action

* Adding modifications to checkout api

Co-authored-by: Alexandros Moraitis <alexandros.moraitis@adyen.com>
Co-authored-by: Ángel Campos <angel.campos@adyen.com>
Co-authored-by: Alessio Zampatti <alessio.zampatti@adyen.com>
Co-authored-by: Eric Laff <eric.laff@tier.app>
Co-authored-by: Eric Laff <eric.laff@tier.app>
Co-authored-by: Eric Laff <eric.laff@tier.app>
@eraserhead0705
Copy link
Author

@acampos1916 Hey! This is a reopened PR per your instructions. I made the requested changes. Thanks again!

@eraserhead0705 eraserhead0705 changed the title Adding-Modification-Functionality-Checkout-To-Api Adding-Modification-Functionality-For-Checkout-Api Jul 22, 2021
@AlexandrosMor
Copy link
Contributor

Hello @eraserhead0705,
Thank you for the pull request. We see that there are old commits which is not good for the commit history. Would you mind to take care of it ?

Thank you in advance,
Alexandros
Adyen

"paymentscancel-"
"withoutreference-succes.json")

result = self.adyen.checkout.payments_cancels_without_reference(request=requests, path_param=psp_reference)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result = self.adyen.checkout.payments_cancels_without_reference(request=requests, path_param=psp_reference)
result = self.adyen.checkout.payments_refunds(request=requests, path_param=psp_reference)

if action == "paymentsResult":
action = "payments/result"
if action == "paymentsCancelsWithoutReference":
action = "payments/cancels"
Copy link
Contributor

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 the payments prefix. Maybe we can call the action just cancels if this is the case.

"paymentsresult-error-invalid-"
"data-payload-422.json")

result = self.adyen.checkout.payments_cancels_without_reference(request=requests, path_param=reference_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result = self.adyen.checkout.payments_cancels_without_reference(request=requests, path_param=reference_id)
result = self.adyen.checkout.payments_refunds(request=requests, path_param=reference_id)

self.assertEqual("Invalid payload provided", result.message['message'])
self.assertEqual("validation", result.message['errorType'])

def test_payments_refunds_raises_vaulue_error(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_payments_refunds_raises_vaulue_error(self):
def test_payments_refunds_raises_value_error(self):

"paymentscancel-"
"withoutreference-succes.json")
with self.assertRaises(ValueError) as exc:
self.adyen.checkout.payments_cancels_with_reference(request=requests, path_param="")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.adyen.checkout.payments_cancels_with_reference(request=requests, path_param="")
self.adyen.checkout.payments_refunds(request=requests, path_param="")

raise ValueError(
'must contain a pspReference in the path_param, path_param cannot be empty'
)
action = "paymentsCapture"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add this action in the client.py code? I think it's not there yet

action = "paymentsResult"
return self.client.call_checkout_api(request, action, **kwargs)

def payment_captures(self, path_param, request=None, idempotency_key=None, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def payment_captures(self, path_param, request=None, idempotency_key=None, **kwargs):
def payments_captures(self, path_param, request=None, idempotency_key=None, **kwargs):

@eraserhead0705
Copy link
Author

Hello @eraserhead0705,
Thank you for the pull request. We see that there are old commits which is not good for the commit history. Would you mind to take care of it ?

Thank you in advance,
Alexandros
Adyen

Yes sureI can clean it up.

@acampos1916
Copy link
Contributor

Thanks @eraserhead0705 let us know it goes, we can check the PR again as soon as these comments are addressed.

'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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work: call_checkout_api expects idempotency_key and path_param in a different order.

Same comment probably also applies to all other uses of call_checkout_api in this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see :) Thanks for the comment!

@yesthesoup
Copy link

hi all, my team would like to use this as well - what is blocking this PR? maybe we could help contribute

@acampos1916
Copy link
Contributor

Hello @yesthesoup, your help would be greatly appreciated. I see that @eraserhead0705 hasn’t been able to work on the suggestions from above, are you able to commit to this branch?

@eraserhead0705
Copy link
Author

eraserhead0705 commented Mar 9, 2022

Hey @acampos1916 I have the fixes on my local branch. I will try and get them pushed this week.

  • Figuring out also if it makes sense to update this PR or just open a fresh one.

@acampos1916
Copy link
Contributor

Thanks @eraserhead0705, if it’s easier to open a new one feel free to do so.

@eraserhead0705
Copy link
Author

eraserhead0705 commented Mar 9, 2022

Thanks @eraserhead0705, if it’s easier to open a new one feel free to do so.

Gonna open a new one then, in the end I think its cleaner. I will reverence it here when I do 👍

@eraserhead0705
Copy link
Author

@acampos1916 I opened a New PR, #158 for these changes.

@eraserhead0705
Copy link
Author

@acampos1916 Can I close this PR?

@acampos1916
Copy link
Contributor

Thanks @eraserhead0705, I can close it

@eraserhead0705 eraserhead0705 deleted the master branch August 19, 2022 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants