导入订单,从Magento到Quickbooks桌面的付款

时间:2013-02-21 06:27:12

标签: magento intuit-partner-platform

我们正在将订单和付款数据从Magento导入Quickbooks Desktop版本。下面是两个查询 - 这些查询提供成功的响应,但不导入任何数据。对我们有什么想法吗?

首先,我们创建一个查询来形成订单堆栈

$qb_order = new QuickBooks_IPP_Object_Invoice();

        $qb_meta = new QuickBooks_IPP_Object_MetaData();
        $qb_meta->setCreateTime($order->getCreatedAt());
        $qb_meta->setLastUpdatedTime($order->getUpdatedAt());
        $qb_order->setMetaData($qb_meta);

        $qb_header = new QuickBooks_IPP_Object_Header();
        $qb_header->setDocNumber($order->getIncrementId());
        if (!$qb_customer_id = $this->_getQbCustomerId($order->getCustomerId())) return false;
        $qb_header->setCustomerId($qb_customer_id);
        $qb_header->setShipDate($order->getDeliveryDate());
        $qb_header->setSubTotalAmt($order->getBaseSubtotal());
        $qb_header->setTaxAmt($order->getBaseTaxAmount());
        $qb_header->setTotalAmt($order->getBaseGrandTotal());
        $qb_header->setARAccountId("Accounts Receivable");

        if ($address = $order->getBillingAddress()) {
            $qb_header->setBillAddr($this->_convertAddress($address, "Billing"));
        }

        if ($address = $order->getShippingAddress()) {
            $qb_header->setShipAddr($this->_convertAddress($address, "Shipping"));
        }

        $qb_header->setDiscountAmt($order->getBaseDiscountAmount());
        $qb_order->setHeader($qb_header);

        foreach($order->getItemsCollection() as $item) {
            $qb_order->addLine($this->_convertOrderItem($item));
    }

这是在查询后形成的XML:

<?xml version="1.0" encoding="UTF-8"?>
<Add xmlns="http://www.intuit.com/sb/cdm/v2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    RequestId="4562cdf8407178e362082c0441dffa74" 
    xsi:schemaLocation="http://www.intuit.com/sb/cdm/v2 ./RestDataFilter.xsd ">
    <OfferingId>ipp</OfferingId>
    <ExternalRealmId>631645715</ExternalRealmId>
    <Object xsi:type="Invoice">
        <Header>
            <DocNumber>100001570</DocNumber>
            <CustomerId>103699</CustomerId>
            <ShipDate>2013-02-21</ShipDate>
            <SubTotalAmt>33.0000</SubTotalAmt>
            <TaxAmt>2.6400</TaxAmt>
            <TotalAmt>35.64</TotalAmt>
            <ARAccountId>Accounts Receivable</ARAccountId>
            <BillAddr>
                <Line1>⁣</Line1>
                <Line2></Line2>
                <Line3></Line3>
                <Line4></Line4>
                <City>⁣</City>
                <Country>⁣</Country>
                <CountrySubDivisionCode>⁣</CountrySubDivisionCode>
                <PostalCode>⁣</PostalCode>
                <Tag>Billing</Tag>
            </BillAddr>
            <ShipAddr>
                <Line1>⁣</Line1>
                <Line2></Line2>
                <Line3></Line3>
                <Line4></Line4>
                <City>⁣</City>
                <Country>⁣</Country>
                <CountrySubDivisionCode>⁣</CountrySubDivisionCode>
                <PostalCode>⁣</PostalCode>
                <Tag>Shipping</Tag>
            </ShipAddr>
            <DiscountAmt>0.0000</DiscountAmt>
        </Header>
        <Line>
            <Desc>Special Product For POS
sdf</Desc>
            <Amount>33.0000</Amount>
            <ItemType>Product</ItemType>
            <UnitPrice>33.0000</UnitPrice>
            <Qty>1</Qty>
        </Line>
    </Object>
</Add>

以下是服务器响应:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
  <Success RequestId="4562cdf8407178e362082c0441dffa74">
    <ObjectRef>
      <Id idDomain="NG">494527</Id>
      <SyncToken>1</SyncToken>
      <LastUpdatedTime>2013-02-21T05:44:12Z</LastUpdatedTime>
    </ObjectRef>
    <RequestName>InvoiceAdd</RequestName>
    <ProcessedTime>2013-02-21T05:44:12Z</ProcessedTime>
  </Success>
</RestResponse>

=============================================== ==================

以下是针对订单创建付款的第二组代码。同样的问题,成功的XML但没有导入数据:

