Code Duplication    Length = 8-15 lines in 3 locations

includes/gateways/stripe/includes/class-give-stripe-customer.php 1 location

@@ 379-386 (lines=8) @@
376
			// Return Card Details, if exists.
377
			if ( ! empty( $card->id ) ) {
378
				$this->attached_source = $card;
379
			} else {
380
381
				give_set_error( 'stripe_error', __( 'An error occurred while processing the donation. Please try again.', 'give' ) );
382
				give_record_gateway_error( __( 'Stripe Error', 'give' ), __( 'An error occurred retrieving or creating the ', 'give' ) );
383
				give_send_back_to_checkout( '?payment-mode=stripe' );
384
385
				$this->attached_source = false;
386
			}
387
		} // End if().
388
	}
389

includes/gateways/stripe/includes/class-give-stripe-gateway.php 1 location

@@ 374-383 (lines=10) @@
371
			// Return Card Details, if exists.
372
			if ( ! empty( $card->id ) ) {
373
				return $card;
374
			} else {
375
376
				give_set_error( 'stripe_error', __( 'An error occurred while processing the donation. Please try again.', 'give' ) );
377
				give_record_gateway_error( __( 'Stripe Error', 'give' ), __( 'An error occurred retrieving or creating the ', 'give' ) );
378
379
				// Send donor back to checkout page on error.
380
				$this->send_back_to_checkout();
381
382
				return false;
383
			}
384
		}
385
386
		/**

includes/gateways/stripe/includes/payment-methods/class-give-stripe-card.php 1 location

@@ 275-289 (lines=15) @@
272
					// Send them to success page.
273
					give_send_to_success_page();
274
275
				} else {
276
277
					// No customer, failed.
278
					give_record_gateway_error(
279
						__( 'Stripe Customer Creation Failed', 'give' ),
280
						sprintf(
281
							/* translators: %s Donation Data */
282
							__( 'Customer creation failed while processing the donation. Details: %s', 'give' ),
283
							wp_json_encode( $donation_data )
284
						)
285
					);
286
					give_set_error( 'stripe_error', __( 'The Stripe Gateway returned an error while processing the donation.', 'give' ) );
287
					give_send_back_to_checkout( "?payment-mode={$this->id}" );
288
289
				} // End if().
290
			} else {
291
				give_send_back_to_checkout( "?payment-mode={$this->id}" );
292
			} // End if().