Created
February 29, 2016 02:34
-
-
Save gedex/240492f479c7443e4780 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function my_stripe_custom_callback( data ) { | |
alert( data.response.error.message ); | |
data.form.unblock(); | |
} |
This file contains hidden or 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: 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