0

我正在尝试创建一个重定向到 Chase paymentech DPP 的自定义支付网关。当我收到此错误消息时,模块一直在工作,直到我到达网关:

此 XML 文件似乎没有任何与之关联的样式信息。文档树如下所示。

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:ws.paymentech.net/PaymentechGateway">
<SOAP-ENV:Body id="_0">
<SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<faultcode>SOAP-ENV:VersionMismatch</faultcode>
<faultstring>SOAP version mismatch or invalid SOAP message</faultstring>
<SOAP-ENV:Code/>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我不确定它是否与格式化表单以以正确的格式(即 XML)发布有关,所以想就如何以正确的格式发布值征求一些建议

这是我的名为 redirect.phtml 的表单,它重定向到支付网关。

<?php 
    $session = Mage::getSingleton('checkout/session');
    $orderIncrementId = $session->getLastRealOrderId();
    $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
    $billingaddress = $order->getBillingAddress();
    $shippingaddress = $order->getShippingAddress();
    $currencyDesc = Mage::app()->getStore()->getCurrentCurrencyCode();
    $totals = number_format($order->getGrandTotal(), 2, '.', ''); 
    $address = $billingaddress->getStreet();
    $address1 = $shippingaddress->getStreet();
    $data = array(
    'api_username' => trim(Mage::getStoreConfig('payment/redirect/api_username')),
    'api_password' => trim(Mage::getStoreConfig('payment/redirect/api_password')),
    'Merchant_ID' => trim(Mage::getStoreConfig('payment/redirect/Merchant_ID')),
    'Terminal_ID' => trim(Mage::getStoreConfig('payment/redirect/Terminal_ID')),
    'BIN_Number' => trim(Mage::getStoreConfig('payment/redirect/BIN_Number')),
    'Amount' => $totals,
    'billing_cust_name' =>$order->getCustomerFirstname(), 
    'billing_last_name'=>$order->getCustomerLastname(),
    'billing_cust_tel_No' => $billingaddress->getTelephone(),
    'billing_cust_email'=>$order->getCustomerEmail(),
    'billing_cust_address'=>$address[0] . ' '.$address[1],
    'billing_cust_city'=>$billingaddress->getCity(),
    'billing_cust_country'=>$billingaddress->getCountryId(),
    'billing_cust_state'=>$billingaddress->getRegion(),
    'billing_cust_zip' =>$billingaddress->getPostcode(),
    'delivery_cust_name' =>$shippingaddress->getCustomerFirstname(),
    'delivery_last_name'=>$shippingaddress->getCustomerLastname(),
    'delivery_cust_tel_No' => $shippingaddress->getTelephone(),
    'delivery_cust_email'=>$shippingaddress->getCustomerEmail(),
    'delivery_cust_address'=>$address1[0] . ' '.$address1[1],
    'delivery_cust_city'=>$shippingaddress->getCity(),
    'delivery_cust_country'=>$shippingaddress->getCountryId(),
    'delivery_cust_state'=>$shippingaddress->getRegion(),
    'delivery_cust_zip' =>$shippingaddress->getPostcode(),
    'Order_Id' => $order->getIncrementId(),
    'TxnType' => 'A',
    'actionID' => 'TXN',
    'Currency' => 'GBP',
    );

?>
<form action="https://wsvar.paymentech.net/PaymentechGateway" method="post" id="chase">
    <?php foreach($data as $key => $value): ?>
        <input type='hidden' name='<?php echo $key?>' value='<?php echo $value;?>' />
    <?php endforeach;?>
    <input type="submit" class="btn btn-success btn-large" value='Complete my order!'/> 
</form>
<?php echo $this->__('If Page Doesn\'t Redirect In 5 Sectonds, Please press Buy button');?>
<script type="text/javascript">
    function myfunc () {
    var frm = document.getElementById("chase");
    frm.submit();
    }
    window.onload = myfunc;
</script>

标准.php

<?php
class Custom_Gateway_Model_Standard extends Mage_Payment_Model_Method_Abstract {
    protected $_code = 'chase';
    protected $_isInitializeNeeded      = true;
    protected $_canUseInternal          = true;
    protected $_canUseForMultishipping  = false;

    public function getOrderPlaceRedirectUrl() {
    return Mage::getUrl('chase/payment/redirect', array('_secure' => true));
    }

