Update payment in open-source QuickBooks PHP DevKit on GitHub

跟風遠走 提交于 2019-12-12 02:47:14

问题


I am using the open-source QuickBooks PHP DevKit on GitHub. I am trying to update a payment. But I am getting an error "ERROR!2030: [Invalid ID, Id should be a valid number. Supplied value:{-17}]"

Code I had given is shown below First added code for update function in Quickbooks/IPP/Service/Payment.php like below:

public function update($Context, $realm, $IDType, $Object)
{
    return parent::_update($Context, $realm, QuickBooks_IPP_IDS::RESOURCE_PAYMENT, $Object, $IDType);
}

After that in the payment_update.php page, I added the code as given below:

$IPP->version(QuickBooks_IPP_IDS::VERSION_3);

$PaymentService = new QuickBooks_IPP_Service_Payment();

$payments = $PaymentService->query($Context, $realm, "SELECT * FROM Payment where Id='27'");
$Payment = $payments[0];        
$Payment->setPaymentRefNum("5Update");



if ($resp = $PaymentService->update($Context, $realm, $Payment->getId(), $Payment))
{
    print('Updated the item name to ' . $Payment->getTotalAmt());
}
else
{
    print('ERROR!');
    print($PaymentService->lastError($Context));
}

Do I need to add any other changes in the class file for updating a payment. Please advise how can I update payment & line.

Request:

POST https://quickbooks.api.intuit.com/v3/company/1214054285/payment HTTP/1.1
Content-Type: application/xml
Authorization: OAuth realm="", oauth_signature_method="HMAC-SHA1", oauth_signature="XXXX",  oauth_nonce="zVYx5", oauth_timestamp="1402573818", oauth_token="XXXX", oauth_consumer_key="XXXXX", oauth_version="1.0"
Content-Length: 1023

<Payment xmlns="http://schema.intuit.com/finance/v3">
    <Id>27</Id>
    <SyncToken>1</SyncToken>
    <MetaData xmlns="http://schema.intuit.com/finance/v3">
        <CreateTime>2014-06-12T00:36:12-07:00</CreateTime>
        <LastUpdatedTime>2014-06-12T00:37:44-07:00</LastUpdatedTime>
    </MetaData>
    <Line xmlns="http://schema.intuit.com/finance/v3">
        <Amount>12.00</Amount>
        <LinkedTxn xmlns="http://schema.intuit.com/finance/v3">
            <TxnId>{-17}</TxnId>
            <TxnType>Invoice</TxnType>
        </LinkedTxn>
    </Line>
    <Line xmlns="http://schema.intuit.com/finance/v3">
        <Amount>5.00</Amount>
        <LinkedTxn xmlns="http://schema.intuit.com/finance/v3">
            <TxnId>{-13}</TxnId>
            <TxnType>Invoice</TxnType>
        </LinkedTxn>
    </Line>
    <TxnDate>2014-05-11</TxnDate>
    <CurrencyRef>USD</CurrencyRef>
    <CustomerRef>12</CustomerRef>
    <DepositToAccountRef>18</DepositToAccountRef>
    <PaymentRefNum>5Update</PaymentRefNum>
    <TotalAmt>17.00</TotalAmt>
    <UnappliedAmt>0</UnappliedAmt>
    <ProcessPayment>false</ProcessPayment>
</Payment>

Response:

HTTP/1.1 400 Bad Request
Date: Thu, 12 Jun 2014 11:49:09 GMT
Content-Type: application/xml
Content-Length: 285
intuit_tid: ae570ca6-4f46-4132-978d-f12f394c50d2
Content-Encoding: gzip
Via: 1.1 ipp-gateway-.net
Vary: Accept-Encoding
Connection: close

回答1:


This was fixed in an update several months ago.

Please use the latest code from GitHub and you should be all set:

  • https://github.com/consolibyte/quickbooks-php


来源:https://stackoverflow.com/questions/24182129/update-payment-in-open-source-quickbooks-php-devkit-on-github

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!