I have added a custom checkout field to my WooCommerce web site. I have added and enabled Stripe plugin, as payment gateway… Is there a way to have this custom fields value sent as data to Stripe payment gateway?
I have searched everywhere but couldn't find anything.
I have added a custom checkout field to my WooCommerce web site. I have added and enabled Stripe plugin, as payment gateway… Is there a way to have this custom fields value sent as data to Stripe payment gateway?
I have searched everywhere but couldn't find anything.
Share Improve this question edited Sep 2, 2019 at 17:43 LoicTheAztec 3,39117 silver badges24 bronze badges asked Sep 2, 2019 at 9:30 ShadowShadow 571 silver badge7 bronze badges 1- This is probably best answered by looking through the woocommerce Stripe plugin, if you can do that yourself, for the point where it assembles the data sent to Stripe to see if there are any obvious hooks you can use. If not, you can always fork the plugin and add the extra function to your own private copy. – Rup Commented Sep 2, 2019 at 9:36
1 Answer
Reset to default 5You can use wc_stripe_payment_metadata
dedicated filter hook to add (pass) some custom meta data to Stripe gateway, this way:
add_filter( 'wc_stripe_payment_metadata', 'stripe_payment_metadata_filter_callback', 10, 3 );
function stripe_payment_metadata_filter_callback( $metadata, $order, $prepared_source ) {
// Here below define your custom field meta key (as it's saved in wp_postmeta DB table)
$metadata = 'custom_meta_key';
$metadata[ __( 'Custom Label Text (or meta key)', 'woocommerce-gateway-stripe' ) ] = $order->get_meta($meta_key);
return $metadata;
}
Code goes in functions.php file of your active child theme (or active theme). It should work.
Related threads:
- WooCommerce Stripe official documentation - Filter Hooks section
- WooCommerce Stripe: Add Custom MetaData (April 2018)
- Send Variation options to stripe as metadata with WooCommerce (May 2018)