尝试将PDF发票上载到Amazon MWS会导致错误:“在上载发票时,请仅提供一个有效的市场". [英] Trying to upload PDF invoice to Amazon MWS results in Error: "Please provide only one valid marketplace while uploading an invoice"
问题描述
我目前正在尝试弄清楚如何使用php/curl将自己的发票pdf文件上传到Amazon MWS:1.)使用操作:SubmitFeed和FeedType: UPLOAD_VAT_INVOICE 将pdf上传到Amazon MWS.这会通过FeedSubmissionId给出肯定的答复
I am currently trying to figure out how to upload my own invoice pdf files to Amazon MWS with php/curl: 1.) Upload pdf to Amazon MWS using Action: SubmitFeed and FeedType: UPLOAD_VAT_INVOICE This is giving a positive response with a FeedSubmissionId
2.)获取具有该FeedSubmissionId的Feed提交结果报告错误79523,请在上载发票时仅提供一个有效的市场."
2.) Get Feed Submission Result with that FeedSubmissionId is reporting an Error 79523 "Please provide only one valid marketplace while uploading an invoice."
所以我认为我的上传工作不正常,但是我找不到错误.
So I assume that my upload is not working properly, but I can not find the mistake.
该错误文件在Amazon的PDF文件的第21页中进行了描述:增值税计算服务(VCS)开发人员指南
The Error Code is described on Page 21 in this PDF File from Amazon: VAT Calculation Service (VCS) Developer Guide
到目前为止,我已经花了2天的时间来尝试解决此问题,但是在Google上却找不到任何相关信息.希望这里有人可以帮助我.谢谢!
I have spent 2 days so far, trying to solve this, and I was not able to find anything about it on google. Hope someone here can help me. Thanks!
这是代码:
<?php
$param = array();
$param['AWSAccessKeyId'] = 'XXXXX';
$param['Action'] = 'SubmitFeed';
$param['Merchant'] = 'XXXXX';
$param['FeedType'] = '_UPLOAD_VAT_INVOICE_';//'_POST_ORDER_FULFILLMENT_DATA_';
$param['FeedOptions'] = 'metadata:OrderId='.$amz_order_id.';metadata:TotalAmount='.$TotalAmount.';metadata:TotalVATAmount='.$TotalVATAmount.';metadata:InvoiceNumber='.$InvoiceNumber.';metadata:documenttype=Invoice';
$param['SignatureMethod'] = 'HmacSHA256';
$param['SignatureVersion'] = '2';
$param['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
$param['Version'] = '2009-01-01';
$param['MarketplaceIdList.Id.1'] = 'A1PA6795UKMFR9';
$param['PurgeAndReplace'] = 'false';
$secret = 'XXXXX';
$url = array();
foreach ($param as $key => $val) {
$key = str_replace("%7E", "~", rawurlencode($key));
$val = str_replace("%7E", "~", rawurlencode($val));
$url[] = "{$key}={$val}";
}
sort($url);
$file = fopen($link_to_pdf_file,"r");
$pdf_feed=fread($file,filesize($FileName));
fclose($file);
$amazon_feed='<?xml version="1.0" encoding="utf-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>'.$param['Merchant'].'</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>'.getserial().'</MessageID>
<OrderFulfillment>
<AmazonOrderID>'.$amz_order_id.'</AmazonOrderID>
<FulfillmentDate>'.$param['Timestamp'].'</FulfillmentDate>
<FulfillmentData>
<CarrierName>Deutsche Post</CarrierName>
<ShippingMethod>Brief</ShippingMethod>
<ShipperTrackingNumber></ShipperTrackingNumber>
</FulfillmentData>
</OrderFulfillment>
</Message>
</AmazonEnvelope>';
$arr = implode('&', $url);
$sign = 'POST' . "\n";
$sign .= 'mws.amazonservices.de' . "\n";
$sign .= '/Feeds/'.$param['Version'].'' . "\n";
$sign .= $arr;
$signature = hash_hmac("sha256", $sign, $secret, true);
$httpHeader = array();
$httpHeader[] = 'Transfer-Encoding: chunked';
$httpHeader[] = 'Content-Type: application/octet-stream';//application/pdf
$httpHeader[] = 'Content-MD5: ' . base64_encode(md5($pdf_feed, true));
$httpHeader[] = 'Expect:';
$httpHeader[] = 'Accept:';
$signature = urlencode(base64_encode($signature));
$link = "https://mws.amazonservices.de/Feeds/".$param['Version']."?";
$link .= $arr . "&Signature=" . $signature;
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $amazon_feed);
$response['reply'] = curl_exec($ch);
$response['info'] = curl_getinfo($ch);
curl_close($ch);
?>
推荐答案
没有任何XML可以与此提要一起发布.FeedContent( CURLOPT_POSTFIELDS
)是PDF的内容( $ pdf_feed
)
There is no XML to post with this feed. FeedContent (CURLOPT_POSTFIELDS
) is the content of the PDF ($pdf_feed
)
这篇关于尝试将PDF发票上载到Amazon MWS会导致错误:“在上载发票时,请仅提供一个有效的市场".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!