Code Duplication    Length = 13-15 lines in 2 locations

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

@@ 278-290 (lines=13) @@
275
	 * Delete a source from stripe.
276
	 * @param string $source_id
277
	 */
278
	public function delete_source( $source_id ) {
279
		$response = WC_Stripe_API::request( array(), 'customers/' . $this->get_id() . '/sources/' . sanitize_text_field( $source_id ), 'DELETE' );
280
281
		$this->clear_cache();
282
283
		if ( empty( $response->error ) ) {
284
			do_action( 'wc_stripe_delete_source', $this->get_id(), $response );
285
286
			return true;
287
		}
288
289
		return false;
290
	}
291
292
	/**
293
	 * Set default source in Stripe
@@ 296-310 (lines=15) @@
293
	 * Set default source in Stripe
294
	 * @param string $source_id
295
	 */
296
	public function set_default_source( $source_id ) {
297
		$response = WC_Stripe_API::request( array(
298
			'default_source' => sanitize_text_field( $source_id ),
299
		), 'customers/' . $this->get_id(), 'POST' );
300
301
		$this->clear_cache();
302
303
		if ( empty( $response->error ) ) {
304
			do_action( 'wc_stripe_set_default_source', $this->get_id(), $response );
305
306
			return true;
307
		}
308
309
		return false;
310
	}
311
312
	/**
313
	 * Deletes caches for this users cards.