Code Duplication    Length = 6-7 lines in 2 locations

includes/gateways/paypal.php 2 locations

@@ 367-372 (lines=6) @@
364
	}
365
366
	// Verify payment currency
367
	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
368
		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
369
		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
370
		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ), '', '', true );
371
		return;
372
	}
373
374
	if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
375
		// This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
@@ 415-421 (lines=7) @@
412
			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ), '', '', true );
413
			return;
414
		}
415
		if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
416
			// Purchase keys don't match
417
			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
418
			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
419
			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ), '', '', true );
420
			return;
421
		}
422
423
		if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
424
			wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ), '', '', true );