Through the use of WordPress Filters, MemberMouse allows you to customize certain data that is passed to Stripe when a transaction is processed. Filters are functions that WordPress passes data through, just before taking some action. These functions can modify or replace the data flowing through them. MemberMouse defines its own set of filters that you can use. To learn more about these, you can see the MemberMouse WordPress Filters article.


Our plugin passes two pieces of descriptive information to Stripe:


Description - This searchable field appears in your list of payments on the Stripe Dashboard

Statement Descriptor - Data in this field appears on the purchasers credit card statement


As MemberMouse has evolved, we've introduced new methods for communicating with Stripe. For MemberMouse 2.3.0 and greater, the recommended method is Stripe Elements. The older method is known as Stripe.js. Depending on which method your site uses, the filters we provide function differently. You can determine which method is currently enabled for your site by examining the checkboxes in your Stripe configuration, found in MemberMouse > Payment Settings.



Overview of Descriptive Data Filters


Utilizing these filters requires that you create a custom PHP function, and then subscribe it to the filter. When the filter is triggered, it passes two pieces of data to your function. The first, $descriptor or $description, contains the default information MemberMouse will send unless modified. The second$order, is a standard class object that contains data about to the order placed in MemberMouse. Your function can use the data in this object to include order-specific information. For reference, here is an  example order object. Ultimately, your function will return data, which is then passed on to Stripe.


The text string you return is subject to character limits, and exceeding these limits may cause the transaction to fail. For Description, the limit is 320 characters. However, the limit for the Statement Descriptor is much smaller, at only 22 characters.


Managing your custom code is easiest when it's installed on your site as a WordPress plugin. Please see this article for instructions on creating a site-specific plugin. For easy installation, the downloadable examples below are already in this format.





Descriptive Filters Available with Stripe Elements


By default, MemberMouse sends the following descriptive information when Stripe Elements is enabled:


Description is "Purchase from [Your Site Name]"

Statement Descriptor is "Order# [Order Number]"




mm_stripe_paymentintent_description


 Available in MM 2.4.0+ 


Download Example Plugin


This filter allows you to customize the Description. For example, to set this field to Order# 1234, Item: Digital Membership you could use the following function in your plugin:


add_filter('mm_stripe_paymentintent_description', function($description, $order) { 
   $description = "Order # ".$order->orderNumber;
   if (isset($order->orderProducts) && is_array($order->orderProducts)) {
        $description .= ", Item: ".array_pop($order->orderProducts)->description;
   }
   return $description;
},1,2);



mm_stripe_statement_billing_descriptor


Available in MM 2.3.0+ 


Download Example Plugin


You can use this filter to customize the Statement Descriptor. In this example, the first 22 characters of the product name are sent to Stripe. Note that Stripe will append this to the "Shortened Descriptor" configured in your Stripe Dashboard Settings, and the total length of the two combined elements is truncated at 22 characters. As a result, less that 22 characters of the product name will actually appear on the member's credit card statement.


add_filter('mm_stripe_billing_statement_descriptor', function($descriptor, $order) { 
    if (isset($order->orderProducts) && is_array($order->orderProducts)) {
        $fullDescription = array_pop($order->orderProducts)->description;
        $descriptor = substr($fullDescription,0,22);
    }
    return $descriptor;
},1,2);





Descriptive Filters Available with Stripe.js


When Stripe.js is enabled, MemberMouse sends only the Description. The Statement Descriptor is not included, meaning that all transactions will use the full Statement Descriptor specified in your Stripe Dashboard Settings. For this reason, only a single filter is available.


By default, MemberMouse includes the Description for all payments. However, initial payments are treated differently than rebills.


For the initial payment you will only see the order ID passed:

For example, Order# 10043 


For rebill payments, you will see the order ID and product description:

For example, Order# 10043, Item: Digital Membership 




mm_stripe_billing_statement_descriptor 


Download Example Plugin


You can use this filter to change the Description. For example, the following code will set the description so that for both initial payments and rebills, the Description includes both the order number and the product description.


Important Note: When Stripe.js is enabled, this filter acts on the Description, but its behavior changes when Stripe Elements is enabled, and it then modifies the Statement Descriptor instead. Because the Statement Descriptor is limited to 22 characters, customers using this filter with Stripe.js will likely need to revise or remove the code when switching to Stripe Elements.


add_filter('mm_stripe_billing_statement_descriptor', function($descriptor, $order) { 
   $descriptor = "Order # ". $order->orderNumber;
   if (isset($order->orderProducts) && is_array ($order->orderProducts)) {
        $descriptor .= ", Item: ". array_pop($order->orderProducts)->description;
   }
   return $descriptor;
},1,2);


In this case you'll see something like the following in Stripe: 

Order# 10043, Item: Basic Membership