• Resolved llevenson

    (@llevenson)


    I want to pass a hidden field with Product Name in it through Stripe. How can I do this?

    Of course, I am using your plugin and WooCommerce.

    Thanks,
    Larry

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Support Job a11n

    (@jobthomas)

    Automattic Happiness Engineer

    @llevenson – only order numbers are passed on to Stripe. What exactly do you have in mind as the purpose for passing on the products?

    Thread Starter llevenson

    (@llevenson)

    Hey, @jobthomas,

    I am selling training courses and want to have the name of the course that you registered for come back to me so I can add it to the webinar platform (with Zapier). I can parse metadata coming from Stripe. But need to have the course name in a hidden field of the Stripe form.

    Or is there another way to go about this??

    Thanks!
    Larry

    Plugin Support Job a11n

    (@jobthomas)

    Automattic Happiness Engineer

    @llevenson wouldn’t it be an option to get those details from your WooCommerce store instead? WC registers if your payment has come through and can send you those product details.

    Also, there are several WP LMSs (including Automattic’s Sensei) that work well with WooCommerce, so maybe that’s an option too?

    I’d like to tag onto this question. I need either product skus or descriptions to pass to Stripe also. Yes, I know you could get those details from WooCommerce store instead, but our treasurer does not have access to the WooCommerce Store. Just to Stripe. She needs to code deposits based on product/category. Certainly this is not a new question. Especially when you can download sales data from Stripe to go into QuickBooks, you would want to know what was sold. Any idea?

    Trinitech

    (@trinitech)

    Hi guys,

    Did any of you managed to get it working as I have the same requirement?

    Thank you

    samrhein

    (@samrhein)

    Hi folks, you can use the filter wc_stripe_payment_metadata. For example:

    //add order details to Stripe payment metadata
    function filter_wc_stripe_payment_metadata( $metadata, $order, $source ) {
        $order_data = $order->get_data();
        $metadata['Total Tax Charged'] = $order_data['total_tax'];
        $metadata['Total Shipping Charged'] = $order_data['shipping_total'];
        $count = 1;
        foreach( $order->get_items() as $item_id => $line_item ){
            $item_data = $line_item->get_data();
            $product = $line_item->get_product();
            $product_name = $product->get_name();
            $item_quantity = $line_item->get_quantity();
            $item_total = $line_item->get_total();
            $metadata['Line Item '.$count] = 'Product name: '.$product_name.' | Quantity: '.$item_quantity.' | Item total: '. number_format( $item_total, 2 );
            $count += 1;
        }
    
        return $metadata;
    }
    add_filter( 'wc_stripe_payment_metadata', 'filter_wc_stripe_payment_metadata', 10, 3 );
    r0bm1lls

    (@r0bm1lls)

    Excuse stupid question – would this code go into theme functions.php? If so tried – not working.

    samrhein

    (@samrhein)

    Yep, functions.php. Maybe this doesn’t support certain product types – what product type did you test it with? I’m successfully using it with Simple and Variable product orders.

    Try turning on Stripe error logging in WooCommerce at /wp-admin/admin.php?page=wc-settings&tab=checkout&section=stripe ‘Log debug messages’ at the bottom. Make a purchase, then at /wp-admin/admin.php?page=wc-status&tab=logs view the ‘woocommerce-gateway-stripe…’ log. It should log something like this for the transaction:

    11-16-2017 @ 17:36:09 - Info: Begin processing payment for order 61 for the amount of 1.00
    11-16-2017 @ 17:36:09 - charges request: Array
    (
        [currency] => usd
        [amount] => 100
        [description] => Test Store - Order 61
        [capture] => true
        [expand[]] => balance_transaction
        [metadata] => Array
            (
                [Customer Name] => John Doe
                [Customer Email] => [email protected]
                [Total Tax Charged] => 0
                [Total Shipping Charged] => 0
                [Line Item 1] => Product name: Test Simple Product | Quantity: 1 | Item total: 1.00
            )
    
        [source] => XXXXXXXXXXXXXXXXXXXXXXX
    )

    In Stripe the payment Metadata is viewable when you click on a payment for more details from here https://dashboard.stripe.com/payments. e.g.

    Metadata

    Customer Email – [email protected]
    Customer Name – John Doe
    Line Item 1 – Product name: Test Simple Product | Quantity: 1 | Item total: 1.00
    Total Shipping Charged – 0
    Total Tax Charged – 0

    Trinitech

    (@trinitech)

    @samrhein

    Thank you very much for your snippet!
    It work perfectly and answered all my needs ??

    Ares

    (@ismartpink)

    This code no longer works and breaks my site with a Fatal error.
    As addressed earlier I would like wordpress to pass item details to Stripe – so Stripe receipts can portray real item name description, now what Stripe receipt displays is Receipt number and Company name.

    @ismartpink I confirmed that the code still works with WooCommerce version 3.3.3 and WooCommerce Stripe Gateway version 4.0.7. Perhaps you are using older versions of these plugins or have a plugin/theme conflict. What’s the fatal error you’re getting?

    Plugin Support stephjacq a11n

    (@stephjacq)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to pass product name through Stripe’ is closed to new replies.