Code Duplication    Length = 10-10 lines in 3 locations

payment_methods/Paypal_Express/EEG_Paypal_Express.gateway.php 3 locations

@@ 148-157 (lines=10) @@
145
        $notify_url = null,
146
        $cancel_url = null
147
    ) {
148
        if (! $payment instanceof EEI_Payment) {
149
            $payment->set_gateway_response(
150
                esc_html__(
151
                    'Error. No associated payment was found.',
152
                    'event_espresso'
153
                )
154
            );
155
            $payment->set_status($this->_pay_model->failed_status());
156
            return $payment;
157
        }
158
        $transaction = $payment->transaction();
159
        if (! $transaction instanceof EEI_Transaction) {
160
            $payment->set_gateway_response(
@@ 159-168 (lines=10) @@
156
            return $payment;
157
        }
158
        $transaction = $payment->transaction();
159
        if (! $transaction instanceof EEI_Transaction) {
160
            $payment->set_gateway_response(
161
                esc_html__(
162
                    'Could not process this payment because it has no associated transaction.',
163
                    'event_espresso'
164
                )
165
            );
166
            $payment->set_status($this->_pay_model->failed_status());
167
            return $payment;
168
        }
169
        $order_description = mb_strcut($this->_format_order_description($payment), 0, 127);
170
        $primary_registration = $transaction->primary_registration();
171
        $primary_attendee = $primary_registration instanceof EE_Registration
@@ 269-278 (lines=10) @@
266
        if ($payment instanceof EEI_Payment) {
267
            $this->log(array('Return from Authorization' => $update_info), $payment);
268
            $transaction = $payment->transaction();
269
            if (! $transaction instanceof EEI_Transaction) {
270
                $payment->set_gateway_response(
271
                    esc_html__(
272
                        'Could not process this payment because it has no associated transaction.',
273
                        'event_espresso'
274
                    )
275
                );
276
                $payment->set_status($this->_pay_model->failed_status());
277
                return $payment;
278
            }
279
            $primary_registrant = $transaction->primary_registration();
280
            $payment_details = $payment->details();
281
            // Check if we still have the token.