%PDF- %PDF-
Direktori : /home/tradesc/www/relax/wp-content/plugins/secudeal-payments-for-ecommerce/ |
Current File : /home/tradesc/www/relax/wp-content/plugins/secudeal-payments-for-ecommerce/secudeal-woocommerce.php |
<?php if ( ! defined( 'ABSPATH' ) ) exit; /** Plugin Name: Secudeal Payments for Ecommerce Plugin URI: https://www.secudeal.com Description: Official WooCommerce checkout gateway for the <a href="https://www.secudeal.com/">SECUDEAL</a> payment solution dedicated to marketplaces. Version: 1.1 Author: Secudeal Author URI: https://www.secudeal.com Text Domain: secudeal Domain Path: /languages Requires at least: 5.9 Tested up to: 6.2 Requires PHP: 7.2 License: GPL3 WC requires at least: 7.0 WC tested up to: 7.6.1 */ if ( ! class_exists( 'WC_Secudeal' ) ){ class WC_Secudeal { public function __construct() { add_action( 'plugins_loaded', array( $this, 'init' ) ); } public function init() { if ( class_exists( 'WC_Payment_Gateway' ) ) { if(strpos(get_home_url(), "shop.secudeal.com") !== false){ $this->urlSecudeal = "test.secudeal.com"; }else{ $this->urlSecudeal = "pay.secudeal.com"; } include_once 'class-wc-gateway-secudeal.php'; add_filter( 'woocommerce_payment_gateways', array( $this, 'Secudeal_gateway_class' ) ); add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this,'WC_Secudeal_action_links') ); add_action( 'wc_ajax_woo_secudeal_cancel_order', array( $this, 'woo_secudeal_cancel_order' ) ); add_action( 'wc_ajax_woo_secudeal_checkout_order', array( $this, 'woo_secudeal_checkout_order' ) ); } } public function WC_Secudeal_action_links( $links ) { $links[] = '<a href="'. menu_page_url( 'wc-settings', false ) .'&tab=checkout§ion=secudeal-gateway">'. __("Paramètres", "secudeal") .'</a>'; return $links; } public function Secudeal_gateway_class( $gateways ) { $gateways[] = 'WC_Secudeal_Gateway'; return $gateways; } public function woo_secudeal_cancel_order(){ wc_add_notice(__('Vous avez annulé la session de paiement Secudeal. Veuillez réessayer de traiter votre commande.', 'secudeal'), 'notice'); wp_redirect(wc_get_checkout_url()); exit; } public function woo_secudeal_checkout_order() { if(!wp_verify_nonce($_GET['_wpnonce'], 'secudeal_checkout_nonce')){ wc_add_notice(__('Il y a eu une erreur pendant le paiement. Veuillez réessayer de traiter votre commande.', 'secudeal'), 'error'); wp_redirect(wc_get_checkout_url()); exit; } $order_id = intval( wp_kses(unserialize(base64_decode($_GET['order_id'])), "strip")); if(is_numeric($order_id)){ $order = wc_get_order($order_id); $resp = false; if($order != false){ $id = intval( wp_kses(unserialize(base64_decode($_GET['id'])), "strip")); if(is_numeric($id)){ $urlCurl = "https://". $this->urlSecudeal ."/wp-json/secudeal/v1/order/". $id ."/getStatusPaid/"; $response = wp_remote_get( $urlCurl ); $resp = json_decode( $response['body'] ); $order_time = date('Y-m-d H:i:s', time() + get_option('gmt_offset') * 3600); if ($resp == true) { $order->payment_complete(); $order->set_transaction_id($id); $order->add_order_note( sprintf( __('Payment Status : valid [%s], Source: Secudeal, Transaction ID : %s', 'secudeal'), $order_time, $id)); WC()->cart->empty_cart(); $result = array( 'result' => 'success', 'redirect' => $order->get_checkout_order_received_url(), ); wp_safe_redirect($result['redirect']); exit; } else { wc_add_notice(__('Il y a eu une erreur pendant le paiement. Veuillez réessayer de traiter votre commande.', 'secudeal'), 'error'); } }else{ wc_add_notice(__('Il y a eu une erreur pendant le paiement. Veuillez réessayer de traiter votre commande.', 'secudeal'), 'error'); } }else{ wc_add_notice(__('Il y a eu une erreur pendant le paiement. Veuillez réessayer de traiter votre commande.', 'secudeal'), 'error'); } }else{ wc_add_notice(__('Il y a eu une erreur pendant le paiement. Veuillez réessayer de traiter votre commande.', 'secudeal'), 'error'); } wp_redirect(wc_get_checkout_url()); exit; } } $WC_Secudeal_plugin = new WC_Secudeal( __FILE__ ); }