Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AmazonOrder.php #9

Merged
merged 5 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/AmazonCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ abstract class AmazonCore
protected $env;
protected $marketplaceId;
protected $rawResponses = array();
protected $proxy_info = [];

/**
* AmazonCore constructor sets up key information used in all Amazon requests.
Expand Down Expand Up @@ -430,6 +431,9 @@ public function setStore($s)
$AMAZON_SERVICE_URL = $store[$s]['amazonServiceUrl'];
$this->urlbase = $AMAZON_SERVICE_URL;
}
if (array_key_exists('proxyInfo', $store[$s])) {
$this->proxy_info = $store[$s]['proxyInfo'];
}

if (array_key_exists('authToken', $store[$s]) && !empty($store[$s]['authToken'])) {
$this->options['MWSAuthToken'] = $store[$s]['authToken'];
Expand Down Expand Up @@ -725,6 +729,20 @@ function fetchURL($url, $param)
}
}

if (!empty($this->proxy_info)
&& !empty($this->proxy_info['ip'])
&& !empty($this->proxy_info['port'])
) {
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); //代理认证模式
curl_setopt($ch, CURLOPT_PROXY, $this->proxy_info['ip']); //代理服务器地址
curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxy_info['port']); //代理服务器端口
//http代理认证帐号,username:password的格式
if (!empty($this->proxy_info['user_pwd'])) {
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->proxy_info['user_pwd']);
}
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); //使用http代理模式
}

$data = curl_exec($ch);
if (curl_errno($ch)) {
$return['ok'] = -1;
Expand Down
34 changes: 31 additions & 3 deletions src/AmazonOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,16 @@ protected function parseXML($xml)
if (isset($xml->BuyerEmail)) {
$d['BuyerEmail'] = (string)$xml->BuyerEmail;
}
if (isset($xml->ShipmentServiceLevelCategory)){
if (isset($xml->PaymentMethodDetails)) {
$d['PaymentMethodDetails'] = array();

$i = 0;
foreach ($xml->PaymentMethodDetails->children() as $x) {
$d['PaymentMethodDetails']['PaymentMethodDetail'][] = (string) $x;
$i++;
}
}
if (isset($xml->ShipmentServiceLevelCategory)) {
$d['ShipmentServiceLevelCategory'] = (string)$xml->ShipmentServiceLevelCategory;
}
if (isset($xml->CbaDisplayableShippingLabel)){
Expand Down Expand Up @@ -640,14 +649,33 @@ public function getBuyerEmail()
* </ul>
* @return string|boolean single value, or <b>FALSE</b> if category not set yet
*/
public function getShipmentServiceLevelCategory(){
if (isset($this->data['ShipmentServiceLevelCategory'])){
public function getShipmentServiceLevelCategory()
{
if (isset($this->data['ShipmentServiceLevelCategory'])) {
return $this->data['ShipmentServiceLevelCategory'];
} else {
return false;
}
}

public function getPaymentMethodDetails()
{
if (isset($this->data['PaymentMethodDetails'])) {
return $this->data['PaymentMethodDetails'];
} else {
return false;
}
}

public function getOrderType()
{
if (isset($this->data['OrderType'])) {
return $this->data['OrderType'];
} else {
return false;
}
}

/**
* Use getShipmentServiceLevelCategory instead.
* @deprecated since version 1.3.0
Expand Down