SwedbankPay / swedbank-pay-woocommerce-payments

Swedbank Pay Payments for WooCommerce (Beta)
https://wordpress.org/plugins/swedbank-pay-payments/
Apache License 2.0
4 stars 4 forks source link

Fix issue when WC_Swedbank_Pay_Transactions::import runs more than one time on the same transaction #114

Closed lakrisgubben closed 3 years ago

lakrisgubben commented 3 years ago

see https://github.com/SwedbankPay/swedbank-pay-woocommerce-payments/issues/112

This PR is two commits, the first one is a test that tries to run WC_Swedbank_Pay_Transactions::import twice on the same order where the second attempt will fail. The second commit tries to fix that failure.

lakrisgubben commented 3 years ago

Here I went with throwing a \SwedbankPay\Core\Exception instead of a standard Exception since that's what WC_Gateway_Swedbank_Pay_Cc::ajax_check_payment is expecting. But maybe it's better to throw a standard Exception and change WC_Gateway_Swedbank_Pay_Cc::ajax_check_payment instead? Happy for input here since I'm not so familiar with when the different Exceptions should be thrown.. :)

lakrisgubben commented 3 years ago

Looks like the failing tests have to do with missing env-vars.. Not sure what to do about that. :)

But as you can see the test run on the first commit has one error which the test run on the second does not have.

asbjornu commented 3 years ago

Thanks, @lakrisgubben! The missing environment variables are due to the PR being run from a fork:

Note: With the exception of GITHUB_TOKEN, secrets are not passed to the runner when a workflow is triggered from a forked repository.

mergify[bot] commented 3 years ago

Thank you @lakrisgubben for your contribution!