Created
October 4, 2023 09:50
-
-
Save AnanthFlycart/86b497b1391e0ba6c02d844c8751c728 to your computer and use it in GitHub Desktop.
CUW: Stripe by Payment Plugins
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
| // 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