403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.148.219.214
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/jenniferflocom/www/wp-content/plugins/mstore-api/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/jenniferflocom/www/wp-content/plugins/mstore-api/controllers/flutter-midtrans.php
<?php
require_once(__DIR__ . '/flutter-base.php');

/*
 * Base REST Controller for flutter
 *
 * @since 1.4.0
 *
 * @package Midtrans
 */

class FlutterMidtrans extends FlutterBaseController
{
    /**
     * Endpoint namespace
     *
     * @var string
     */
    protected $namespace = 'api/flutter_midtrans';

    /**
     * Register all routes releated with stores
     *
     * @return void
     */
    public function __construct()
    {
        add_action('rest_api_init', array($this, 'register_flutter_midtrans_routes'));
    }

    public function register_flutter_midtrans_routes()
    {
        register_rest_route($this->namespace, '/generate_snap_token', array(
            array(
                'methods' => "POST",
                'callback' => array($this, 'generate_snap_token'),
                'permission_callback' => function () {
                    return parent::checkApiPermission();
                }
            ),
        ));

        register_rest_route($this->namespace, '/payment_success', array(
            array(
                'methods' => "POST",
                'callback' => array($this, 'payment_success'),
                'permission_callback' => function () {
                    return parent::checkApiPermission();
                }
            ),
        ));

    }

    public function generate_snap_token($request)
    {
        if (!is_plugin_active('midtrans-woocommerce/midtrans-gateway.php')) {
            return parent::sendError("invalid_plugin", "You need to install Midtrans WooCommerce Payment Gateway plugin to use this api", 404);
        }
        $json = file_get_contents('php://input');
        $body = json_decode($json, TRUE);

        $params = array(
            'transaction_details' => array(
                'order_id' => sanitize_text_field($body['order_id']),
                'gross_amount' => sanitize_text_field($body['amount']),
            )
        );
        require_once ABSPATH . 'wp-content/plugins/midtrans-woocommerce/midtrans-gateway.php';
        $order = wc_get_order( sanitize_text_field($body['order_id']) );
        $snapResponse = WC_Midtrans_API::createSnapTransactionHandleDuplicate( $order, $params, 'midtrans' );
        return  $snapResponse;
    }

    public function payment_success($request)
    {
        $json = file_get_contents('php://input');
        $body = json_decode($json, TRUE);

        $order = wc_get_order( sanitize_text_field($body['order_id']) );
        $order->payment_complete();
        $order->add_order_note('Midtrans payment successful.<br/>Transaction ID: '.sanitize_text_field($body['transaction_id']));
        return  true;
    }
}

new FlutterMidtrans;

Youez - 2016 - github.com/yon3zu
LinuXploit