PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.4
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.4
2.4.3 2.4.4 2.4.2 2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 All 60 releases
← All changes | includes/Gateways/PayPalGateway.php +7 -2 2.4.1 → 2.4.4 View file →
@@ -638,16 +638,21 @@
638 638 ];
639 639
640 640 if (!empty($pending)) {
641 641 $payment_id = (int) $pending[0];
642 - update_post_meta($payment_id, '_status', 'completed');
643 - update_post_meta($payment_id, '_transaction_id', '' !== $txn_id ? $txn_id : get_post_meta($payment_id, '_transaction_id', true));
642 + // The amount PayPal actually settled is written first: the record
643 + // was created with the full balance, and listeners that react to
644 + // `_status` becoming "completed" (Pro's Partial Payments, for one)
645 + // read `_amount` to decide whether the invoice is settled. Flip
646 + // the status first and a short payment reads as the full amount.
644 647 if ($amount > 0) {
645 648 update_post_meta($payment_id, '_amount', $amount);
646 649 }
650 + update_post_meta($payment_id, '_transaction_id', '' !== $txn_id ? $txn_id : get_post_meta($payment_id, '_transaction_id', true));
647 651 update_post_meta($payment_id, '_payment_date', current_time('mysql'));
648 652 update_post_meta($payment_id, '_notes', __('Payment confirmed by PayPal', 'easy-invoice'));
649 653 update_post_meta($payment_id, '_gateway_response', wp_json_encode($gateway_response));
654 + update_post_meta($payment_id, '_status', 'completed');
650 655 $this->log('Pending PayPal record #' . $payment_id . ' completed for txn ' . $txn_id);
651 656
652 657 return $payment_id;
653 658 }