Giter Site home page Giter Site logo

rest_api_v2_sdk_php's People

Contributors

perrytew avatar ucjonathan avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rest_api_v2_sdk_php's Issues

Set Second Shipping method as default one

Hi,

How I can set second shipping method as a default one or how I can change the shipping method in my code.

Code:

if ($cart->getSettings() != null && $cart->getSettings()->getShipping() != null) {
    $shippingSettings = $cart->getSettings()->getShipping();
    $estimates = $shippingSettings->getEstimates();
    if ($estimates != null && count($estimates) > 0) {
        $cart->getShipping()->setShippingMethod($estimates[0]->getName());
    }
}

How to add order in ultracard CRM using web API

Hi Perry,

Could you please guide me how I can insert orders in ultracart CRM using API? As I'm not getting the things in the doc. I just want to add order details and don't want credit card functionality in CRM using API.If you have any live example then please share with me that would be a great help for me to understand.

Regards,
kavita

Unable to filter out orders based on current_stage

Hello Perry,

Got one more issue.
We are unable to filter order based on current_stage parameter.
Below is the code which giving us empty array and we definitely have rejected orders in database.

 ///REGUALR ORDERS 
  $data["_expand"] = 'summary, payment, payment.transaction';
  $data["_limit"] = 200;
  $data["current_stage"] = "Rejected";
  $data["_sort"] = '-order_id';
 
  
  $uri = PATH.'/order/orders?'.http_build_query($data) ;
  $result = \Httpful\Request::get($uri)                  // Build a GET request...
  ->addHeader('X-UltraCart-Api-Version', API_VER) 
  ->addHeader('x-ultracart-simple-key',SIMPLE_KEY)
  ->addHeader('cache-control', 'no-cache') 
  ->send();  

Documentation for "$_expland"

I saw the following on a few places in code examples:

$_expand = "_expand_example"; // string | The object expansion to perform on the result. See documentation for examples

Can you tell me where to find documentation for examples because I wasn't able to find it (searched through your website, goggled, etc. but couldn't find it) and there's no link in the documentation.

P.S. Maybe is's something obvious but I wasn't aware of it.

How do add/link multiple orders for single customer in ultracart using checkout API.

Hi,

I have 3 upsell products and I would like to know how do I add them in the Ultracart backend using checkout API.
This is my main product: https://prnt.sc/j8yx5n

And after proceeding to buy this product, I have 3 more products which are coming 1 by 1 before checkout. Here is the screenshot of 1 of those upsell products: https://prnt.sc/j8yyz3

If customer proceeds to purchase the main product, he will get an option to add those upsell products one by one. And if the customer selects all/some of those upsell products. Those products will be added to cart along with the main product.

I would like to know how do I add/link those upsell products with the main product in ultracart?

Updating an Auto order

Hello Perry,

I have been trying to update an Auto order using this new API from last couple of days but haven't got much success. Below is the code and error we are receiving:

    $data["_expand"] = 'original_order,original_order.shipping'; 
    $uri = PATH.'/auto_order/auto_orders/'.$auto_order_oid.'?'.http_build_query($data);
    
    $result = \Httpful\Request::get($uri)                  // Build a GET request...
    ->addHeader('X-UltraCart-Api-Version', API_VER) 
    ->addHeader('x-ultracart-simple-key',SIMPLE_KEY)
    ->addHeader('cache-control', 'no-cache') 
    ->send();   
    
    $auto_order = $result->body->auto_order;
    $auto_order->original_order->shipping->first_name="New FirstName";
    
    $uri = PATH.'/auto_order/auto_orders/'.$auto_order_oid;
    
    $update_result = \Httpful\Request::put($uri)                  // Build a PUT request...
    ->sendsJson()
    ->body(json_encode($auto_order))
    ->addHeader('X-UltraCart-Api-Version', API_VER) 
    ->addHeader('x-ultracart-simple-key',SIMPLE_KEY)
    ->addHeader('cache-control', 'no-cache') 
    ->send();

Errors:
[developer_message] => Server side error. Please try your request again. If it continues to fail, contact UltraCart Support.
[user_message] => Server side error. Please try your request again. If it continues to fail, contact UltraCart Support.

Can you provide some examples to update quantity, frequency and next shipment date of an AutoOrder?

Thanks
Himanshu Saini.

PS: Is there any other better way to reach you? We have been planning to use this new API extensively and I don't want to create a new issue here for every hurdle we face.

FinalizeOrder stopped to return order details in case of success.

Hello Perry,

Sorry this issue do not belong here but I can't find place to report issue for older REST Checkout API.

