Hello @trehulka,
If you can, check github (only the files include/functions.php and include/create_payment.php were updated) version of the plugin.
I added a button_id argument for the shortcode (button_id=”1″) and the $chargeID and $button_id as parameters for the actions ‘direct_stripe_before_success_redirection’ and ‘direct_stripe_before_error_redirection’.
With that you could add an action in your (child-)theme’s functions.php file to add metadata, like so :
function my_direct_stripe_action($chargeID, $post_id, $button_id) {
if( $button_id === '1') {
$ch = \Stripe\Charge::retrieve($chargeID);
$ch->metadata[my_key]=my_var;
$ch->save();
}
}
add_action( 'direct_stripe_before_success_redirection', 'my_direct_stripe_action', 10, 3 );
Of couse you would have to find your best way to retrieve and make ‘my_var’ the precise or random data you need per payment.
Cheers!
Nicolas
Works great! Will you push it live? Thanks!
Cool that you found it useful!
I’ll try to make an update within the next two weeks.
Best regards
Hey,
Just wanted to say thank you for this, I was looking for a simple way to integrate Stripe to a website that was using Paypal IPN and it works great.
I did some changes to display the metadata in the wp-admin under the Logs Direct Stripe by modifying the direct_stripe_logs_colums_names and direct_stripe_manage_logs_columns functions directly in the plugin but was wondering if there is a better way to do it?
Should I remove the action and add a new one instead? I not sure how to do it so if you have an example that would be great.
Thanks in advance for your answer,
Best regards,
Julien
Hello @jcuenin,
Thank you for using Direct Stripe.
I dont think there’s another way to edit Direct Stripe logs data right now, and I stopped editing / adding features to the plugin as it is.
I am developing version 2 with refactored code and more hooks, i will definitely add filters to add the possibility to edit logs data and keep direct stripe up to date.
As always I can’t promise any release date…
I will post an example of how to use those filters when v2 comes out.
Please, open your own thread next time 😉
Best wishes
Thank you for your quick answer, I didn’t open a new thread as I thought it was more relevant to answer this one but no problem will do next time.
I will carry on this way for now unless I find a way to create filters.
I didn’t know you were on a v2 and would be glad to help when I have some time.
Cheers
-
This reply was modified 9 years ago by
jcuenin.