Code Duplication    Length = 6-7 lines in 3 locations

includes/gateways/worldpay.php 1 location

@@ 132-138 (lines=7) @@
129
                wpinv_set_payment_transaction_id( $invoice_id, $request['transId'] );
130
                wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Worldpay Transaction ID: %s', 'invoicing' ), $request['transId'] ) );
131
                return;
132
            } else if ( $request['transStatus'] == 'C' ) {
133
                wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
134
                wpinv_insert_payment_note( $invoice_id, __( 'Payment transaction failed while processing Worldpay payment, kindly check IPN log.', 'invoicing' ) );
135
                
136
                wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Payment transaction failed while processing Worldpay payment. IPN data: %s', 'invoicing' ), json_encode( $request ) ), $invoice_id );
137
                return;
138
            }
139
        }
140
    }
141
    return;

includes/gateways/paypal.php 2 locations

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