We have a checkout implementation which has final step with call to rest/finalizeOrder and this worked good for more than a year but recently this finalizeOrder function stopped to give order details in success response. We have not altered code in last couple of months.

We reached Ultracart support team and they suggested us to check logs at Ultracart login and further informed us that we are sending wrong login credentials.

Upon checking logs at Ultracart login, found something strange that no matter what request data we send, input parameter 1 at logs is always same with same cart ID for all failed calls. See below image.
image
Result for all failed calls is: Invalid Login. Check your credentials and IP access."

I have changed my login password (in case it expired) and updated my code with same. I checked the IP address of server and whitelist at Ultracart. I am pretty sure I am sending correct credentials.

I can send you the request and response data if I can have a better communication channel to you than this.

Please look into this and update asap as its hurting our order workflow very badly.

Thanks & Regards,
Himanshu

`401 Unauthorized` response Error

I am getting following error.Please have a look and revert me ASAP:

Fatal error: Uncaught ultracart\v2\ApiException: [401] Client error: GET https://secure.ultracart.com/rest/v2/checkout/cart?_expand=checkout%2Citems resulted in a 401 Unauthorized response: {"error":{"developer_message":"Permission Denied.","user_message":"Permission Denied."},"metadata":{}} in /home/dsdevelo/public_html/demo/CRM/vendor/UltraCart/rest_api_v2_sdk_php/lib/api/CheckoutApi.php:728 Stack trace: #0 /home/dsdevelo/public_html/demo/CRM/vendor/UltraCart/rest_api_v2_sdk_php/lib/api/CheckoutApi.php(703): ultracart\v2\api\CheckoutApi->getCartWithHttpInfo('checkout,items') #1 /home/dsdevelo/public_html/demo/CRM/sync.php(52): ultracart\v2\api\CheckoutApi->getCart('checkout,items') #2 {main} thrown in /home/dsdevelo/public_html/demo/CRM/vendor/UltraCart/rest_api_v2_sdk_php/lib/api/CheckoutApi.php on line 728

Following is my code:

error_reporting(E_ALL);

// BEWARE: Almost every item here starts with 'Cart'. There are similar items
// with other APIs. Do not mistakenly use the other items.
// For example: CartItem vs. Item, CartItemOption vs. ItemOption. CartPaymentCreditCard vs. CustomerCard.

// initialization code
require_once './vendor/autoload.php';
// See https://github.com/UltraCart/hosted_fields for this file.
require_once('./hosted_fields/HostedFields.class.php');

// Configure API key authorization: ultraCartSimpleApiKey
$api_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
ultracart\v2\Configuration::getDefaultConfiguration()->setApiKey('x-ultracart-simple-key', $api_key);

$client = new GuzzleHttp\Client(['verify' => true, 'debug' => false]);
$config = ultracart\v2\Configuration::getDefaultConfiguration();
$headerSelector = new \ultracart\v2\HeaderSelector();

//$auto_order_api = new ultracart\v2\api\AutoOrderApi($client, $config, $headerSelector);

$checkout_api = new ultracart\v2\api\CheckoutApi();
echo "

";   print_r($checkout_api); echo "
"; die('Error Detect!');
// expansion should contain all the objects that will be needed throughout the checkout.
// see https://www.ultracart.com/api/#Topic3 for the complete list.
// This expansion list should be supplied for each get/put throughout or data may be lost on the return objects.
//$expansion = "billing,checkout,coupons,items,payment,settings.shipping.estimates,shipping,summary,taxes,coupons";

$expansion = "checkout,items";
// The expansion above doesn't include much of the item objects because they're not needed. For example, we don't
// need the item multimedia because we're not showing this cart to an end customer like a javascript implementation would

$get_response = $checkout_api->getCart($expansion);

if($get_response->getErrors() != null && count($get_response->getErrors()) > 0){
// handle errors here.
die('System error. Could not retrieve shopping cart.');
} else {
$cart = $get_response->getCart();
}

When to use Fulfillment API?

Hi,
Could you please tell me at what stage I need to use Fulfillment API? And could you please explain to me what does below line code means?

$fulfillment_shipment->setTrackingNumbers(['TrackingNo12345', 'TrackingNo67890']);

Tracking Number should be unique and how I'll pass the tracking number in above line code?

And Last, I want Web service(SOAP) as a TRANSMISSION MECHANISM for DISTRIBUTION CENTERS.

How to get order date in receipt email template

Hi Perry,

Could you please assist me regarding how I can get the order date in receipt email template? And from where I can change the $instructions variable value? And how I can create a new cancellation email template?

