YooMoney API
Old versions of the API
Help
Sign up for YooMoney
List of successful and refunded payments

This is an old version of the API. Switch to the YooMoney API.

After payments are completed, you can use the listOrders method in the payment management protocol (MWS) to get a list of payments.
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;
}
Use the listReturns method to get a list of refunded payments.
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;
}
Function to send Payment management (MWS) requests:
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;
}
See also
Manage orders Request for a list of successful payments Request for a list of refunded successful payments