double-break / spapi-php

Amazon Selling Partner API PHP Client
MIT License
56 stars 48 forks source link

Update ASECryptoStream.php #35

Closed dishcheng closed 3 years ago

dishcheng commented 3 years ago

After I upload xml,I will get like this result

array:3 [
  "Header" => array:2 [
    "DocumentVersion" => "1.02"
    "MerchantIdentifier" => "xxxxxxxx"
  ]
  "MessageType" => "ProcessingReport"
  "Message" => array:2 [
    "MessageID" => "1"
    "ProcessingReport" => array:4 [
      "DocumentTransactionID" => "xxxxxxxxxx"
      "StatusCode" => "Complete"
      "ProcessingSummary" => array:4 [
        "MessagesProcessed" => "0"
        "MessagesSuccessful" => "0"
        "MessagesWithError" => "1"
        "MessagesWithWarning" => "0"
      ]
      "Result" => array:4 [
        "MessageID" => "0"
        "ResultCode" => "Error"
        "ResultMessageCode" => "5001"
        "ResultDescription" => "XML Parsing Fatal Error at Line 1, Column 636: Content is not allowed in trailing section. Content is not allowed in trailing section."
      ]
    ]
  ]
]

For example,myxml like this

<?xml version="1.0" encoding="utf-8" ?>\n
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">\n
    <Header>\n
        <DocumentVersion>1.01</DocumentVersion>\n
        <MerchantIdentifier>XXXXXXXXX</MerchantIdentifier>\n
    </Header>\n
    <MessageType>Price</MessageType>\n
    <Message>\n
        <MessageID>1</MessageID>\n
        <OperationType>Update</OperationType>\n
        <Price>\n
            <SKU>XX-XXXX-XXXX</SKU>\n
            <StandardPrice currency="USD">14.00</StandardPrice>\n
            <Sale>\n
                <StartDate>2021-06-29T00:00:00Z</StartDate>\n
                <EndDate>2026-03-11T00:00:00Z</EndDate>\n
                <SalePrice currency="USD">15.00</SalePrice>\n
            </Sale>\n
        </Price>\n
    </Message>\n
</AmazonEnvelope>

after getPaddedText will become like this

<?xml version="1.0" encoding="utf-8" ?>\n
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">\n
    <Header>\n
        <DocumentVersion>1.01</DocumentVersion>\n
        <MerchantIdentifier>XXXXXXXXX</MerchantIdentifier>\n
    </Header>\n
    <MessageType>Price</MessageType>\n
    <Message>\n
        <MessageID>1</MessageID>\n
        <OperationType>Update</OperationType>\n
        <Price>\n
            <SKU>XX-XXXX-XXXX</SKU>\n
            <StandardPrice currency="USD">14.00</StandardPrice>\n
            <Sale>\n
                <StartDate>2021-06-29T00:00:00Z</StartDate>\n
                <EndDate>2026-03-11T00:00:00Z</EndDate>\n
                <SalePrice currency="USD">15.00</SalePrice>\n
            </Sale>\n
        </Price>\n
    </Message>\n
</AmazonEnvelope>\x00\x00\x00\x00\x00\x00

then end will add \x00\x00\x00\x00\x00\x00