Skip to content

Instantly share code, notes, and snippets.

@gedex
Created February 29, 2016 02:34
Show Gist options
  • Save gedex/240492f479c7443e4780 to your computer and use it in GitHub Desktop.
Save gedex/240492f479c7443e4780 to your computer and use it in GitHub Desktop.
function my_stripe_custom_callback( data ) {
alert( data.response.error.message );
data.form.unblock();
}
<?php
/**
* Plugin Name: Custom WC Stripe JS callback.
* Description: Example to override error response handler for WC Stripe
* Version: 1.0.0
* Author: WooThemes
* Author URI: https://woothemes.com
*/
// Pass my function name that handles error response handler.
add_filter( 'wc_stripe_params', function( $params ) {
$params['error_response_handler'] = 'my_stripe_custom_callback';
return $params;
} );
// Enqueue custom JS callback.
add_action( 'wp_enqueue_scripts', function() {
if ( ! is_checkout() ) {
return;
}
wp_enqueue_script( 'wc-custom-stripe-js-callback', plugins_url( 'wc-custom-stripe-js-callback.js', __FILE__ ), array( 'woocommerce_stripe' ), '1.0.0', true );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment