Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AnanthFlycart/86b497b1391e0ba6c02d844c8751c728 to your computer and use it in GitHub Desktop.

Select an option

Save AnanthFlycart/86b497b1391e0ba6c02d844c8751c728 to your computer and use it in GitHub Desktop.
CUW: Stripe by Payment Plugins
// add stripe_cc payment method
add_filter('cuw_post_purchase_before_payment_supported_payment_gateways', function ($methods) {
$methods['stripe_cc'] = __('Credit Cards (Stripe) by Payment Plugins', 'woo-stripe-payment');
return $methods;
}, 100);
// handle request after payment succeed
add_filter('cuw_payment_successful_result', function ($result, $order) {
if ($order->get_payment_method() == 'stripe_cc') {
if (substr($result['redirect'], 0, 1) == '#' && function_exists('wc_get_checkout_url')) {
$result['redirect'] = add_query_arg('cuw_capture_stripe_cc_payment', '1' . $result['redirect'], wc_get_checkout_url());
}
}
return $result;
}, 10, 2);
// show loading animation
add_action('init', function () {
if (!empty($_GET['cuw_capture_stripe_cc_payment'])) {
add_action('wp_head', function() {
?><style>#cuw-overlay{position:fixed;width:100%;height:100%;top:0;left:0;right:0;bottom:0;z-index:10000;background:#fff;cursor:pointer}</style><?php
}, 1);
add_action('wp_body_open', function() {
?><div id="cuw-overlay"></div><?php
}, 1);
add_action('wp_footer', function() {
?><script>jQuery(document).ready(function($){$("#cuw-overlay").block({message:null,overlayCSS:{'background':'#fff','z-index':10001,'opacity':1}})})</script><?php
}, 1);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment