Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Custom WordPress plugin used as an extension of Direct Stripe Plugin
* Plugin Name: DS custom code
* Author: Nicolas Figueira
* Description: Direct Stripe custom actions and filters
* Plugin URI:
* This code is an add-on of Direct Stripe WordPress plugin
//Add the email receipt parameter to the Stripe user after a successfull charge
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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment