Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfromthelc committed Nov 15, 2024
1 parent d3b7af8 commit 2d8e73e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/inc/payment-gateways/lib/stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,38 +309,43 @@ public static function convert_dispute_reason_to_sift_chargeback_reason( string
}
}

/**
* Send a chargeback event to Sift.
*
* @param object $event The Stripe event object.
*
* @return void
*/
public static function send_chargeback_to_sift( $event ): void {
// Extract the charge ID and the original dispute reason.
$charge_id = $event->charge ?? null;
$dispute_reason = $event->reason ?? null;
$charge_id = $event->charge ?? null;
$dispute_reason = $event->reason ?? null;

if ( ! $charge_id || ! $dispute_reason ) {
wc_get_logger()->error( 'Missing charge ID or dispute reason in the Stripe dispute event.' );
return;
}

// Get the order ID from the Stripe charge ID using the helper method from the Stripe class.
// Get the order ID from the Stripe charge ID.
$order_id = self::get_order_from_charge_id( $charge_id );
if ( ! $order_id ) {
wc_get_logger()->error( 'Order ID not found for the Stripe charge ID: ' . esc_html( $charge_id ) );
return;
}

// Get the WooCommerce order object.
$order = wc_get_order( $order_id );
if ( ! $order instanceof WC_Order ) {
wc_get_logger()->error( 'WooCommerce order not found for Order ID: ' . esc_html( $order_id ) );
return;
}

// Convert the Stripe dispute reason to the Sift chargeback reason using the helper method from the Stripe class.
// Convert the Stripe dispute reason to the Sift chargeback reason
$chargeback_reason = self::convert_dispute_reason_to_sift_chargeback_reason( $dispute_reason );
if ( ! $chargeback_reason ) {
wc_get_logger()->error( 'Unable to convert Stripe dispute reason to Sift chargeback reason: ' . esc_html( $dispute_reason ) );
return;
}

// Call the action to handle the chargeback event.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'sift_for_woocommerce_chargeback', $order_id, $order, $chargeback_reason );
}
}

0 comments on commit 2d8e73e

Please sign in to comment.