I’m using it in the WC Lovers Marketplace Frontend Manager. Being able to filter the Stripe Client Headers would be great too. I can send you the filters I’ve already added for my personal use.
/**
* Generate request headers.
*
* @param string $processed_method The uppercase HTTP method.
* @param Config $config Request configuration.
* @return array Associative array of headers.
*/
private function generate_request_headers( $processed_method, $config ) {
$headers = [];
if ( $config->api_version ) {
$headers['Stripe-Version'] = $config->api_version;
}
if ( $config->secret_key ) {
$headers['Authorization'] = "Bearer $config->secret_key";
}
if ( $processed_method === 'POST' ) {
$headers['Idempotency-Key'] = $config->idempotency_key ?: bin2hex( random_bytes( 16 ) );
}
$headers = $config->headers + $headers;
return apply_filters( 'woo_mp_stripe_request_headers', $headers ) ;
}
/**
* Output a template.
*
* @param string $name The name of the template.
* @return void
*/
private function template( $name ) {
$directories = array_merge(
$this->gateway_template_directories,
[ WOO_MP_PATH . '/templates' ],
Woo_MP::is_pro() ? [ WOO_MP_PRO_PATH . '/templates' ] : []
);
foreach ( $directories as $directory ) {
$path = apply_filters( 'woo_mp_payment_meta_box_template', "$directory/$name.php", $name ) ;
if ( is_readable( $path ) ) {
require $path;
break;
}
}
}
//main plugin file
if ( ( ! is_admin() && ( ! defined( ‘DOING_CRON’ ) || ! DOING_CRON ) ) || is_network_admin() || ! apply_filters( ‘woo_mp_force_load’, false ) ) {
return;
}
Plugin Author
bfl
(@bfl)
I’m going to look into this soon.
Plugin Author
bfl
(@bfl)
A filter for Stripe request headers is also a good idea.
Regarding WCFM: Do you mean that you are providing Woo MP to third-party vendors, and you were able to get it working on the screen shown here?
Yes I got it working on that page, but I had to include some localized variables from WC and I also rewrote the JS files, and while I was in there I upgraded Stripe.JS to use V3 elements.
Plugin Author
bfl
(@bfl)
Wow, I’m impressed! I think I’ll add that filter, but it will have to come with a warning. I’m concerned about the security implications of using Woo MP like that, as I built it with the assumption that it would only be used by trusted employees with access to the WP Admin. I also assumed it would only be used in the WP Admin, so I can’t guarantee that it will function correctly elsewhere.
You probably already know this, but I would recommend testing each update of Woo MP on a staging/test site, as your customizations likely rely on internal implementation details.
Thanks for the update and fair warning!
Plugin Author
bfl
(@bfl)
I’ve added all 3 filters and they will be released in the next update.
Plugin Author
bfl
(@bfl)
The new filters are available now in version 2.7.0.