如何在magento中取消authorize.net transection

时间:2017-10-17 09:21:47

标签: magento void authorize.net

我想在某些条件下取消authorize.net在magento中完成的横断。 我有横断ID和所有细节。 请告诉我。

1 个答案:

答案 0 :(得分:0)

我找到了答案:

$的transactionId = 60032060090; $ referId = 123456;

$ paygate = Mage :: getModel(' paygate / authorizenet');

    $requestBody = sprintf(
            '<?xml version="1.0" encoding="utf-8"?>'
            . '<createTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">'
            . '<merchantAuthentication><name>%s</name><transactionKey>%s</transactionKey></merchantAuthentication>'
            . '<refId>%s</refId>'
            .'<transactionRequest><transactionType>voidTransaction</transactionType><refTransId>%s</refTransId></transactionRequest>'
            . '</createTransactionRequest>',
            $paygate->getConfigData('login'),
            $paygate->getConfigData('trans_key'),
            $referId,
            $transactionId
            );

    $client = new Varien_Http_Client();
    $uri = $paygate->getConfigData('cgi_url_td');
    $uri = $uri ? $uri : $paygate::CGI_URL_TD;
    $client->setUri($uri);
    $client->setConfig(array('timeout'=>45));
    $client->setHeaders(array('Content-Type: text/xml'));
    $client->setMethod(Zend_Http_Client::POST);
    $client->setRawData($requestBody);

    $debugData = array(
            'url' => $uri,
            'request' => $requestBody
    );

    try {
        $responseBody = $client->request()->getBody();
        $debugData['result'] = $responseBody;
        echo 'dddddd';
        echo $debugData['result'];
        libxml_use_internal_errors(true);
        $responseXmlDocument = new Varien_Simplexml_Element($responseBody);
        libxml_use_internal_errors(false);
    } catch (Exception $e) {
        $debugData['exception'] = $e->getMessage();

// $ paygate-&gt; _debug($ debugData);             Mage :: throwException(Mage :: helper(&#39; paygate&#39;) - &gt; __(&#39;交易状态提取错误。&#39;));         }