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

Multiple issues after #106 #112

Closed lakrisgubben closed 3 years ago

lakrisgubben commented 3 years ago

Hi,

PR #106 that was done to fix issue #105 unfortunately creates more issues. :/ The issues can be seen by going to the thank you page after completing an order so that the WC_Gateway_Swedbank_Pay_Cc::ajax_check_payment method is run. This'll trigger the WC_Swedbank_Pay_Transactions::import method and if the order already exists (i.e. the first if clause is not triggered) then the $wpdb->update(...) call triggers an error "WordPress database error Unknown column 'isOperational'..." and the method trows an Exception on line 331.. This in turns triggers a fatal error since WC_Gateway_Swedbank_Pay_Cc::ajax_check_payment is expecting an instance of \SwedbankPay\Core\Exception.

I guess the most common way for the order to already exist in the transaction table is because a callback has already come in from Swedbank pay to create it (that's how I noticed it). But you can also trigger this error by just reloading the thank you page after it has fetched the data from Swedbank.

Not sure why #106 changed from using $this->prepare and $this->update to using $wpdb. But if I change that back and just fix the two issues reported in #105 and change so both WC_Gateway_Swedbank_Pay_Cc::ajax_check_payment and WC_Swedbank_Pay_Transactions::import uses the same exception then everything seems to work great. :)

asbjornu commented 3 years ago

We warmly welcome pull reuqests, @lakrisgubben. You're free to submit one if you want to. But we'll look at this as soon as time allows.

lakrisgubben commented 3 years ago

Thanks @asbjornu. I'll try to find some time tomorrow for a PR. :)