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

Add filter to payment status #709

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

devbanana
Copy link

Issue: PCP-582

Ticket:

Slack Thread:


Description

Adds a filter for the status of authorized payments.

Steps to Test

Documentation

  • This PR needs documentation (has the "Documentation" label).

Changelog Entry

Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.

@devbanana devbanana requested a review from Dinamiko June 30, 2022 11:12
@Dinamiko Dinamiko requested a review from AlexP11223 July 7, 2022 10:25
@@ -109,7 +109,7 @@ protected function handle_authorization_status(
case AuthorizationStatus::CREATED:
case AuthorizationStatus::PENDING:
$wc_order->update_status(
'on-hold',
apply_filters( 'ppcp_authorized_order_status', 'on-hold' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Most of the filters in this plugin use woocommerce_paypal_payments_ prefix.

@AlexP11223
Copy link
Contributor

We check statuses in several places. Something could be broken here if someone changes the status via this filter. Maybe in some of these places we simply need to add this filter.

if ( ! is_a( $wc_order, WC_Order::class ) || $wc_order->get_status() !== 'on-hold' ) {
return;
}
if ( $order_status->name() !== OrderStatus::COMPLETED ) {
$message = __(
'Could not process WC order because PAYMENT.CAPTURE.COMPLETED webhook not received.',
'woocommerce-paypal-payments'
);
$logger->error( $message );
$wc_order->update_status( 'failed', $message );

if ( ! in_array( $wc_order->get_status(), array( 'pending', 'on-hold' ), true ) ) {
continue;
}
$wc_order->payment_complete();

if ( ! in_array( $wc_order->get_status(), array( 'pending', 'on-hold' ), true ) ) {
continue;
}
if ( $order->intent() === 'CAPTURE' ) {
$wc_order->payment_complete();
} else {
$wc_order->update_status(
'on-hold',
__( 'Payment can be captured.', 'woocommerce-paypal-payments' )
);
}

if ( $wc_order->get_status() !== 'on-hold' ) {
$response['success'] = true;
return new WP_REST_Response( $response );
}
$wc_order->add_order_note(
__( 'Payment successfully captured.', 'woocommerce-paypal-payments' )
);
$wc_order->payment_complete();
$wc_order->update_meta_data( AuthorizedPaymentsProcessor::CAPTURED_META_KEY, 'true' );

if ( $wc_order->get_status() === 'processing' || 'capture' !== $intent ) {
return;
}

if ( self::ALREADY_CAPTURED === $result_status ) {
if ( $wc_order->get_status() === 'on-hold' ) {
$wc_order->add_order_note(
__( 'Payment successfully captured.', 'woocommerce-paypal-payments' )
);
}
$wc_order->update_meta_data( self::CAPTURED_META_KEY, 'true' );

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.

None yet

3 participants