API ЮKassa
Помощь
Подключить ЮKassa
Список успешных и возвращенных платежей
После того как платежи проведены, можно получить их список с помощью метода listOrders протокола Управление заказами (MWS).
listOrders
PHP
/**
 * Returns successful orders and their properties.
 * @return string response from YooMoney in XML format
 */
public function listOrders() {
    $methodName = "listOrders";
    $this->log->info("Start " . $methodName);
    $dateTime = Utils::formatDateForMWS(new \DateTime());
    $requestParams = array(
        'requestDT' => $dateTime,
        'outputFormat' => 'XML',
        'shopId' => $this->settings->SHOP_ID,
        'orderCreatedDatetimeLessOrEqual' => $dateTime
    );
    $result = $this->sendUrlEncodedRequest($methodName, $requestParams);
    $this->log->info($result);
    return $result;
}
Список возвращенных платежей можно получить с помощью метода listReturns.
listReturns
PHP
/**
 * Returns refunded payments.
 * @return string response from YooMoney in XML format
 */
public function listReturns() {
    $methodName = "listReturns";
    $this->log->info("Start " . $methodName);
    $dateTime = Utils::formatDateForMWS(new \DateTime()) ;
    $requestParams = array(
        'requestDT' => $dateTime,
        'outputFormat' => 'XML',
        'shopId' => $this->settings->SHOP_ID,
        'from' => '2015-01-01T00:00:00.000Z',
        'till' => $dateTime
    );
    $result = $this->sendUrlEncodedRequest($methodName, $requestParams);
    $this->log->info($result);
    return $result;
}
Функции для отправки запросов по Управлению заказами (MWS):
PHP
/**
 * Makes XML/PKCS#7 request.
 * @param  string $paymentMethod financial method name
 * @param  array  $data          key-value pairs of request body
 * @return string                response from YooMoney in XML format
 */
private function sendXmlRequest($paymentMethod, $data) {
    $body = '<?xml version="1.0" encoding="UTF-8"?>';
    $body .= '<' . $paymentMethod . 'Request ';
    foreach($data AS $param => $value) {
        $body .= $param . '="' . $value . '" ';
    }
    $body .= '/>';
    return $this->sendRequest($paymentMethod, $this->signData($body), "pkcs7-mime");
}

/**
 * Makes application/x-www-form-urlencoded request.
 * @param  string $paymentMethod financial method name
 * @param  array  $data          key-value pairs of request body
 * @return string                response from YooMoney in XML format
 */
private function sendUrlEncodedRequest($paymentMethod, $data) {
    return $this->sendRequest($paymentMethod, http_build_query($data), "x-www-form-urlencoded");
}

/**
 * Sends prepared request.
 * @param  string $paymentMethod financial method name
 * @param  string $requestBody   prepared request body
 * @param  string $contentType   HTTP Content-Type header value
 * @return string                response from YooMoney in XML format
 */
private function sendRequest($paymentMethod, $requestBody, $contentType) {
    $this->log->info($paymentMethod . " Request: " . $requestBody);
    $curl = curl_init();
    $params = array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_HTTPHEADER => array('Content-type: application/' . $contentType),
        CURLOPT_URL => 'https://shop.yookassa.ru:8083/webservice/mws/api/' . $paymentMethod,
        CURLOPT_POST => 0,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_SSLCERT => $this->settings->mws_cert,
        CURLOPT_SSLKEY => $this->settings->mws_private_key,
        CURLOPT_SSLCERTPASSWD => $this->settings->mws_cert_password,
        CURLOPT_SSL_VERIFYHOST => false,
        CURLOPT_VERBOSE => 1,
        CURLOPT_POSTFIELDS => $requestBody
    );
    curl_setopt_array($curl, $params);
    $result = null;
    try {
        $result = curl_exec($curl);
        if (!$result) {
            trigger_error(curl_error($curl));
        }
        curl_close($curl);
    } catch (HttpException $ex) {
        echo $ex;
    }
    return $result;
}
Что почитать еще
Управление заказамиЗапрос списка успешных платежейЗапрос списка возвратов успешных платежей