$order = Mage::getModel("sales/order")->load($invoice->getOrderId());
        if (!$qb_order_id = $this->getHelper()->getObjectQbId($order)) return false;
        $qb_payment = new QuickBooks_IPP_Object_Payment();

        $qb_meta = new QuickBooks_IPP_Object_MetaData();
        $qb_meta->setCreateTime($invoice->getCreatedAt());
        $qb_meta->setLastUpdatedTime($invoice->getUpdatedAt());
        $qb_payment->setMetaData($qb_meta);

        $qb_header = new QuickBooks_IPP_Object_Header();
        $qb_header->setDocNumber($invoice->getIncrementId());
        $qb_header->setTxnDate($invoice->getCreatedAt());
        if (!$qb_customer_id = $this->_getQbCustomerId($order->getCustomerId())) return false;
        $qb_header->setCustomerId($qb_customer_id);
        $qb_header->setTotalAmt($invoice->getBaseGrandTotal());
        $qb_header->setProcessPayment('false');

        $qb_payment->setHeader($qb_header);

        $qb_line = new QuickBooks_IPP_Object_Line();
        $qb_line->setAmount($invoice->getBaseGrandTotal());
        $qb_line->setTxnId($qb_order_id);
        $qb_payment->addLine($qb_line);

这是在代码之后形成的XML:

<?xml version="1.0" encoding="UTF-8"?>
<Add xmlns="http://www.intuit.com/sb/cdm/v2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    RequestId="dc07317b838eb3d0c89e310b4984468a" 
    xsi:schemaLocation="http://www.intuit.com/sb/cdm/v2 ./RestDataFilter.xsd ">
    <OfferingId>ipp</OfferingId>
    <ExternalRealmId>631645715</ExternalRealmId>
    <Object xsi:type="Payment">
        <Header>
            <DocNumber>100000265</DocNumber>
            <TxnDate>2013-02-21</TxnDate>
            <CustomerId>103699</CustomerId>
            <TotalAmt>35.64</TotalAmt>
            <ProcessPayment>false</ProcessPayment>
        </Header>
        <Line>
            <Amount>35.6400</Amount>
            <TxnId>494527</TxnId>
        </Line>
    </Object>
</Add>

以下是服务器的答案:

<?xml version="1.0" ?>
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
  <Success RequestId="dc07317b838eb3d0c89e310b4984468a">
    <ObjectRef>
      <Id idDomain="NG">494529</Id>
      <SyncToken>1</SyncToken>
      <LastUpdatedTime>2013-02-21T05:48:07Z</LastUpdatedTime>
    </ObjectRef>
    <RequestName>PaymentAdd</RequestName>
    <ProcessedTime>2013-02-21T05:48:07Z</ProcessedTime>
  </Success>
</RestResponse>

1 个答案:

答案 0 :(得分:1)

首先,为了清楚起见,确保您正在构建正确的平台 - 根据Intuit FAQs(截至2013年2月),如果这是一个仅针对您公司的内部集成,那么您应该'使用Intuit Anywhere / IPP。来自FAQ:

  问:我想将我的自定义(非SaaS,单租户)解决方案与Intuit Anywhere集成。我可以这样做吗?

     <答:答:不是今天,但我们正在考虑它。

作为旁注,对于与QuickBooks for Windows的内部集成,Web连接器比Intuit Anywhere更加可靠且更容易排除故障。

尽管如此......您的问题很可能与订单项以及您(未)引用的项目有关。在QuickBooks中,每个行项目都附加到QuicKBooks中的特定项目记录(它是GUI中的“项目名称/ SKU”下拉列表)。

您的订单项,但是:

  <Line>
    <Desc>Special Product For POS sdf</Desc>
    <Amount>33.0000</Amount>
    <ItemType>Product</ItemType>
    <UnitPrice>33.0000</UnitPrice>
    <Qty>1</Qty>
   </Line>

仅引用项目“类型”(例如“库存”,“产品”,“服务”等)。

您应该在每个订单项中都有一个标记:

<ItemName>Your QuickBooks Item Name</ItemName>

或者:

<ItemId>123</ItemId>

如果您查看网页上的documentation或部分QuickBooks IDS/Intuit Anywhere examples,您会看到他们在每个订单项中都使用ItemName或ItemId。

您可能还想查看how to fetch the write back errors,因为这会为您提供更多信息(值得注意的是PHP DevKit目前没有用于获取这些错误的本机方法,但这是我们正在工作的东西如果你需要进一步的帮助,请联系我。)