Code Duplication    Length = 19-19 lines in 2 locations

includes/gateways/paypal.php 1 location

@@ 645-663 (lines=19) @@
642
643
    $subscription = new WPInv_Subscription( $ipn_data['subscr_id'], true );
644
645
    if( ! $subscription || $subscription->id < 1 ) {
646
647
        $subs_db      = new WPInv_Subscriptions_DB;
648
        $subs         = $subs_db->get_subscriptions( array( 'parent_payment_id' => $parent_invoice_id, 'number' => 1 ) );
649
        $subscription = reset( $subs );
650
651
        if( $subscription && $subscription->id > 0 ) {
652
653
            // Update the profile ID so it is set for future renewals
654
            $subscription->update( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) );
655
656
        } else {
657
658
            // No subscription found with a matching payment ID, bail
659
            return false;
660
661
        }
662
663
    }
664
665
    return $subscription;
666

includes/gateways/authorizenet.php 1 location

@@ 633-651 (lines=19) @@
630
631
    $subscription = new WPInv_Subscription( $subscription_id, true );
632
633
    if( ! $subscription || $subscription->id < 1 ) {
634
635
        $subs_db      = new WPInv_Subscriptions_DB;
636
        $subs         = $subs_db->get_subscriptions( array( 'parent_payment_id' => $parent_invoice_id, 'number' => 1 ) );
637
        $subscription = reset( $subs );
638
639
        if( $subscription && $subscription->id > 0 ) {
640
641
            // Update the profile ID so it is set for future renewals
642
            $subscription->update( array( 'profile_id' => sanitize_text_field( $subscription_id ) ) );
643
644
        } else {
645
646
            // No subscription found with a matching payment ID, bail
647
            return false;
648
649
        }
650
651
    }
652
653
    return $subscription;
654