There is an action hook processed just before any successful transaction that can be used to add (for example) a receipt_email to the current charge :

Tha action is ‘direct_stripe_before_success_redirection’

Its parameters are :

  1. Charge ID – ID of the Charge that was just created with Stripe API
  2. Post ID – ID of the log created for the current transaction
  3. Button ID – ID set with the shortcode parameter “button_id”
  4. User ID – ID of the Stripe User

Here we go :

function my_direct_stripe_action($chargeID, $post_id, $button_id, $user_id) {
 // Add the action for a precise button setting a button_id
 if( $button_id === '1') {
 // Retrieve the user to identify its email address
 $user = get_user_by( 'ID', $user_id );
 $email_address = $user->user_email;
 //Retrieve Stripe Charge and update it
 $ch = \Stripe\Charge::retrieve($chargeID);
 $ch->receipt_email = $email_address;

// Pass the function 'my_direct_stripe_action' through the action with priority 10 and 4 parameters
add_action( 'direct_stripe_before_success_redirection', 'my_direct_stripe_action', 10, 4 );

If you are in a testing environment, stripe don’t send the receipt but you can check in the logs that the charge was updated.

2 thoughts on “Add receipt_email to charge via action hook in Direct Stripe

  1. Hello,

    I’ve posted a comment on this topic elsewhere but I can’t find my way back to it.
    can you lead me to it ?

    I also know you responded to my comment with a whole solution and you’re of great help !

    Thank you very much !


Leave a Reply

Your email address will not be published. Required fields are marked *