我们正在尝试将亚马逊商业API整合到网站中。
这是项目的流程。筹款人将把amazon business api的产品添加到项目中,然后管理员批准/将项目发布到网站上。一旦通过网站为相应项目收集资金。管理员将从亚马逊购买产品。
我们已经生成了亚马逊电子采购打孔网址,我们可以进入亚马逊商业网站并将产品添加到购物车。点击“提交这些项目以获得批准”后,我们可以在项目中获得购物车响应。但问题是订单ID未生成且无法在亚马逊网站管理员帐户“批准订单”页面中看到这些订单。
以下是我们发送给亚马逊业务的请求代码。请指导/建议我们在哪里犯了错误。
Punchout设置请求:
<?php
$soapUrl = "https://www.amazon.com/eprocurement/punchout";
$xml_post_string = '<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.007/cXML.dtd">
<cXML version="1.2.007" xml:lang="en-US" payloadID="123456.123456@amazon.com" timestamp="2016-09-01T01:50:29-05:00">
<Header>
<From>
<Credential domain="NetworkId">
<Identity>abcd123</Identity>
</Credential>
</From>
<To>
<Credential domain="NetworkId">
<Identity>Amazon</Identity>
</Credential>
</To>
<Sender>
<Credential domain="NetworkId">
<Identity> abcd123</Identity>
<SharedSecret>test secret</SharedSecret>
</Credential>
<UserAgent>amazon.com</UserAgent>
</Sender>
</Header>
<Request>
<PunchOutSetupRequest operation="create">
<BuyerCookie>1234567</BuyerCookie>
<Extrinsic name="RequestID">5826623</Extrinsic>
<Extrinsic name="MUDID">CLS21518</Extrinsic>
<Extrinsic name="Location">RTP</Extrinsic>
<Extrinsic name="Country">UNITED STATES</Extrinsic>
<Extrinsic name="Email">user@email.org</Extrinsic>
<Extrinsic name="ClientMUDID">CLS21518</Extrinsic>
<Extrinsic name="UserEmail">user@email.org</Extrinsic>
<Extrinsic name="Division">Corporate</Extrinsic>
<Extrinsic name="StartDate">1/9/2016 2:34:36 PM</Extrinsic>
<BrowserFormPost>
<URL>http://www.test.com/ test/response.php</URL>
</BrowserFormPost>
<Contact>
<Name xml:lang="en-US">Jones, Tom</Name>
<Email>user@email.org</Email>
</Contact>
<SupplierSetup>
<URL>http://workchairs.com/cxml</URL>
</SupplierSetup>
</PunchOutSetupRequest>
</Request>
</cXML>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: https://www.amazon.com/eprocurement/punchout",
"Content-length: ".strlen($xml_post_string),
);
$url = $soapUrl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo "<pre>"; print_r($parser); exit;
?>
Punchout设置响应:
SimpleXMLElement Object
(
[@attributes] => Array
(
[payloadID] => 1234567981324.123.1234@amazon.com
[timestamp] => 2016-09-01T10:37:29+10:37
)
[Response] => SimpleXMLElement Object
(
[Status] => SimpleXMLElement Object
(
[@attributes] => Array
(
[code] => 200
[text] => success
)
)
[PunchOutSetupResponse] => SimpleXMLElement Object
(
[StartPage] => SimpleXMLElement Object
(
[URL] => https://www.amazon.com/eprocurement/initiate-clean-punchout/123-1234567-1234567
)
)
)
)
Punchout Order Message:
SimpleXMLElement Object
(
[@attributes] => Array
(
[payloadID] => 1234567981234.105.9597@amazon.com
[timestamp] => 2016-09-01T10:37:53.985Z
)
[Header] => SimpleXMLElement Object
(
[From] => SimpleXMLElement Object
(
[Credential] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[domain] => DUNS
)
[Identity] => 123465789
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[domain] => NetworkId
)
[Identity] => Amazon
)
)
)
[To] => SimpleXMLElement Object
(
[Credential] => SimpleXMLElement Object
(
[@attributes] => Array
(
[domain] => NetworkId
)
[Identity] => abcd123
)
)
[Sender] => SimpleXMLElement Object
(
[Credential] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[domain] => DUNS
)
[Identity] => 123456789
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[domain] => NetworkId
)
[Identity] => Amazon
)
)
[UserAgent] => Amazon LLC eProcurement Application
)
)
[Message] => SimpleXMLElement Object
(
[PunchOutOrderMessage] => SimpleXMLElement Object
(
[BuyerCookie] => 1234567
[PunchOutOrderMessageHeader] => SimpleXMLElement Object
(
[@attributes] => Array
(
[operationAllowed] => create
)
[Total] => SimpleXMLElement Object
(
[Money] => 1.88
)
)
[ItemIn] => SimpleXMLElement Object
(
[@attributes] => Array
(
[quantity] => 1
)
[ItemID] => SimpleXMLElement Object
(
[SupplierPartID] => D00004ABC1
[SupplierPartAuxiliaryID] => 123-1234567-1234567,1
)
[ItemDetail] => SimpleXMLElement Object
(
[UnitPrice] => SimpleXMLElement Object
(
[Money] => 1.88
)
[Description] => Mead Composition Book, Wide Ruled, 9.75 x 7.50 Inch Sheet Size, Black Marble, Bookbound, 100 Sheets (09910)
[UnitOfMeasure] => EA
[Classification] => 14111514
[ManufacturerPartID] => UPC-800187711702
[ManufacturerName] => MeadWestvaco Consumer & Office Products
[Extrinsic] => Array
(
[0] => Amazon
[1] => Amazon
[2] => gl_office_product
[3] => OFFICE_PRODUCTS
[4] => New
[5] => true
)
)
)
)
)
)
我们成功收到亚马逊商家的回复。但订单详细信息未与实际的亚马逊商业帐户相关联。
一旦从管理方获得资金,就可以购买产品。订单详细信息需要在亚马逊商业帐户中提供。
我们是否遗漏了请求脚本?或者是否需要在亚马逊商业帐户中进行任何设置?