Regards,

Help create cart information then add payment, items

Hi. What I'm looking to do. A customer goes to this page and fills out the form on the right with Name, email, phone #, address. submit and then get sent to order page:
If they leave without completing the second page,I need to store the information they provided in first (shipping, billing info) without the order Item, payment info so I would like that info sent to Ultracart as a partial order.
in /order page they will add the payment and the selected package they want if they continue to second page
i used this ref to make the order but then i get error saying :
error Please add at least one item to your shopping cart before checkout.
i dont want to add the order item immediately i just want to fill the info (shipping, billing) then add the order item, payment to process the payment.
and i dont know how to add an item to cart ! is there any function that do that cart->setOrderItem()

Pulled the example from your api documentation and am getting errors

Here is the error:
PHP Fatal error: Call to undefined function ultracart\v2\models\mb_strlen()

Here is the code I pulled from the website:

$config = ultracart\v2\Configuration::getDefaultConfiguration()->setApiKey('x-ultracart-simple-key', $key);
$api = new ultracart\v2\api\CustomerApi(null, $config);
$offset = 0;
$limit = 200;

    $email = null;
    $qb_class = null;
    $quickbooks_code = null;
    $last_modified_dts_start = null;
    $last_modified_dts_end = null;
    $signup_dts_start = null;
    $signup_dts_end = null;
    $billing_first_name = null;
    $billing_last_name = null;
    $billing_company = null;
    $billing_city = null;
    $billing_state = null;
    $billing_postal_code = null;
    $billing_country_code = null;
    $billing_day_phone = null;
    $billing_evening_phone = null;
    $shipping_first_name = null;
    $shipping_last_name = null;
    $shipping_company = null;
    $shipping_city = null;
    $shipping_state = null;
    $shipping_postal_code = null;
    $shipping_country_code = null;
    $shipping_day_phone = null;
    $shipping_evening_phone = null;
    $pricing_tier_oid = null;
    $pricing_tier_name = null;
    $_limit = $limit;
    $_offset = $offset;
    $_since = null;
    $_sort = null;
    // $_expand = null; // no expansion.  bare bones.
    $_expand = "shipping,billing"; // shipping and billing addresses
    // $_expand = "shipping,billing,cards,pricing_tiers"; // everything.



    $get_response = $api->getCustomers($email, $qb_class, $quickbooks_code, $last_modified_dts_start, $last_modified_dts_end, $signup_dts_start, $signup_dts_end, $billing_first_name, $billing_last_name, $billing_company, $billing_city, $billing_state, $billing_postal_code, $billing_country_code, $billing_day_phone, $billing_evening_phone, $shipping_first_name, $shipping_last_name, $shipping_company, $shipping_city, $shipping_state, $shipping_postal_code, $shipping_country_code, $shipping_day_phone, $shipping_evening_phone, $pricing_tier_oid, $pricing_tier_name, $_limit, $_offset, $_since, $_sort, $_expand);
    if($get_response->getSuccess()){
        return $get_response->getCustomers();
    }

    return array();
}

This is my php version. If I need to upgrade, please let me know.

ArrayAccess Deprecations

I receive a lot of deprecation notices when running tests (using PHP 8.1).

All are similar to this:

Deprecated: Return type of ultracart\v2\models\CartItem::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Suppressing these deprecation notices is my typical course of action, however these do not seem to be affected by any attempt of preventing log channels, etc.

Is there anything I can do in my code locally to suppress these noisy messages?

Accessing API using another PHP client (Httpful)

Hello Perry,

Today we have started to test this new API and got one question:

As this is a REST API can we use http://phphttpclient.com/ as our client instead of swagger client?
I have tried calling https://secure.ultracart.com/rest/v2/auto_order/auto_orders with Httpful client with "x-ultracart-simple-key" query parameter and got permission denied message.

Further we ran into issue while fetching auto orders using swaggerClient. We called autoOrderAutoOrdersGet and passed email & _expand parameters.
We have received the auto orders for email that have been placed as Guest but auto orders that have been placed after logging in is not available.

Looking to hear from you on this.

Thanks
Himanshu Saini

Fatal error

Hey perry,

I'm getting Fatal Error. Please have a look.

