Code Duplication    Length = 23-31 lines in 2 locations

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.

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

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