Magento的API V2,扩大销售/订单班 [英] magento API v2, extending sales/order class
问题描述
我已经处理了一些日子的Magento API第2版。我试图扩展API添加一个名为帕新方法(支付手段)的订单/销售类。
现在我可以使用WSDL V1要做到这一点,但使用V2,当我得到这个错误:
I've been dealing with Magento API v2 for some days. I'm trying to extend the API to add a new method called "pago" (means payment) to the order/sales class. By now I'm able to do it using the v1 WSDL, but when using v2 I get this error:
程序salesOrderPago不... present
Procedure 'salesOrderPago' not present in ...
我的WSDL似乎是OK(http://www.hijole.com.py/ofertas/index.php/api/v2_soap/?wsdl)
我觉得我的错误是在某处我api.xml文件
My WSDL seems to be OK (http://www.hijole.com.py/ofertas/index.php/api/v2_soap/?wsdl) I think my error is somewhere in my api.xml file
<?xml version="1.0"?>
<config>
<api>
<resources>
<sales_order translate="title" module="sales">
<model>sales/order_api</model>
<title>Order API</title>
<acl>sales/order</acl>
<methods>
<pago translate="title" module="sales">
<title>Acepta un pago</title>
<acl>sales/order/create</acl>
</pago>
</methods>
</sales_order>
</resources>
<resources_alias>
<order>sales_order</order>
</resources_alias>
<v2>
<resources_function_prefix>
<order>salesOrder</order>
</resources_function_prefix>
</v2>
</api>
</config>
这是我的API / v2.php文件
This is my api/v2.php file
<?php
class Neurona_Pagoexpress_Model_Sales_Order_Api_V2 extends Mage_Sales_Model_Order_Api
{
public function pago($ref, $medio, $moneda, $boleta)
{
try{
//Crea invoice para la orden
$invoice = Mage::getModel('sales/order_invoice_api');
$invoice->create($ref, array(), 'PagoExpress - '.$boleta);
$aut = "4894371870891274"; //Generar con algoritmo
return array('00','Procedimiento correcto',$aut); // 00 = OK, Pago realizado
}
catch (Mage_Core_Exception $e) {
return array('99');
}
}
}
这是我的 conig.xml 文件
<?xml version="1.0"?>
<config>
<global>
<models>
<sales>
<rewrite>
<order_api>Neurona_Pagoexpress_Model_Sales_Order_Api</order_api>
<order_api_v2>Neurona_Pagoexpress_Model_Sales_Order_Api_V2</order_api_v2>
</rewrite>
</sales>
</models>
</global>
</config>
下面是我等/ wsdl.xml
Here is my etc/wsdl.xml
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<message name="salesOrderPagoRequest">
<part name="sessionId" type="xsd:string" />
<part name="orderIncrementId" type="xsd:string" />
<part name="orderMedio" type="xsd:string" />
<part name="orderMoneda" type="xsd:string" />
<part name="orderBoleta" type="xsd:string" />
</message>
<message name="salesOrderPagoResponse">
<part name="result" type="typens:ArrayOfString" />
</message>
<portType>
<operation name="salesOrderPago">
<documentation>Implementa el pago de una factura</documentation>
<input message="typens:salesOrderPagoRequest" />
<output message="typens:salesOrderPagoResponse" />
</operation>
</portType>
<binding>
<operation name="salesOrderPago">
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
<input>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
</definitions>
在此先感谢!
推荐答案
后来我找到了解决方法:只要重新启动Apache。这似乎是一个WSDL缓存的问题。
I found the solution later: Just restart Apache. It seems to be a wsdl cache issue.
这篇关于Magento的API V2,扩大销售/订单班的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!