Fatal error: Uncaught RuntimeException: GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler. in /xxx/xxxx/xxxxx/vendor/guzzlehttp/guzzle/src/functions.php:119 Stack trace: #0 /xxx/xxxx/xxxxx/vendor/guzzlehttp/guzzle/src/HandlerStack.php(40): GuzzleHttp\choose_handler() #1 /xxxx/xxxx/xxxxx/vendor/guzzlehttp/guzzle/src/Client.php(65): GuzzleHttp\HandlerStack::create() #2 /xxxx/xxxxx/xxxxx/sync_new.php(25): GuzzleHttp\Client->__construct(Array) #3 {main} thrown in /xxxx/xxxxx/xxxxx/vendor/guzzlehttp/guzzle/src/functions.php on line 119

Can't able to process order error return on store_cvv...

Hi Team,

I have configured Ultracart with new website. However, its not processing
orders and its asking for cvv2 number and breaks the operations.
Its working on our other website with the same merchant.
Here is the snippet of the code. Kindly check and let us know if there is
any issues. Also you can see the resulting error we are getting.

  // --- Payment Block ---
 $creditCardNumber = $_SESSION['cc_no'];
 $cvv = $_SESSION['cvv_no'];
 $_SESSION['coupon'] = $_POST['couponw3c'];
 $_SESSION['shipping_mehtod'] = $_POST['shipping_method_choose'];

 $_SESSION['hidden_shipping_charges'] = $_POST['shipping_price_val'];
 $_SESSION['hidden_total_charges'] = $_POST['tot'];
 $_SESSION['hidden_subtotal_charges'] = $_POST['subtot'];
 $payment = new \ultracart\v2\models\CartPayment();
 $creditCard = new \ultracart\v2\models\CartPaymentCreditCard();
 $store_cc_result = $hosted_fields->store_number($creditCardNumber);
 if ($store_cc_result->success) {
   // the server will tie the actual card number to the cart later, but the mask must be added
   $creditCard->setCardNumber($store_cc_result->maskedValue);
   $creditCard->setCardExpirationMonth($_SESSION['cc_exp_month']);
   $creditCard->setCardExpirationYear($_SESSION['cc_exp_yr']);
   $creditCard->setCardType($store_cc_result->cardType);
 }
 $store_cvv_result = $hosted_fields->store_cvv($cvv);
 if ($store_cvv_result->success) {
   // the server will tie the actual cvv to the cart later, but the mask must be added
   $creditCard->setCardVerificationNumber($store_cvv_result->maskedValue);
 }
 $payment->setPaymentMethod("Credit Card");
 $payment->setCreditCard($creditCard);
 $cart->setPayment($payment);
 // --- End Payment Block ---

At the time debugging, I am getting following result.

stdClass Object ( [success] => [errorMessage] => Invalid CVV2 number
provided for storage. )

Hence, can your developer guys check whats wrong in this?

Installed via composer on localhost working but moving it to live site generates errors

I Installed the PHP SDK via composer on my local computer it's working fine but when I move it on our live server it throws an error

atal error: Uncaught Error: Class 'ultracart\v2\Api\AutoorderApi' not found in /path_to_public_html/pingbackpixel/testapi.php:21 Stack trace: #0 {main} thrown in /path_to_public_html/pingbackpixel/testapi.php on line 21

I see the AutoOrderApi.php inside vendor/UltraCart/rest_api_v2_sdk_php/lib/api/AutoOrderApi.php

Website Speed get very slow

Hi,
I've noticed that my website speeds get slow when I use checkout API and we have but it has excellent internet speed. Could you please assist me regarding the same?

Regards,
kavita

Where are the custom fields located in the API?

Hi Perry,

I'm looking specifically for these 4 fields:

Custom Field 1
Custom Field 2
Mailing List
Country

I found country code, but not the country name (maybe not in there, which is fine).

I couldn't find a custom field object to reference so I'm stuck there. Otherwise, I've found the other 23 fields from their objects/arrays and it seems to be working fine.

Thanks again for your help!

-Bryant

Custom add-to-cart logic and "handoff" to the UltraCart's cart page

Hello,

I'm trying to develop a custom PHP solution for the add-to-cart for my client's website and I managed to use API to add items to the cart. However, I don't know how to "transfer" user from our website to the UltraCart's cart page (if that's even possible - not the checkout, but to the cart page because there's some additional information for the user that they can pick before they continue to the checkout).

I found this example, but I get the following error:
"Exception when calling CheckoutApi->handoffCart: [400] Client error: POST https://secure.ultracart.com/rest/v2/checkout/cart/handoff resulted in a 400 Bad Request response: Server side object 'cart' could not be constructed from the json you provided."

So, 2 things:

  1. Is this the method that I should use - or this method is just for the checkout handoff
  2. is there something else that I should do in order to prepare the data for this method (I assume that I need to add cart_id somehow, maybe even some other info)

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.