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 $post_data;
349
	}
350
351
	/**
352
	 * Get payment source. This can be a new token or existing card.

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

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