Ошибка ИБП: 250003 Номер лицензии недействительного доступа - PullRequest
0 голосов
/ 07 сентября 2018

Я пытаюсь настроить API доставки UPS в opencart и получаю сообщение об ошибке 250003 Номер недействительного доступа. Я скачал комплект для разработки доставки UPS с официального сайта UPS. Я заглянул на форумы и обнаружил, что проблема связана с полномочиями. Я восстановил ключ доступа и все еще получаю ту же ошибку.

Я создал файл контроллера и вот мой код:

<code>    class ControllerSaleUpsShipping extends Controller {
    //Configuration
    private $access = "my_access_key";
    private $userid = "my_account_username";
    private $passwd = "my_account_password";
    private $wsdl = HTTPS_UPS."Ship.wsdl"; // HTTPS_UPS this is the https url to the UPS folder where all schemas file are placed.

    private $operation = "ProcessShipment";
    private $endpointurl = 'https://wwwcie.ups.com/webservices/Ship';
    //private $endpointurl = https://onlinetools.ups.com/webservices/Ship //production URL

    private $outputFileName = DIR_UPS."XOLTResult.xml"; // DIR_UPS this is the absolute path to the UPS folder where all schemas file are placed.
    public function index()
    {
        try
        {
            $opts = array(
                'http' => array(
                    'user_agent' => 'PHPSoapClient'
                )
            );
            $context = stream_context_create($opts);
            $mode = array
            (
                'soap_version' => 'SOAP_1_1',  // use soap 1.1 client
                'trace' => 1,
                'stream_context' => $context
            );

            // initialize soap client
            $client = new SoapClient($this->wsdl , $mode);

            //set endpoint url
            $client->__setLocation($this->endpointurl);


            //create soap header
            $usernameToken['Username'] = $this->userid;
            $usernameToken['Password'] = $this->passwd;
            $serviceAccessLicense['AccessLicenseNumber'] = $this->access;
            $upss['UsernameToken'] = $this->usernameToken;
            $upss['ServiceAccessToken'] = $this->serviceAccessLicense;

            $header = new SoapHeader('http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0','UPSSecurity',$upss);
            $client->__setSoapHeaders($header);

            if(strcmp($this->operation,"ProcessShipment") == 0 )
            {
                //get response
            $resp = $client->__soapCall('ProcessShipment',array($this->processShipment()));
                 //get status
                echo "Response Status: " . $resp->Response->ResponseStatus->Description ."\n";

                //save soap request and response to file
                echo $this->outputFileName."demo";
                $fw = fopen($this->outputFileName , 'w');
                fwrite($fw , "Request: \n" . $client->__getLastRequest() . "\n");
                fwrite($fw , "Response: \n" . $client->__getLastResponse() . "\n");
                fclose($fw);

            }
            else if (strcmp($this->operation , "ProcessShipConfirm") == 0)
            {
                    //get response
            $resp = $client->__soapCall('ProcessShipConfirm',array($this->processShipConfirm()));

                 //get status
                echo "Response Status: " . $resp->Response->ResponseStatus->Description ."\n";

                //save soap request and response to file
                $fw = fopen($this->outputFileName , 'w');
                fwrite($fw , "Request: \n" . $client->__getLastRequest() . "\n");
                fwrite($fw , "Response: \n" . $client->__getLastResponse() . "\n");
                fclose($fw);

            }
            else
            {
                $resp = $client->__soapCall('ProcessShipeAccept',array($this->processShipAccept()));

                //get status
                echo "Response Status: " . $resp->Response->ResponseStatus->Description ."\n";

            //save soap request and response to file
            $fw = fopen($this->outputFileName ,'w');
            fwrite($fw , "Request: \n" . $client->__getLastRequest() . "\n");
                fwrite($fw , "Response: \n" . $client->__getLastResponse() . "\n");
                fclose($fw);
            }
        }
        catch(Exception $ex)
        {
            echo "<pre>";print_r ($ex);echo "
"; } } публичная функция processShipment () { $ This-> load-> модель ( 'продажа / заказ'); $ order_id = 394; $ order_info = $ this-> model_sale_order-> getOrder ($ order_id); $ products = $ this-> model_sale_order-> getOrderProducts ($ order_id); // создаем запрос на мыло $ requesttoption ['RequestOption'] = 'nonvalidate'; $ request ['Request'] = $ requesttoption; $ shipment ['Description'] = ''; $ counter = 1; foreach ($ products as $ row_product) { $ shipment ['Description']. = $ row_product ['name']; if ($ counter! = count ($ products)) { $ shipment ['Description']. = ","; } $ counter = $ counter + 1; } $ shipper ['Name'] = 'name'; $ shipper ['AttentionName'] = 'имя внимания'; $ shipper ['TaxIdentificationNumber'] = 'my_tax_number'; $ shipper ['ShipperNumber'] = 'my_shipper_number'; $ address ['AddressLine'] = 'my_address'; $ address ['City'] = 'my_city'; $ address ['StateProvinceCode'] = 'CA'; $ address ['PostalCode'] = '90220'; $ address ['CountryCode'] = 'US'; $ shipper ['Address'] = $ address; $ phone ['Number'] = 'my_number'; $ phone ['Extension'] = '1'; $ shipper ['Phone'] = $ phone; $ shipment ['Shipper'] = $ shipper; $ shipto ['Name'] = $ order_info ['shipping_firstname']. "". $ order_info ['shipping_lastname']; $ shipto ['AttentionName'] = 'Имя'; $ addressTo ['AddressLine'] = $ order_info ['shipping_address_1']; $ addressTo ['City'] = $ order_info ['shipping_city']; $ addressTo ['PostalCode'] = $ order_info ['shipping_postcode']; $ addressTo ['CountryCode'] = $ this-> getCountryCode ($ order_info ['shipping_country']); $ phone2 ['Number'] = ''; $ shipto ['Address'] = $ addressTo; $ shipto ['Phone'] = $ phone2; $ shipment ['ShipTo'] = $ shipto; $ shipfrom ['Name'] = 'my_company_name'; $ shipfrom ['AttentionName'] = 'my_AttentionName'; $ addressFrom ['AddressLine'] = 'my_Address'; $ addressFrom ['City'] = 'my_city'; $ addressFrom ['StateProvinceCode'] = 'CA'; $ addressFrom ['PostalCode'] = '90220'; $ addressFrom ['CountryCode'] = 'US'; $ phone3 ['Number'] = 'my_number'; $ shipfrom ['Address'] = $ addressFrom; $ shipfrom ['Phone'] = $ phone3; $ shipment ['ShipFrom'] = $ shipfrom; $ shipmentcharge ['Type'] = '01'; $ billshipper ['AccountNumber'] = 'my_shipper_number'; $ shipmentcharge ['BillShipper'] = $ billshipper; $ paymentinformation ['ShipmentCharge'] = $ shchargecharge; $ shipment ['PaymentInformation'] = $ paymentinformation; $ service ['Code'] = '08'; $ service ['Description'] = 'Ускоренный'; $ shipment ['Service'] = $ service; $ internationalForm ['FormType'] = '01'; $ internationalForm ['InvoiceNumber'] = $ order_id; $ internationalForm ['InvoiceDate'] = дата ("гггг"). дата ("мм"). дата ("дд"); $ internationalForm ['PurchaseOrderNumber'] = $ order_id; $ internationalForm ['TermsOfShipment'] = 'CFR'; $ internationalForm ['ReasonForExport'] = 'Продажа'; if ($ order_info ['shipping_firstname'] == "") { $ customer_name = $ order_info ['payment_firstname']. "". $ order_info ['payment_lastname']; $ customer_address = $ order_info ['payment_address_1']; $ customer_city = $ order_info ['payment_city']; $ customer_postcode = $ order_info ['payment_postcode'];$ customer_state = $ order_info ['payment_zone']; $ customer_country = $ order_info ['payment_country']; } еще { $ customer_name = $ order_info ['shipping_firstname']. "". $ order_info ['shipping_lastname']; $ customer_address = $ order_info ['shipping_address_1']; $ customer_city = $ order_info ['shipping_city']; $ customer_postcode = $ order_info ['shipping_postcode']; $ customer_state = $ order_info ['shipping_zone']; $ customer_country = $ order_info ['shipping_country']; } $ shipto ['Name'] = $ customer_name; $ shipto ['AttentionName'] = 'name'; $ addressTo ['AddressLine'] = $ customer_address; $ addressTo ['City'] = $ customer_city; $ addressTo ['StateProvinceCode'] = $ customer_state; $ addressTo ['PostalCode'] = $ customer_postcode; $ addressTo ['CountryCode'] = $ this-> getCountryCode ($ customer_country); $ phone2 ['Number'] = ''; $ shipto ['Address'] = $ addressTo; $ shipto ['Phone'] = $ phone2; $ shipment ['ShipTo'] = $ shipto; $ soldTo ['Option'] = '01'; $ soldTo ['AttentionName'] = $ customer_name; $ soldTo ['Name'] = $ customer_name; $ soldToPhone ['Number'] = $ order_info ['phone']; $ soldTo ['Phone'] = $ soldToPhone; $ soldToAddress ['AddressLine'] = $ customer_address; $ soldToAddress ['City'] = $ customer_city; $ soldToAddress ['StateProvinceCode'] = $ customer_state; $ soldToAddress ['PostalCode'] = $ customer_postcode; $ soldToAddress ['CountryCode'] = $ this-> getCountryCode ($ customer_country); $ soldTo ['Address'] = $ soldToAddress; $ contact ['SoldTo'] = $ soldTo; $ internationalForm ['Contacts'] = $ contact; $ product ['Description'] = $ shipment ['Description']; $ product ['OriginCountryCode'] = 'US'; foreach ($ products as $ row_product) { $ options = $ this-> model_sale_order-> getOrderOptions ($ order_id, $ row_product ['order_product_id']); if (count ($ products)> 1) { $ unitProduct ['Number'. $ counter] = $ row_product ['количество']; $ unitProduct ['Value'. $ counter] = $ row_product ['price']; foreach ($ options как $ option) { $ uom ['Code'. $ counter] = $ option ['sku']; $ uom ['Description'. $ counter] = $ option ['sku']; } } еще { $ unitProduct ['Number'] = $ row_product ['number']; $ unitProduct ['Value'] = $ row_product ['price']; foreach ($ options как $ option) { $ uom ['Code'] = $ option ['sku']; $ uom ['Description'] = $ option ['sku']; } } $ counter = $ counter + 1; } $ unitProduct ['UnitOfMeasurement'] = $ uom; $ product ['Unit'] = $ unitProduct; $ productWeight ['Weight'] = '3'; $ uomForWeight ['Code'] = 'LBS'; $ uomForWeight ['Description'] = 'LBS'; $ productWeight ['UnitOfMeasurement'] = $ uomForWeight; $ product ['ProductWeight'] = $ productWeight; $ internationalForm ['Product'] = $ product; $ internationalForm ['CurrencyCode'] = 'USD'; $ shpServiceOptions ['InternationalForms'] = $ internationalForm; $ shipment ['ShipmentServiceOptions'] = $ shpServiceOptions; $ package ['Description'] = ''; $ Packaging ['Code'] = '02'; $ Packaging ['Description'] = 'Продукты'; $ package ['Packaging'] = $ packaging; $ unit ['Code'] = 'IN'; $ unit ['Description'] = 'Дюймы'; $ sizes ['UnitOfMeasurement'] = $ unit; $ sizes ['Length'] = '7'; $ sizes ['Width'] = '5'; $ sizes ['Height'] = '2'; $ package ['Dimensions'] = $ sizes; $ unit2 ['Code'] = 'LBS'; $ unit2 ['Description'] = 'Фунты'; $ packageweight ['UnitOfMeasurement'] = $ unit2;$ packageweight ['Weight'] = '10'; $ package ['PackageWeight'] = $ packageweight; $ shipment ['Package'] = $ package; $ labelimageformat ['Code'] = 'GIF'; $ labelimageformat ['Description'] = 'GIF'; $ labelpecification ['LabelImageFormat'] = $ labelimageformat; $ labelpecification ['HTTPUserAgent'] = 'Mozilla / 4.5'; $ shipment ['LabelSpecification'] = $ labelpecification; $ request ['Shipment'] = $ shipment; echo "Request ....... \ n"; // echo "
";print_r($request);echo "
"; эхо "\ n \ n"; вернуть $ запрос; } функция processShipConfirm () { // создаем запрос на мыло } функция processShipAccept () { // создаем запрос на мыло } / ** Функция для получения двухзначного кода страны ** / функция getCountryCode ($ страна) { $ country = ($ country == "Соединенные Штаты"? "Соединенные Штаты Америки": $ страна); $ data = @file_get_contents ("https://restcountries.eu/rest/v2/name/".$country); $ result = json_decode ($ data); // echo "
";print_r($result);echo "
"; return $ result [0] -> alpha2Code; } }

Есть ли способ отладить проблему?

Заранее спасибо

1 Ответ

0 голосов
/ 06 ноября 2018

Ну, это никогда не работает легко,

хорошо, попробуйте это, заставьте ИБП удалить, а затем установите его снова, это должно дать вам новый ключ доступа, теперь используйте этот новый ключ и посмотрите, работает ли он, вот некоторые методы, которые работали для других разработчиков

(1) "Для меня это был просто неправильный код доступа, мне нужен был код доступа xml. Мне также пришлось вернуться на сайт UPS и запросить ключ доступа (код) XML, а не ключ доступа HTML, который Сначала я использовал поле «Код доступа ИБП» для модуля ИБП. Теперь работает - или, по крайней мере, отображает параметры доставки ИБП при оформлении заказа. "

(2) «Шахта решена. Мне нужно было убедиться, что у меня опубликованы, обязательны для заполнения и видны поля« Страна »,« Штат »и« Почтовый пользователь »во всех местах. Также вы можете попытаться сделать« Метод регистрации »« Обязательным ». После настройки этого параметра вам необходимо вручную ввести необходимые поля пользователя. Метод регистрации виртуальной машины не связывается с полями пользователя. Это ошибка. «

, а если нет, я бы предложил вам связаться с UPS напрямую.

...