Code Monkey home page Code Monkey logo

ups-php's People

Contributors

abantecart avatar abolabo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ups-php's Issues

installation via composer miss-configured

after using command:
composer require abantecart/ups-php
library is downloaded and installed, but PHP doesent see it.

After further investigation i have found that \vendor\composer\autoload_psr4.php doesent have anything related with abantecart nor ups

What i have also done is:

  • force autoload regenerate with command: dump-autoload
  • manually remove all vendor folder with: rm -rf vendor
  • clean install with: composer install

Any other ideas how to use this library?

Installation Issue - Class "UPS\OAuthClientCredentials\Configuration" not found

Hi,

I'm having installation issues as well. I followed the instructions in this post and still cannot get past the error

Fatal error: Uncaught Error: Class "UPS\OAuthClientCredentials\Configuration" not found in /Users/crazyj9/Library/CloudStorage/Dropbox/Code/Sites/GMLapp/vendor/abantecart/ups-php/_examples/getAccessToken.php:10

Any other ideas to try?

Thank you!
John

License?

Hello there,
we'd like to incorporate the composer package ups-php into our codebase.
Will ups-php stay published open source or are there plans to turn this into a private repository?
I'm asking because there is no license shipped with this repository and we want to avoid the visibility of this repository might change in the future.
Thank you!

Error in OneOfLabelRecoveryResponseLabelResults

There is an issue with the OneOfLabelRecoveryResponseLabelResults class. The class lacks arguments to fetch or retrieve data from the response.

Here is the response from UPS Testing

{ "LabelRecoveryResponse": { "Response": { "ResponseStatus": { "Code": "1", "Description": "Success" }, "TransactionReference": { "CustomerContext": "testing" } }, "ShipmentIdentificationNumber": "1Z12345E8791315509", "LabelResults": { "TrackingNumber": "1Z12345E8791315509", "LabelImage": { "LabelImageFormat": { "Code": "PDF" }, "GraphicImage": "JVBERi0xLjMNJeLjz9MNCjIw=", "URL": "https://www.ups.com/uel/llp/1Z12345E8791315509/link/labelAll/XLBR/0uHrBtnAFwm4NRuUC7XNCqQ7Tb2RRs0D0oimIIqZ3Mse/en_US?loc=en_US&cie=true&pdr=false" }, "Receipt": { "Image": { "ImageFormat": { "Code": "PDF" }, "GraphicImage": "JVBERi0xLjMNJeLjz9MNCjEg" }, "URL": "https://www.ups.com/uel/llp/1Z12345E8791315509/link/receipt/XLBR/0uHrBtnAFwm4NRuUC7XNCqQ7Tb2RRs0D0oimIIqZ3Mse/en_US?loc=en_US&cie=true&pdr=false" } } } }

More Examples?

Hi,
thank you for your work for building this API Wrapper for UPS.
I am not an experienced developer and i am unsure how to use you api. There are examples for authorize and get shipping fees. But
can you give more examples? Like, "how to create a shipping label" and these things?
Thanks a lot

Example not working

HP Fatal error: Uncaught Error: Class "UPS\OAuthClientCredentials\Configuration" not found in /var/www/ppp/ups/getAccessToken.php:11
Stack trace:
#0 {main}
thrown in /var/www/ppp/ups/getAccessToken.php on line 11

i used composer with php8.1

<?php
require_once 'vendor/autoload.php';
//YOUR ACCOUNT NUMBER (6 characters)
$accNumber = 'XXXXXX';
//UPS API Credentials (obtain after APP creation)
$clientId = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX';
$password = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;

$config = \UPS\OAuthClientCredentials\Configuration::getDefaultConfiguration()
    ->setUsername($clientId)
    ->setPassword($password);

$apiInstance = new \UPS\OAuthClientCredentials\Request\DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
    new \GuzzleHttp\Client(),
    $config
);
$grant_type = "client_credentials"; // string |
$x_merchant_id = $accNumber; // string | Client merchant ID

try {
    $result = $apiInstance->createToken($grant_type, $x_merchant_id);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->generateToken: ', $e->getMessage(), PHP_EOL;
}

?>

Uncaught Error: Class "OneOfRateResponseResponseAlert" not found

I try run a example with this code but no work

Code:

<?php
require_once ('../vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
/** @see getAccessToken.php */
$token = 'you_token';
$config = UPS\Rating\Configuration::getDefaultConfiguration()->setAccessToken($token);

$apiInstance = new UPS\Rating\Request\DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$body = array(
  "RateRequest" => array(
    "Request" => array(
      "TransactionReference" => array(
        "CustomerContext" => "CustomerContext"
      )
    ),
    "Shipment" => array(
      "Shipper" => array(
        "Name" => "Roberto Perez",
        "ShipperNumber" => "123456", //accNumber
        "Address" => array(
          "AddressLine" => array(
            "ShipperAddressLine",
            "ShipperAddressLine",
            "ShipperAddressLine"
          ),
          "City" => "TIMONIUM",
          "StateProvinceCode" => "MD",
          "PostalCode" => "21093",
          "CountryCode" => "US"
        )
      ),
      "ShipTo" => array(
        "Name" => "ShipToName",
        "Address" => array(
          "AddressLine" => array(
            "ShipToAddressLine",
            "ShipToAddressLine",
            "ShipToAddressLine"
          ),
          "City" => "Alpharetta",
          "StateProvinceCode" => "GA",
          "PostalCode" => "30005",
          "CountryCode" => "US"
        )
      ),
      "ShipFrom" => array(
        "Name" => "ShipFromName",
        "Address" => array(
          "AddressLine" => array(
            "ShipFromAddressLine",
            "ShipFromAddressLine",
            "ShipFromAddressLine"
          ),
          "City" => "TIMONIUM",
          "StateProvinceCode" => "MD",
          "PostalCode" => "21093",
          "CountryCode" => "US"
        )
      ),
      "PaymentDetails" => array(
        "ShipmentCharge" => array(
          "Type" => "01",
          "BillShipper" => array(
            "AccountNumber" => "123456" //accNumber
          )
        )
      ),
      "Service" => array(
        "Code" => "03",
        "Description" => "Ground"
      ),
      "NumOfPieces" => "1",
      "Package" => array(
        "SimpleRate" => array(
          "Description" => "SimpleRateDescription",
          "Code" => "XS"
        ),
        "PackagingType" => array(
          "Code" => "02",
          "Description" => "Packaging"
        ),
        "Dimensions" => array(
          "UnitOfMeasurement" => array(
            "Code" => "IN",
            "Description" => "Inches"
          ),
          "Length" => "5",
          "Width" => "5",
          "Height" => "5"
        ),
        "PackageWeight" => array(
          "UnitOfMeasurement" => array(
            "Code" => "LBS",
            "Description" => "Pounds"
          ),
          "Weight" => "1"
        )
      )
    )
  )
);
$version = "v1"; // string | Indicates Rate API to display the new release features in Rate API response based on Rate release. See the New section for the latest Rate release. Supported values: v1, v1601, v1607, v1701, v1707, v2108, v2205. Length 5
$requestoption = "rate"; // string | Valid Values: Rate = The server rates (The default Request option is Rate if a Request Option is not provided). Shop = The server validates the shipment, and returns rates for all UPS products from the ShipFrom to the ShipTo addresses. Rate is the only valid request option for Ground Freight Pricing requests. . Length 10
$trans_id = "trans_id_example"; // string | An identifier unique to the request. Length 32
$transaction_src = "testing"; // string | An identifier of the client/source application that is making the request.Length 512
$additionalinfo = ""; // string | Valid Values: timeintransit = The server rates with transit time information combined with requestoption in URL.Rate is the only valid request option for Ground Freight Pricing requests. Length 15

try {
    $result = $apiInstance->rate(json_encode($body), $version, $requestoption, $trans_id, $transaction_src, $additionalinfo);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->rate: ', $e->getMessage(), PHP_EOL;
}
?>
Error:

PHP Fatal error: Uncaught Error: Class "OneOfRateResponseResponseAlert" not found in /home/demon/php/simple_ups_rate/Rating/src/ObjectSerializer.php:298 Stack trace: #0 /home/demon/php/simple_ups_rate/Rating/src/ObjectSerializer.php(315): UPS\Rating\ObjectSerializer::deserialize() #1 /home/demon/php/simple_ups_rate/Rating/src/ObjectSerializer.php(315): UPS\Rating\ObjectSerializer::deserialize() #2 /home/demon/php/simple_ups_rate/Rating/src/ObjectSerializer.php(315): UPS\Rating\ObjectSerializer::deserialize() #3 /home/demon/php/simple_ups_rate/Rating/src/Request/DefaultApi.php(171): UPS\Rating\ObjectSerializer::deserialize() #4 /home/demon/php/simple_ups_rate/Rating/src/Request/DefaultApi.php(107): UPS\Rating\Request\DefaultApi->rateWithHttpInfo() #5 /home/demon/php/simple_ups_rate/_examples/getRates_.php(115): UPS\Rating\Request\DefaultApi->rate() #6 {main} thrown in /home/demon/php/simple_ups_rate/Rating/src/ObjectSerializer.php on line 298

PackageResults does not work as expected

The PackageResults Property of ShipmentResults can be an array of PackageResults or just the properties of an PackageResults-Object

Single:
"PackageResults": { "TrackingNumber": "1ZXXXXXXXXXXXXXXXX", "ServiceOptionsCharges": { "CurrencyCode": "USD", "MonetaryValue": "0.00" }, "ShippingLabel": { "ImageFormat": { "Code": "ZPL", "Description": "ZPL" }, "GraphicImage": "" } }

Multiple:

"PackageResults": [ { "TrackingNumber": "1ZXXXXXXXXXXXXXXXX", "ServiceOptionsCharges": { "CurrencyCode": "USD", "MonetaryValue": "0.00" }, "ShippingLabel": { "ImageFormat": { "Code": "ZPL", "Description": "ZPL" }, "GraphicImage": "" } }, { "TrackingNumber": "1ZXXXXXXXXXXXXXXXX", "ServiceOptionsCharges": { "CurrencyCode": "USD", "MonetaryValue": "0.00" }, "ShippingLabel": { "ImageFormat": { "Code": "ZPL", "Description": "ZPL" }, "GraphicImage": "" } } ]

The swagger generated classes do not support this and currently only array as PackageResults are supported.

Fatal error: Uncaught Error: Class "UPS/* not found

Hi,

I can't figure out how to fix this. I had a blank directory, used your composer line and am getting this error.

Am I supposed to add another composer line to add the UPS directory? I do not see one in the files.

Fatal error: Uncaught Error: Class "UPS\OAuthClientCredentials\Configuration" not found in /home/NULL/public_html/dadev/wp-content/plugins/rma/ups.php:13 Stack trace: #0 {main} thrown in /home/NULL/public_html/dadev/wp-content/plugins/rma/ups.php on line 13

Thank you

<?php
require __DIR__ . '/vendor/autoload.php';

-- account info removed --

$config = \UPS\OAuthClientCredentials\Configuration::getDefaultConfiguration()
    ->setUsername($clientId)
    ->setPassword($password);

Error in OneOfShipmentResponseShipmentResultsPackageResults

There is an issue with the OneOfShipmentResponseShipmentResultsPackageResults class. The class lacks arguments to fetch or retrieve data from the response.

Here is the response from UPS Testing

{ "ShipmentResponse": { "Response": { "ResponseStatus": { "Code": "1", "Description": "Success" }, "Alert": { "Code": "129001", "Description": "Additional Handling has automatically been set on Package 1." }, "TransactionReference": { "CustomerContext": "testing" } }, "ShipmentResults": { "ShipmentCharges": { "TransportationCharges": { "CurrencyCode": "USD", "MonetaryValue": "87.17" }, "ServiceOptionsCharges": { "CurrencyCode": "USD", "MonetaryValue": "31.40" }, "TotalCharges": { "CurrencyCode": "USD", "MonetaryValue": "118.57" } }, "BillingWeight": { "UnitOfMeasurement": { "Code": "LBS", "Description": "Pounds" }, "Weight": "98.0" }, "ShipmentIdentificationNumber": "1ZXXXXXXXXXXXXXXXX", "PackageResults": { "TrackingNumber": "1ZXXXXXXXXXXXXXXXX", "BaseServiceCharge": { "CurrencyCode": "USD", "MonetaryValue": "71.26" }, "ServiceOptionsCharges": { "CurrencyCode": "USD", "MonetaryValue": "31.40" }, "ShippingLabel": { "ImageFormat": { "Code": "GIF", "Description": "GIF" }, "GraphicImage": "R0lGODlheAUgA/cAAAAAAAEBAQICAg" }, "ItemizedCharges": [ { "Code": "100", "CurrencyCode": "USD", "MonetaryValue": "24.50" }, { "Code": "375", "CurrencyCode": "USD", "MonetaryValue": "15.91" }, { "Code": "432", "CurrencyCode": "USD", "MonetaryValue": "6.90" } ] } } } }

Cannot use "parent" when current class scope has no parent Error

Hi,

I'm try to do zip code check for Saturday delivery (using time in transit) and when I use the zip code 84098 in the request, I'm getting an error:

Cannot use "parent" when current class scope has no parent {"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Cannot use "parent" when current class scope has no parent at /Users/crazyj9/Library/CloudStorage/Dropbox/Code/Sites/GMLapp/vendor/abantecart/ups-php/TimeInTransit/src/TimeInTransit/DestinationPickList.php:181)

Here's the body of the request:

`
UPS\TimeInTransit\TimeInTransit\TimeInTransitRequest Object
(
[container:protected] => Array
(
[origin_country_code] => US
[origin_state_province] =>
[origin_city_name] =>
[origin_town_name] =>
[origin_postal_code] => 04101
[destination_country_code] => US
[destination_state_province] =>
[destination_city_name] =>
[destination_town_name] =>
[destination_postal_code] => 84098
[residential_indicator] => 01
[ship_date] => 2023-12-22
[ship_time] =>
[weight] => 10.5
[weight_unit_of_measure] => LBS
[shipment_contents_value] => 100
[shipment_contents_currency_code] => USD
[bill_type] => 03
[avv_flag] => 1
[number_of_packages] => 1
[drop_off_at_facility_indicator] =>
[hold_for_pickup_indicator] =>
[return_unfilterd_services] =>
[max_list] =>
)

)
`

When I submit this zip code on ups api site, I get a response of destinationAmbiguous=true, which is fine, but the code is failing. Can you take a look please?

Thank you,
John

Installation Question

Hello

  1. I went to my blank website root and ran the composer command and installed the files
composer require abantecart/ups-php
  1. I created a new file in my root, upstest.php and added this content.
<?php
require __DIR__ . '/vendor/autoload.php';

$accNumber = '';
$clientId = '';
$password = '';

$config = \UPS\OAuthClientCredentials\Configuration::getDefaultConfiguration()
    ->setUsername($clientId)
    ->setPassword($password);

$apiInstance = new \UPS\OAuthClientCredentials\Request\DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
    new \GuzzleHttp\Client(),
    $config
);
$grant_type = "client_credentials"; // string |
$x_merchant_id = $accNumber; // string | Client merchant ID

try {
    $result = $apiInstance->createToken($grant_type, $x_merchant_id);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->generateToken: ', $e->getMessage(), PHP_EOL;
}

I keep getting the error:

Fatal error: Uncaught Error: Class "UPS\OAuthClientCredentials\Configuration" not found in /home/pelp/public_html/dadev/upstest.php:17 Stack trace: #0 {main} thrown in /home/pelp/public_html/dadev/upstest.php on line 7

Do you know what I am doing wrong?

Implement library for drupal commerce ups module

We should migrate to solution with newest API request.
https://www.drupal.org/project/commerce_ups/issues/3387353#comment-15337989

This library is great candidate to be incorporate for Drupal community.

From perspective of maintainer of this library, our need is to update from :
https://github.com/gabrielbull/php-ups-api
to:
https://github.com/abantecart/ups-php
Do have some experience what change are between?

This main folder is where we need your attention in this update (subfolder not needed):
https://git.drupalcode.org/project/commerce_ups/-/tree/8.x-3.x/src

Is this something that you can help to do as someone who know API?
As you see, there is only few places that need equivalent of API points to work and need only to be replaced as API keys and engine work on older implementation

Thank you for any help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.