    //create xml and send info to gateway
    private function callApi(Varien_Object $payment, $amount,$type){

    //call your authorize api here, incase of error throw exception.
    //only example code written below to show flow of code

    $order = $payment->getOrder();
    $types = Mage::getSingleton('payment/config')->getCcTypes();
    if (isset($types[$payment->getCcType()])) {
    $type = $types[$payment->getCcType()];
    }
    $billingaddress = $order->getBillingAddress();
    $totals = number_format($amount, 2, '.', '');
    $orderId = $order->getIncrementId();
    $currencyDesc = $order->getBaseCurrencyCode();

    $url = $this->getConfigData('gateway_url');
    $fields = array(
            'api_username'=> $this->getConfigData('api_username'),
            'api_password'=> $this->getConfigData('api_password'),
            'Merchant_ID'=> $this->getConfigData('Merchant_ID'),
            'Terminal_ID'=> $this->getConfigData('Terminal_ID'),
            'BIN_Number'=> $this->getConfigData('BIN_Number'),
            'customer_firstname'=> $billingaddress->getData('firstname'),
            'customer_lastname'=> $billingaddress->getData('lastname'),
            'customer_phone'=> $billingaddress->getData('telephone'),
            'customer_email'=> $billingaddress->getData('email'),
            'customer_ipaddress'=> $_SERVER['REMOTE_ADDR'],
            'bill_firstname'=> $billingaddress->getData('firstname'),
            'bill_lastname'=> $billingaddress->getData('lastname'),
            'Bill_address1'=> $billingaddress->getData('street'),
            'bill_city'=> $billingaddress->getData('city'),
            'bill_country'=> $billingaddress->getData('country_id'),
            'bill_state'=> $billingaddress->getData('region'),
            'bill_zip'=> $billingaddress->getData('postcode'),
            'customer_cc_expmo'=> $payment->getCcExpMonth(),
            'customer_cc_expyr'=> $payment->getCcExpYear(),
            'customer_cc_number'=> $payment->getCcNumber(),
            'customer_cc_type'=> strtoupper($type),
            'customer_cc_cvc'=> $payment->getCcCid(),
            'merchant_ref_number'=> $order->getIncrementId(),
            'currencydesc'=>$currencyDesc,
            'amount'=>$totals
    );

    $fields_string="";
    foreach($fields as $key=>$value) {
    $fields_string .= $key.'='.$value.'&';
    }
    $fields_string = substr($fields_string,0,-1);
    //open connection
    $ch = curl_init($url);
    //set the url, number of POST vars, POST data
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
    curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN HTTP HEADERS
    curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); // Timeout on connect (2 minutes)
    //execute post
    $result = curl_exec($ch);
    curl_close($ch);

    return array('status'=>1,'transaction_id' => time() , 'fraud' => rand(0,1));
  }
}
?>

授权.php

 protected function _getTransactionDetails($transactionId)
    {
        $requestBody = sprintf(
            '<?xml version="1.0" encoding="utf-8"?>'
            . '<getTransactionDetailsRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">'
            . '<merchantAuthentication><name>%s</name><transactionKey>%s</transactionKey></merchantAuthentication>'
            . '<transId>%s</transId>'
            . '</getTransactionDetailsRequest>',
            $this->getConfigData('login'),
            $this->getConfigData('trans_key'),
            $transactionId
        );

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

        $debugData = array('request' => $requestBody);

        try {
            $responseBody = $client->request()->getBody();
            $debugData['result'] = $responseBody;
            $this->_debug($debugData);
            libxml_use_internal_errors(true);
            $responseXmlDocument = new Varien_Simplexml_Element($responseBody);
            libxml_use_internal_errors(false);
        } catch (Exception $e) {
            Mage::throwException(Mage::helper('paygate')->__('Payment updating error.'));
        }

        $response = new Varien_Object;
        $response
            ->setResponseCode((string)$responseXmlDocument->transaction->responseCode)
            ->setResponseReasonCode((string)$responseXmlDocument->transaction->responseReasonCode)
            ->setTransactionStatus((string)$responseXmlDocument->transaction->transactionStatus)
        ;
        return $response;
    }



Thanks in advance
4

1 回答 1

1

据我所知,您应该只使用其中一种方法(而不是两种方法),因为它们代表两种不同类型的网关。

public function getOrderPlaceRedirectUrl() {
return Mage::getUrl('chase/payment/redirect', array('_secure' => true));
}

//create xml and send info to gateway
private function callApi(Varien_Object $payment, $amount,$type){

我建议使用此示例重新开始(我不确定“Standard.php”和“Authorize.php”的作用)http://www.excellencemagentoblog.com/magento-create-custom-payment-method-api -基于并做出改变callApi

也看看

protected function _postRequest(Varien_Object $request)

protected function _buildRequest(Varien_Object $payment)

/app/code/core/Mage/Paygate/Model/Authorizenet.php
于 2013-02-07T14:43:13.773 回答