Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JarrydLong/c9678a468ba2a0b99b56eb082025d1ee to your computer and use it in GitHub Desktop.
Save JarrydLong/c9678a468ba2a0b99b56eb082025d1ee to your computer and use it in GitHub Desktop.
Updates the payment description in Stripe when purchasing a subscription using Stripe Checkout.
<?php
/**
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
*/
// Copy from below this line
/**
* Updates the payment description in Stripe when purchasing a subscription using Stripe Checkout.
*/
function my_pmpro_stripe_checkout_session_parameters_subscription_description( $checkout_session_params, $morder ) {
$user = get_userdata( $morder->user_id );
$email = empty( $user->user_email ) ? '' : $user->user_email;
$description = "Order #" . $morder->code . ", " . trim( $morder->billing->name ) . " (" . $email . ") - ".$morder->membership_level->name;
if ( $checkout_session_params['mode'] === 'subscription' ) {
$checkout_session_params['subscription_data']['description'] = $description;
} else {
$checkout_session_params['payment_intent_data']['description'] = $description;
}
return $checkout_session_params;
}
add_filter( 'pmpro_stripe_checkout_session_parameters', 'my_pmpro_stripe_checkout_session_parameters_subscription_description', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment