Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @sandeld

    Thanks for reaching out!

    I understand that you would like the VAT amount to be displayed under your Stripe’s transactions, correct?

    I checked the Github Repository and found that this was already reported as a bug here: https://github.com/woocommerce/woocommerce-gateway-stripe/issues/2103

    I would suggest subscribing to the thread to keep posted for updates.

    Thanks!

    Thread Starter sandeld

    (@sandeld)

    Thanks for the link. Looks like this is never going to get implemented. What a shame. Can you at least tell me how to correctly hook into this function from functions.php?

    You can see I’ve already edited the $metadata object directly in the plugin code by adding:

    'order_tax' => $order->get_total_tax(),

    But obviously it’s better to leave that alone and call it from the child theme.

    public function generate_payment_request( $order, $prepared_payment_method ) {
    		$settings                              = get_option( 'woocommerce_stripe_settings', [] );
    		$statement_descriptor                  = ! empty( $settings['statement_descriptor'] ) ? str_replace( "'", '', $settings['statement_descriptor'] ) : '';
    		$short_statement_descriptor            = ! empty( $settings['short_statement_descriptor'] ) ? str_replace( "'", '', $settings['short_statement_descriptor'] ) : '';
    		$is_short_statement_descriptor_enabled = ! empty( $settings['is_short_statement_descriptor_enabled'] ) && 'yes' === $settings['is_short_statement_descriptor_enabled'];
    		$capture                               = ! empty( $settings['capture'] ) && 'yes' === $settings['capture'] ? true : false;
    		$post_data                             = [];
    		$post_data['currency']                 = strtolower( $order->get_currency() );
    		$post_data['amount']                   = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $post_data['currency'] );
    		/* translators: 1) blog name 2) order number */
    		$post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() );
    		$billing_email            = $order->get_billing_email();
    		$billing_first_name       = $order->get_billing_first_name();
    		$billing_last_name        = $order->get_billing_last_name();
    
    		if ( ! empty( $billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) {
    			$post_data['receipt_email'] = $billing_email;
    		}
    
    		switch ( $order->get_payment_method() ) {
    			case 'stripe':
    				if ( $is_short_statement_descriptor_enabled && ! ( empty( $short_statement_descriptor ) && empty( $statement_descriptor ) ) ) {
    					$post_data['statement_descriptor'] = WC_Stripe_Helper::get_dynamic_statement_descriptor( $short_statement_descriptor, $order, $statement_descriptor );
    				} elseif ( ! empty( $statement_descriptor ) ) {
    					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor );
    				}
    
    				$post_data['capture'] = $capture ? 'true' : 'false';
    				break;
    			case 'stripe_sepa':
    				if ( ! empty( $statement_descriptor ) ) {
    					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor );
    				}
    				// other payment methods error if we try to add a statement descriptor in the request
    		}
    
    		if ( method_exists( $order, 'get_shipping_postcode' ) && ! empty( $order->get_shipping_postcode() ) ) {
    			$post_data['shipping'] = [
    				'name'    => trim( $order->get_shipping_first_name() . ' ' . $order->get_shipping_last_name() ),
    				'address' => [
    					'line1'       => $order->get_shipping_address_1(),
    					'line2'       => $order->get_shipping_address_2(),
    					'city'        => $order->get_shipping_city(),
    					'country'     => $order->get_shipping_country(),
    					'postal_code' => $order->get_shipping_postcode(),
    					'state'       => $order->get_shipping_state(),
    				],
    			];
    		}
    
    		$post_data['expand[]'] = 'balance_transaction';
    
    		$metadata = [
    			__( 'customer_name', 'woocommerce-gateway-stripe' ) => sanitize_text_field( $billing_first_name ) . ' ' . sanitize_text_field( $billing_last_name ),
    			__( 'customer_email', 'woocommerce-gateway-stripe' ) => sanitize_email( $billing_email ),
    			'order_tax' => $order->get_total_tax(),
    			'order_id' => $order->get_order_number(),
    			'site_url' => esc_url( get_site_url() ),
    		];
    
    		if ( $this->has_subscription( $order->get_id() ) ) {
    			$metadata += [
    				'payment_type' => 'recurring',
    			];
    		}
    
    		$post_data['metadata'] = apply_filters( 'wc_stripe_payment_metadata', $metadata, $order, $prepared_payment_method );
    
    		if ( $prepared_payment_method->customer ) {
    			$post_data['customer'] = $prepared_payment_method->customer;
    		}
    
    		if ( ! empty( $prepared_payment_method->source ) ) {
    			$post_data['source'] = $prepared_payment_method->source;
    		}
    
    		if ( ! empty( $prepared_payment_method->payment_method ) ) {
    			$post_data['payment_method'] = $prepared_payment_method->payment_method;
    		}
    
    		/**
    		 * Filter the return value of the WC_Payment_Gateway_CC::generate_payment_request.
    		 *
    		 * @since 3.1.0
    		 * @param array $post_data
    		 * @param WC_Order $order
    		 * @param object $source
    		 */
    		return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $prepared_payment_method );
    	}

    Hi @sandeld

    I understand that you would like to do custom coding as a workaround for this issue.

    Kindly be informed that custom coding is outside our scope of support, hence, I am leaving this thread open for a bit to see if anyone can chime in to help you out.

    For questions related to development and custom coding, your best bet is to ask on any of these channels for support. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    Hope this helps!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Taxes not sent to Stripe’ is closed to new replies.