|
@@ 859-915 (lines=57) @@
|
| 856 |
|
* @return array |
| 857 |
|
* @version 1.0.1012 |
| 858 |
|
*/ |
| 859 |
|
public function CreateUnimartB2CReturnOrder() |
| 860 |
|
{ |
| 861 |
|
|
| 862 |
|
// 參數初始化 |
| 863 |
|
$ParamList = [ |
| 864 |
|
'MerchantID' => '', |
| 865 |
|
'AllPayLogisticsID' => '', |
| 866 |
|
'ServerReplyURL' => '', |
| 867 |
|
'GoodsName' => '', |
| 868 |
|
'GoodsAmount' => 0, |
| 869 |
|
'SenderName' => '', |
| 870 |
|
'SenderPhone' => '', |
| 871 |
|
'Remark' => '', |
| 872 |
|
'PlatformID' => '', |
| 873 |
|
]; |
| 874 |
|
$this->PostParams = $this->GetPostParams($this->Send, $ParamList); |
| 875 |
|
$this->PostParams['CollectionAmount'] = 0; |
| 876 |
|
$this->PostParams['ServiceType'] = 4; // 退貨不付款 |
| 877 |
|
|
| 878 |
|
// 參數檢查 |
| 879 |
|
$this->ValidateHashKey(); |
| 880 |
|
$this->ValidateHashIV(); |
| 881 |
|
$this->ValidateID('MerchantID', $this->PostParams['MerchantID'], 10); |
| 882 |
|
$this->ServiceURL = $this->GetURL('UNIMART_RETURN_ORDER'); |
| 883 |
|
$this->ValidateID('AllPayLogisticsID', $this->PostParams['AllPayLogisticsID'], 20, true); |
| 884 |
|
$this->ValidateURL('ServerReplyURL', $this->PostParams['ServerReplyURL']); |
| 885 |
|
$this->ValidateString('GoodsName', $this->PostParams['GoodsName'], 60, true); |
| 886 |
|
$this->ValidateAmount('GoodsAmount', $this->PostParams['GoodsAmount']); |
| 887 |
|
$this->ValidateString('SenderName', $this->PostParams['SenderName'], 50); |
| 888 |
|
$this->ValidatePhoneNumber('SenderPhone', $this->PostParams['SenderPhone'], true); |
| 889 |
|
$this->ValidateString('Remark', $this->PostParams['Remark'], 20, true); |
| 890 |
|
$this->ValidateID('PlatformID', $this->PostParams['PlatformID'], 10, true); |
| 891 |
|
|
| 892 |
|
$MinAmount = 1; // 金額下限 |
| 893 |
|
$MaxAmount = 19999; // 金額上限 |
| 894 |
|
if ($this->PostParams['GoodsAmount'] < $MinAmount or $this->PostParams['GoodsAmount'] > $MaxAmount) { |
| 895 |
|
throw new Exception('Invalid GoodsAmount.'); |
| 896 |
|
} |
| 897 |
|
|
| 898 |
|
// 產生 CheckMacValue |
| 899 |
|
$this->PostParams['CheckMacValue'] = ECPay_CheckMacValue::generate($this->PostParams, $this->HashKey, $this->HashIV); |
| 900 |
|
|
| 901 |
|
// 解析回傳結果 |
| 902 |
|
// 正確:RtnMerchantTradeNo | RtnOrderNo |
| 903 |
|
// 錯誤:|ErrorMessage |
| 904 |
|
$Feedback = ECPay_IO::ServerPost($this->PostParams, $this->ServiceURL); |
| 905 |
|
$Pieces = explode('|', $Feedback); |
| 906 |
|
$Result = ['RtnMerchantTradeNo' => '', 'RtnOrderNo' => '']; |
| 907 |
|
if (empty($Pieces[0])) { |
| 908 |
|
$Result = ['ErrorMessage' => $Pieces[1]]; |
| 909 |
|
} else { |
| 910 |
|
$Result['RtnMerchantTradeNo'] = $Pieces[0]; |
| 911 |
|
$Result['RtnOrderNo'] = $Pieces[1]; |
| 912 |
|
} |
| 913 |
|
|
| 914 |
|
return $Result; |
| 915 |
|
} |
| 916 |
|
|
| 917 |
|
/** |
| 918 |
|
* 超商取貨逆物流訂單(萊爾富超商B2C). |
|
@@ 925-981 (lines=57) @@
|
| 922 |
|
* @return array |
| 923 |
|
* @version 1.0.1012 |
| 924 |
|
*/ |
| 925 |
|
public function CreateHiLifeB2CReturnOrder() |
| 926 |
|
{ |
| 927 |
|
|
| 928 |
|
// 參數初始化 |
| 929 |
|
$ParamList = [ |
| 930 |
|
'MerchantID' => '', |
| 931 |
|
'AllPayLogisticsID' => '', |
| 932 |
|
'ServerReplyURL' => '', |
| 933 |
|
'GoodsName' => '', |
| 934 |
|
'GoodsAmount' => 0, |
| 935 |
|
'SenderName' => '', |
| 936 |
|
'SenderPhone' => '', |
| 937 |
|
'Remark' => '', |
| 938 |
|
'PlatformID' => '', |
| 939 |
|
]; |
| 940 |
|
$this->PostParams = $this->GetPostParams($this->Send, $ParamList); |
| 941 |
|
$this->PostParams['CollectionAmount'] = 0; |
| 942 |
|
$this->PostParams['ServiceType'] = 4; // 退貨不付款 |
| 943 |
|
|
| 944 |
|
// 參數檢查 |
| 945 |
|
$this->ValidateHashKey(); |
| 946 |
|
$this->ValidateHashIV(); |
| 947 |
|
$this->ValidateID('MerchantID', $this->PostParams['MerchantID'], 10); |
| 948 |
|
$this->ServiceURL = $this->GetURL('HILIFE_RETURN_ORDER'); |
| 949 |
|
$this->ValidateID('AllPayLogisticsID', $this->PostParams['AllPayLogisticsID'], 20, true); |
| 950 |
|
$this->ValidateURL('ServerReplyURL', $this->PostParams['ServerReplyURL']); |
| 951 |
|
$this->ValidateString('GoodsName', $this->PostParams['GoodsName'], 60, true); |
| 952 |
|
$this->ValidateAmount('GoodsAmount', $this->PostParams['GoodsAmount']); |
| 953 |
|
$this->ValidateString('SenderName', $this->PostParams['SenderName'], 50); |
| 954 |
|
$this->ValidatePhoneNumber('SenderPhone', $this->PostParams['SenderPhone'], true); |
| 955 |
|
$this->ValidateString('Remark', $this->PostParams['Remark'], 20, true); |
| 956 |
|
$this->ValidateID('PlatformID', $this->PostParams['PlatformID'], 10, true); |
| 957 |
|
|
| 958 |
|
$MinAmount = 1; // 金額下限 |
| 959 |
|
$MaxAmount = 20000; // 金額上限 |
| 960 |
|
if ($this->PostParams['GoodsAmount'] < $MinAmount or $this->PostParams['GoodsAmount'] > $MaxAmount) { |
| 961 |
|
throw new Exception('Invalid GoodsAmount.'); |
| 962 |
|
} |
| 963 |
|
|
| 964 |
|
// 產生 CheckMacValue |
| 965 |
|
$this->PostParams['CheckMacValue'] = ECPay_CheckMacValue::generate($this->PostParams, $this->HashKey, $this->HashIV); |
| 966 |
|
|
| 967 |
|
// 解析回傳結果 |
| 968 |
|
// 正確:RtnMerchantTradeNo | RtnOrderNo |
| 969 |
|
// 錯誤:|ErrorMessage |
| 970 |
|
$Feedback = ECPay_IO::ServerPost($this->PostParams, $this->ServiceURL); |
| 971 |
|
$Pieces = explode('|', $Feedback); |
| 972 |
|
$Result = ['RtnMerchantTradeNo' => '', 'RtnOrderNo' => '']; |
| 973 |
|
if (empty($Pieces[0])) { |
| 974 |
|
$Result = ['ErrorMessage' => $Pieces[1]]; |
| 975 |
|
} else { |
| 976 |
|
$Result['RtnMerchantTradeNo'] = $Pieces[0]; |
| 977 |
|
$Result['RtnOrderNo'] = $Pieces[1]; |
| 978 |
|
} |
| 979 |
|
|
| 980 |
|
return $Result; |
| 981 |
|
} |
| 982 |
|
|
| 983 |
|
/** |
| 984 |
|
* 超商取貨逆物流訂單(全家超商B2C). |