<?php
namespace AdaPaySdk;

use AdaPay\AdaPay;


class PaymentReverse extends AdaPay{

    static private $instance;

    public $endpoint = "/v1/payments/reverse";

    public function __construct()
    {
        parent::__construct();
        // $this->sdk_tools = SDKTools::getInstance();
    }


    

    //=============支付撤销对象
    /**
     * 创建支付撤销对象
     * @Author   Kelly
     * @DateTime 2020-10-22
     * @version  V1.1.4
     * @param    array
     * @return   array
     */
    public function create($params=array(),$key){
        $request_params = $params;
        if($key == 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871'){
            $this->setRsaPrivateKey('MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANG5b9X+SnEirAtdj1fN/wTzmA5Rm7V8QTIIxIEmADTQ+28slzcCYWpG3FMmIfjwX7Ho0mdUDvDVQ++U92PJRSaMrKYbdf6mz6DWLKveEfjkvrjQqk4l+bLu3H75nS10A8nkBSqYO0tPiHmZSkBb/cHcDar6z2rLuT8IYmZYQtGZAgMBAAECgYEAiiQ7Jhl5r0vHRzU5Vfy6HejWH5hhmAlgaDSeOvNs7104QOJ+OB25TOef+KUFe5PZdLaG4MjdjoTrWsQkr/XDNY+FjrCTPY9LUKQVztS+K6uyhOO5xELX2m6tYvvkRzomJmpxKKlJImralVsn0tgGldH7oGQbpjCa1YH2BwFPygECQQD0VTz54ABvbg6vLQ1CRMwYzInR/QhA/nvS9DLDdpZmkP04WyJ3iUOAot1IQ51NVCz55rHSDZS5nGcqoIWbm3llAkEA270jWrH+xUbQTj4hrV98QHnFWcZGe98lO1zm0bggE3EWlSGp2EmWZZedIu2xq6QvlxbscjjC1M+SDMB/Dn/OJQJAJveBJgjHiP3wcZepyavXMQ1N3aORMWxkqxwvDGVZTzpIaDiAorfNgDJ5QBEogTCvi5tzOKDZ21BKU84OAOcm0QJBANORXATq9B4FfHKZJ9vB3+REWluBqEOEKljpreOmoFuXuuKDswBoecH/JHCI41QblSaoD6g6NnyoDjrw7GSNcXECQEI3aNwxYpvcbVn8l8goyIKckfj5giXkzhGxBN9UI24wmx4CBQmdSsiShbNjVAFs1T7u4ZNEZ1TNnxxlV/+LciU=');
            $this->__init_params();
            $this->setApiKey($key);
        }

        $request_params = $this->do_empty_data($request_params);
        $req_url =  self::$gateWayUrl . $this->endpoint;
        $header =  $this->get_request_header($req_url, $request_params, self::$header);
        $this->result = $this->ada_request->curl_request($req_url, $request_params, $header, $is_json=true);
        // $this->result = $this->sdk_tools->post($params, $this->endpoint);
    }

    /**
     * 查询支付撤销对象
     * @Author   Kelly
     * @DateTime 2020-10-22
     * @version  V1.1.4
     * @param    array
     * @return   array
     */
    public function query($params=array()){
        ksort($params);
        $request_params = $params;
        $req_url =  self::$gateWayUrl . $this->endpoint . "/" . $params['reverse_id'];
        $header = $this->get_request_header($req_url, http_build_query($request_params), self::$headerText);
        $this->result = $this->ada_request->curl_request($req_url . "?" . http_build_query($request_params), "", $header, false);
        // $this->result = $this->sdk_tools->get($params, $this->endpoint . "/" . $params['reverse_id']);
    }

    /**
     * 查询支付撤销对象列表
     * @Author   Kelly
     * @DateTime 2020-10-22
     * @version  V1.1.4
     * @param    array
     * @return   array
     */
    public function queryList($params=array()){
        ksort($params);
        $request_params = $this->do_empty_data($params);
        $req_url =  self::$gateWayUrl . $this->endpoint. "/list" ;
        $header = $this->get_request_header($req_url, http_build_query($request_params), self::$headerText);
        $this->result = $this->ada_request->curl_request($req_url . "?" . http_build_query($request_params), "", $header, false);
        // $this->result = $this->sdk_tools->get($params, $this->endpoint . "/list");
    }

    
}