id = 'kuveyt'; // payment gateway plugin ID $this->icon = ''; // URL of the icon that will be displayed on checkout page near your gateway name $this->has_fields = true; // in case you need a custom credit card form $this->method_title = 'Kuvey Türk'; $this->method_description = 'Kuvey Türk Sanal Pos ile ödeme'; // will be displayed on the options page // gateways can support subscriptions, refunds, saved payment methods, // but in this tutorial we begin with simple payments $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->testmode = 'yes' === $this->get_option('testmode'); $this->customerId = $this->testmode ? $this->get_option('test_customerId') : $this->get_option('customerId'); $this->merchantId = $this->testmode ? $this->get_option('test_merchantId') : $this->get_option('merchantId'); $this->userName = $this->testmode ? $this->get_option('test_userName') : $this->get_option('userName'); $this->api_password = $this->testmode ? $this->get_option('test_api_password') : $this->get_option('api_password'); // This action hook saves the settings add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); add_action('woocommerce_api_my_best_test_classs', [$this, 'my_best_test_classs']); } function my_best_test_classs() { echo "Test"; } /** * Plugin options, we deal with it in Step 3 too */ public function init_form_fields() { $this->form_fields = array( 'title' => array( 'title' => 'Başlık', 'type' => 'text', 'description' => 'Müşterilerin ödeme ekranında göreceği ödeme yöntemi ismi', 'default' => 'Kuveyt Türk', 'desc_tip' => true, ), 'description' => array( 'title' => 'Açıklama', 'type' => 'textarea', 'description' => 'Müşterilerin göreceği ödeme açıklaması', 'default' => 'Kuveyt Türk ile ödeme', ), 'testmode' => array( 'title' => 'Test mod', 'label' => 'Test Modu Aktif', 'type' => 'checkbox', 'description' => 'Eğer bu modu açarsanız lüften test bilgileri bankanızın size sunduğu test bilgiler ile doldurun', 'default' => 'yes', 'desc_tip' => true, ), 'test_customerId' => array( 'title' => 'Test Müşteri ID', 'type' => 'text' ), 'test_merchantId' => array( 'title' => 'Test Mağaza ID', 'type' => 'password', ), 'test_userName' => array( 'title' => 'Test Kullanıcı Adı', 'type' => 'text' ), 'test_api_password' => array( 'title' => 'Test Şifre', 'type' => 'password' ), 'customerId' => array( 'title' => 'Müşteri ID', 'type' => 'text' ), 'merchantId' => array( 'title' => 'Mağaza ID', 'type' => 'password', ), 'userName' => array( 'title' => 'Kullanıcı Adı', 'type' => 'text' ), 'api_password' => array( 'title' => 'Şifre', 'type' => 'password' ) ); } public function payment_fields() { // ok, let's display some description before the payment form if ($this->description) { // you can instructions for test mode, I mean test card numbers etc. if ($this->testmode) { $this->description .= ' Test modu aktif. Lütfen bankanın sağladığı test kartı verilerini girin.'; $this->description = trim($this->description); } // display the description with

tags etc. echo wpautop(wp_kses_post($this->description)); } // I will echo() the form, but you can close PHP tags and print it directly in HTML echo '

'; // Add this action hook if you want your custom payment gateway to support it do_action('woocommerce_credit_card_form_start', $this->id); ?> // I recommend to use inique IDs, because other gateways could already use #ccNo, #expdate, #cvc echo ' Card Holder Name:
Card Number:
Expire Date (mm):
Expire Date (yy):
CVV2:
id); echo '
'; } function process_payment($order_id) { return array( 'result' => 'success', 'redirect' => add_query_arg('wc-api', 'my_best_test_classs', get_site_url()) ); $order = wc_get_order($order_id); // Mark as on-hold (we're awaiting the payment) /* $order->update_status('on-hold', __('Awaiting offline payment', 'wc-gateway-offline')); // Reduce stock levels $order->reduce_order_stock(); // Remove cart WC()->cart->empty_cart();*/ /* // Return thankyou redirect return array( 'result' => 'success', 'redirect' => $this->get_return_url($order) );*/ } } }