Skip to content
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

Prevent order status change on callback once processed once #108

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions classes/class-wc-klarna-pending-orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@

$order = wc_get_order( $order_id );

// If a paid date is set, the order has already been processed. It is therefore not a pending order.
if ( ! empty( $order->get_date_paid() ) ) {
return;
}

// Use the order from Klarna for the fraud status check.
if ( 'ACCEPTED' === $klarna_order->fraud_status ) {
$order->payment_complete( $klarna_order_id );
Expand Down Expand Up @@ -86,9 +91,9 @@
private static function get_order_id_from_klarna_order_id( $klarna_order_id ) {
$orders = wc_get_orders(
array(
'meta_query' => array(

Check warning on line 94 in classes/class-wc-klarna-pending-orders.php

View workflow job for this annotation

GitHub Actions / phpcs

Detected usage of meta_query, possible slow query.
'meta_key' => '_wc_klarna_order_id',

Check warning on line 95 in classes/class-wc-klarna-pending-orders.php

View workflow job for this annotation

GitHub Actions / phpcs

Detected usage of meta_key, possible slow query.
'meta_value' => $klarna_order_id,

Check warning on line 96 in classes/class-wc-klarna-pending-orders.php

View workflow job for this annotation

GitHub Actions / phpcs

Detected usage of meta_value, possible slow query.
'compare' => '=',
),
)
Expand Down
Loading