WooFrance Dépannage et support WordPress WooCommerce › Forums › Les plugins WordPress WooCommerce › passerelle de paiement
Étiqueté : woocommerce passerelle de paiement
- Ce sujet contient 0 réponse, 1 participant et a été mis à jour pour la dernière fois par GUEYE, le il y a 2 années et 11 mois.
Affichage de 1 message (sur 1 au total)
-
AuteurMessages
-
20 décembre 2021 à 17 h 50 min #380327
Bonjour je suis entrain de faire une passerelle de paiement personnalisé maintenant j’arrive pas à faire la redirection vers la page de paiement .
<?php /** /** * Plugin Name: plugin_PAY * Description: Lancer la page de paiement * Version: 5.6.40 * Author Name: xxx * Author: Vxxx */ add_filter( 'woocommerce_payment_gateways', 'pay_add_gateway_class' ); function pay_add_gateway_class( $gateways ) { $gateways[] = 'WC_Pay_Gateway'; // your class name is here return $gateways; } add_action( 'plugins_loaded', 'pay_init_gateway_class' ); function pay_init_gateway_class() { class WC_Pay_Gateway extends WC_Payment_Gateway { /** * Class constructor, more about it in Step 3 */ public function __construct() { $this->id = 'pay'; $this->icon = ''; $this->has_fields = true; $this->method_title = 'PAY Gateway'; $this->method_description = ''; $this->supports = array( 'products' ); // Method with all the options fields $this->init_form_fields(); // Load the settings. $this->init_settings(); $this->title = $this->get_option( 'title' ); $this->description = $this->get_option( 'description' ); $this->enabled = $this->get_option( 'enabled' ); $this->testmode = 'yes' === $this->get_option( 'testmode' ); $this->login = $this->testmode ? $this->get_option( 'login_api' ) : $this->get_option( 'login' ); $this->code = $this->testmode ? $this->get_option( 'code' ) : $this->get_option( 'code' ); // This action hook saves the settings add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); // We need custom JavaScript to obtain a token add_action( 'woocommerce_before_checkout_process', array( $this, 'payment' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'payment' ) ); } public function init_form_fields(){ $this->form_fields = array( 'enabled' => array( 'title' => 'Enable/Disable', 'label' => 'Enable Pay Gateway', 'type' => 'checkbox', 'description' => '', 'default' => 'no' ), 'title' => array( 'title' => 'Title', 'type' => 'text', 'description' => 'This controls the title which the user sees during checkout.', 'default' => 'Payment', 'desc_tip' => true, ), 'description' => array( 'title' => 'Description', 'type' => 'textarea', 'description' => 'This controls the description which the user sees during checkout.', 'default' => '.', ), 'testmode' => array( 'title' => 'Test mode', 'label' => 'Enable Test Mode', 'type' => 'checkbox', 'description' => 'Place the payment gateway in test mode using test API keys.', 'default' => 'yes', 'desc_tip' => true, ), 'login_api' => array( 'title' => 'Login API', 'type' => 'text' ), 'code' => array( 'title' => 'Mot de Passe API', 'type' => 'password', ), 'URL success' => array( 'title' => 'URL Success', 'type' => 'text' ), 'URL Failed' => array( 'title' => 'URL Failed', 'type' => 'text' ) ); } public function payment() { global $woocommerce; ?> <script src="https://;;;"></script> <body > <button type="submit" id="place_order" name="woocommerce_checkout_place_order" class="button alt" href="#" onclick="lancerPaiement('xxx','xxx','xxx','xxxx.xxx/success','xxxx.xxx/failed', <?php echo $woocommerce->cart->total; ?>)"> Payment </button> </body> <script> function lancerPaiement(reference, login, code, url_success, url_failed, amount){ paymentPay(reference, login, code,url_success, url_failed, amount) } </script> <?php } public function process_payment( $order_id ) { global $woocommerce; // we need it to get any order detailes $order = new WC_Order( $order_id ); $checkout_payment_url = $order -> get_checkout_payment_url( paiement() ) ; return array( 'result' => 'success', 'redirect' => add_query_arg ('order_pay', $order -> id , $checkout_payment_url)) ; } } } ?>
-
AuteurMessages
Affichage de 1 message (sur 1 au total)
- Vous devez être connecté pour répondre à ce sujet.