Code Duplication    Length = 23-31 lines in 2 locations

includes/class-wc-gateway-stripe.php 1 location

@@ 415-445 (lines=31) @@
412
	 * @param  object $source
413
	 * @return array()
414
	 */
415
	protected function generate_payment_request( $order, $source ) {
416
		$post_data                = array();
417
		$post_data['currency']    = strtolower( $order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency() );
418
		$post_data['amount']      = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] );
419
		$post_data['description'] = sprintf( __( '%s - Order %s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() );
420
		$post_data['capture']     = $this->capture ? 'true' : 'false';
421
422
		if ( ! empty( $order->billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) {
423
			$post_data['receipt_email'] = $order->billing_email;
424
		}
425
426
		$post_data['expand[]']    = 'balance_transaction';
427
428
		if ( $source->customer ) {
429
			$post_data['customer'] = $source->customer;
430
		}
431
432
		if ( $source->source ) {
433
			$post_data['source'] = $source->source;
434
		}
435
436
		/**
437
		 * Filter the return value of the WC_Payment_Gateway_CC::generate_payment_request.
438
		 *
439
		 * @since 3.1.0
440
		 * @param array $post_data
441
		 * @param WC_Order $order
442
		 * @param object $source
443
		 */
444
		return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $source );
445
	}
446
447
	/**
448
	 * Get payment source. This can be a new token or existing card.

includes/legacy/class-wc-gateway-stripe.php 1 location

@@ 327-349 (lines=23) @@
324
	 * @param  object $source
325
	 * @return array()
326
	 */
327
	protected function generate_payment_request( $order, $source ) {
328
		$post_data                = array();
329
		$post_data['currency']    = strtolower( $order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency() );
330
		$post_data['amount']      = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] );
331
		$post_data['description'] = sprintf( __( '%s - Order %s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() );
332
		$post_data['capture']     = $this->capture ? 'true' : 'false';
333
334
		if ( ! empty( $order->billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) {
335
			$post_data['receipt_email'] = $order->billing_email;
336
		}
337
338
		$post_data['expand[]']    = 'balance_transaction';
339
340
		if ( $source->customer ) {
341
			$post_data['customer'] = $source->customer;
342
		}
343
344
		if ( $source->source ) {
345
			$post_data['source'] = $source->source;
346
		}
347
348
		return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $source );
349
	}
350
351
	/**
352
	 * Get payment source. This can be a new token or existing card.