C# Magento:通过soap获取事务ID
我最近尝试通过magentos SOAPv2适配器连接到magento webshop。C# Magento:通过soap获取事务ID,c#,web-services,soap,wsdl,magento-1.7,C#,Web Services,Soap,Wsdl,Magento 1.7,我最近尝试通过magentos SOAPv2适配器连接到magento webshop。 Sharpdevelop确实生成了一些c#包装器来获取WSDL。 我可以登录和查询订单,但当涉及到付款方式时,我想知道为什么没有办法获得交易ID。 以下是我尝试过的: salesOrderEntity ent = ms.salesOrderInfo(mlogin,"<my_order_id>"); salesOrderEntity ent=ms.salesOrderInfo(mlogin,”)
Sharpdevelop确实生成了一些c#包装器来获取WSDL。
我可以登录和查询订单,但当涉及到付款方式时,我想知道为什么没有办法获得交易ID。 以下是我尝试过的:
salesOrderEntity ent = ms.salesOrderInfo(mlogin,"<my_order_id>");
salesOrderEntity ent=ms.salesOrderInfo(mlogin,”);
salesOrderEntity
类包含一个salesOrderPaymentEntity
,该实体应包含一个属性last\u trans\u id
,但它不包含该属性。有人知道从哪里可以从支付信息中获取交易ID吗?在sharpdevelop生成的代理代码中,我甚至没有找到对last_trans_id的引用 提前感谢您的建议。
-克里斯-过了一段时间,我再次提出了这个问题,并找到了一个解决方案。
salesOrderEntity包含salesOrderStatusHistoryEntity对象的列表。
它们包含一个名为“comment”的字段,在我的例子中,可以通过如下文本方式找到事务ID 事务ID:“800736757864…”
这对我很有帮助。过了一段时间,我再次提出了这个问题,并找到了一个解决方案。
salesOrderEntity包含salesOrderStatusHistoryEntity对象的列表。
它们包含一个名为“comment”的字段,在我的例子中,可以通过如下文本方式找到事务ID 事务ID:“800736757864…”
这对我很有帮助。Chris OP已经回答了这个问题,但只是为了给这个问答增加一些额外的价值,下面是我的代码 作为一些背景,我之所以使用事务ID是因为Paypal使用它们。我正在编写一个cron作业,它从Paypal API中提取前24小时的Paypal订单,然后我们通过SOAP从Magento提取前24小时的所有订单,获取事务ID并将其与Paypal列表匹配。这是为了确保没有不在Magento上的Paypal订单,有时我们会遇到IPN故障,这会阻止Magento报价转换为订单,客户会收到Paypal的账单,但由于从未创建订单,因此不会向他们发货任何产品。如果不匹配,将向客户服务发送电子邮件警报
$startDate = gmdate('Y-m-d H:i:s', strtotime('-1 day', time()));
$complex_params =array(
array('key'=>'created_at','value'=>array('key' =>'from','value' => $startDate))
);
$result = $client_v2->salesOrderList($session_id, array('complex_filter' => $complex_params));
// We've got all the orders, now we need to run through them and get the transaction id from the order info
// We create an array just to hold the transaction Ids
$ikoTransactionIds = array();
foreach ($result as $invoice) {
$invoiceInfo = $client_v2->salesOrderInfo($session_id, $invoice->increment_id);
$history = $invoiceInfo->status_history;
$comments = $history[0]->comment;
// Only the Paypal based records have transaction Ids in the comments, orders placed via credit card do not. In these cases $comments are null
if ($comments) {
// Check if the text 'Transaction ID:' exists at all
if ((strpos($comments, "Transaction ID:")) !== FALSE) {
list($before, $transactionId) = explode('Transaction ID: ', $comments);
// Remove the trailing period
$transactionId = rtrim($transactionId ,".");
// Remove the quotes
$transactionId = str_replace('"', '', $transactionId);
// We add the id to our array of ids for this Magento install
$ikoTransactionIds[] = $transactionId;
}
}
}
Chris TheOP已经回答了这个问题,但为了给这个问答增加一些额外的价值,这里是我的代码 作为一些背景,我之所以使用事务ID是因为Paypal使用它们。我正在编写一个cron作业,它从Paypal API中提取前24小时的Paypal订单,然后我们通过SOAP从Magento提取前24小时的所有订单,获取事务ID并将其与Paypal列表匹配。这是为了确保没有不在Magento上的Paypal订单,有时我们会遇到IPN故障,这会阻止Magento报价转换为订单,客户会收到Paypal的账单,但由于从未创建订单,因此不会向他们发货任何产品。如果不匹配,将向客户服务发送电子邮件警报
$startDate = gmdate('Y-m-d H:i:s', strtotime('-1 day', time()));
$complex_params =array(
array('key'=>'created_at','value'=>array('key' =>'from','value' => $startDate))
);
$result = $client_v2->salesOrderList($session_id, array('complex_filter' => $complex_params));
// We've got all the orders, now we need to run through them and get the transaction id from the order info
// We create an array just to hold the transaction Ids
$ikoTransactionIds = array();
foreach ($result as $invoice) {
$invoiceInfo = $client_v2->salesOrderInfo($session_id, $invoice->increment_id);
$history = $invoiceInfo->status_history;
$comments = $history[0]->comment;
// Only the Paypal based records have transaction Ids in the comments, orders placed via credit card do not. In these cases $comments are null
if ($comments) {
// Check if the text 'Transaction ID:' exists at all
if ((strpos($comments, "Transaction ID:")) !== FALSE) {
list($before, $transactionId) = explode('Transaction ID: ', $comments);
// Remove the trailing period
$transactionId = rtrim($transactionId ,".");
// Remove the quotes
$transactionId = str_replace('"', '', $transactionId);
// We add the id to our array of ids for this Magento install
$ikoTransactionIds[] = $transactionId;
}
}
}
+谢谢你的指点。绝对荒谬,我们必须从销售订单历史记录中的注释中挖掘订单的交易ID。+1感谢指针。绝对荒谬,我们必须从销售订单历史记录中的注释中挖掘订单的交易ID。