Code Duplication    Length = 13-15 lines in 2 locations

includes/class-wc-stripe-customer.php 2 locations

@@ 253-265 (lines=13) @@
250
	 * Delete a card from stripe.
251
	 * @param string $card_id
252
	 */
253
	public function delete_card( $card_id ) {
254
		$response = WC_Stripe_API::request( array(), 'customers/' . $this->get_id() . '/sources/' . sanitize_text_field( $card_id ), 'DELETE' );
255
256
		$this->clear_cache();
257
258
		if ( ! is_wp_error( $response ) ) {
259
			do_action( 'wc_stripe_delete_card', $this->get_id(), $response );
260
261
			return true;
262
		}
263
264
		return false;
265
	}
266
267
	/**
268
	 * Set default card in Stripe
@@ 271-285 (lines=15) @@
268
	 * Set default card in Stripe
269
	 * @param string $card_id
270
	 */
271
	public function set_default_card( $card_id ) {
272
		$response = WC_Stripe_API::request( array(
273
			'default_source' => sanitize_text_field( $card_id ),
274
		), 'customers/' . $this->get_id(), 'POST' );
275
276
		$this->clear_cache();
277
278
		if ( ! is_wp_error( $response ) ) {
279
			do_action( 'wc_stripe_set_default_card', $this->get_id(), $response );
280
281
			return true;
282
		}
283
284
		return false;
285
	}
286
287
	/**
288
	 * Deletes caches for this users cards.