Code Duplication    Length = 15-18 lines in 3 locations

includes/class-wc-stripe-webhook-handler.php 3 locations

@@ 223-237 (lines=15) @@
220
	 * @since 4.0.0
221
	 * @param object $notification
222
	 */
223
	public function process_webhook_dispute( $notification ) {
224
		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge );
225
226
		if ( ! $order ) {
227
			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->charge );
228
			return;
229
		}
230
231
		$order->update_status( 'on-hold', __( 'A dispute was created for this order. Response is needed. Please go to your Stripe Dashboard to review this dispute.', 'woocommerce-gateway-stripe' ) );
232
233
		do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification );
234
235
		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
236
		$this->send_failed_order_email( $order_id );
237
	}
238
239
	/**
240
	 * Process webhook capture. This is used for an authorized only
@@ 338-355 (lines=18) @@
335
	 * @version 4.0.0
336
	 * @param object $notification
337
	 */
338
	public function process_webhook_charge_failed( $notification ) {
339
		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
340
341
		if ( ! $order ) {
342
			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id );
343
			return;
344
		}
345
346
		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
347
348
		if ( 'on-hold' !== $order->get_status() ) {
349
			return;
350
		}
351
352
		$order->update_status( 'failed', __( 'This payment failed to clear.', 'woocommerce-gateway-stripe' ) );
353
354
		do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification );
355
	}
356
357
	/**
358
	 * Process webhook source canceled. This is used for payment methods
@@ 365-382 (lines=18) @@
362
	 * @version 4.0.0
363
	 * @param object $notification
364
	 */
365
	public function process_webhook_source_canceled( $notification ) {
366
		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
367
368
		if ( ! $order ) {
369
			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id );
370
			return;
371
		}
372
373
		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
374
375
		if ( 'on-hold' !== $order->get_status() || 'cancelled' !== $order->get_status() ) {
376
			return;
377
		}
378
379
		$order->update_status( 'cancelled', __( 'This payment has cancelled.', 'woocommerce-gateway-stripe' ) );
380
381
		do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification );
382
	}
383
384
	/**
385
	 * Process webhook refund.