Created
November 29, 2018 17:41
-
-
Save New0/3c80baa0e0ebed7db40667e4bdcbea2e to your computer and use it in GitHub Desktop.
Custom WordPress plugin used as an extension of Direct Stripe Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: DS custom code | |
* Author: Nicolas Figueira | |
* Description: Direct Stripe custom actions and filters | |
* Plugin URI: https://gist.github.com/New0/d72217de1e60871cf938715c2fd03b61 | |
* | |
* 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; | |
$ch->save(); | |
} | |
} | |
// 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