Giter Club home page Giter Club logo

shopify-api-php's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shopify-api-php's Issues

Could not find the current session id in the cookies

Issue summary

I get error when OAuth callback

Here is my code

OAuth::callback($cookies, $query, function (OAuthCookie $cookie) {
            setcookie(
                $cookie->getName(),
                $cookie->getValue(),
                $cookie->getExpire(),
                '',
                '',
                $cookie->isSecure(),
                $cookie->isHttpOnly()
            );
            return true;
        });

I get this error:

Shopify\Exception\CookieNotFoundException
Could not find the current session id in the cookies

Callback fetchAccessToken problem

Issue summary

Fatal error: Uncaught TypeError: Return value of Shopify\Clients\HttpClientFactory::client() must be an instance of Psr\Http\Client\ClientInterface, instance of GuzzleHttp\Client returned in

This happen in callback method when try to fetchAccessToken, any clue why this happen ?

Return created/updated objects

Overview

The API itself will already return the full object if you do a create/update operation. However, the library swallows this response here:
https://github.com/Shopify/shopify-php-api/blob/0556edf274ceb83346533bd22b662d7622e58c66/src/Rest/Base.php#L60-L74

Solution

Adding return $response->getDecodedBody(); at the end of the function should suffice. Note that the saveAndUpdate function would also need to be updated, with return $this->save(true);. Implementation can be found in my fork: MagicLegend@d43bc94

Type

  • New feature
  • Changes to existing features

Motivation

What inspired this feature request? What problems were you facing?

I would like to verify the saved object myself, without needing to query the API again for data that was already returned in the first place. This also allows immediate access to the ID of the newly created object.

Webhook remove

Overview/summary

Is there a way to remove created webhook? Now I can only register, but not to remove.

Motivation

There are cases when you need to remove registered webhooks

Area

  • Webhooks

Checklist

  • I have described this enhancement in a way that is actionable (if possible)

How to initialise client

Hi

Please clearify in instruction how to start using the library.

for example after autload? how to start using it.

Regards

Laravel 9

Will there be support for Laravel 9? Getting this message on installation
osiset/laravel-shopify[v17.1.0, ..., 17.1.x-dev] require laravel/framework ^7.0 || ^8.0 -> found laravel/framework[v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but it conflicts with your root composer.json require (^9.2).

HTTPClientFactory Not being setup correctly

Issue summary

Error thrown: Call to a member function client() on null in /var/www/vendor/shopify/shopify-api/src/Clients/Http.php on line 164

Expected behavior

$client = Context::$HTTP_CLIENT_FACTORY->client(); Should be returning a working Guzzle client however it isnt. Apologies it's late here but Context::initialize() is never called as far as I can see and so $HTTP_CLIENT_FACTORY is never populated with the Guzzle client that is relied on.

Steps to reproduce the problem

  1. Run composer for version 1.0.0
  2. Make a very basic call like new \Shopify\Clients\Rest($url, $accessToken)->get('orders');

Getting error to process webhook

When i called following code (process method):
$registry = new Registry();
$response = $registry->process($request->headers->toArray(), $request->getRawBody());

Getting following error:
Call to undefined method Symfony\Component\HttpFoundation\HeaderBag::toArray()

Note: Laravel Framework 8.83.2

any solution?

Using inventoryBulkAdjustQuantityAtLocation does not work although no error is thrown

I get a [statusCode:GuzzleHttp\Psr7\Response:private] => 200 in the response.
So it seems to work but it does not reflect in updated inventory. :(

Checking at /admin/products/inventory?location_id=62241177806&query=F11_27781195 does not show the new inventory.

I am using the inventoryid correctly (not product or variantid).

 $inventoryItemAdjustments = array();
 
 $inventoryItemAdjustments[] = (object)[
   'inventoryItemId' => 'gid://shopify/InventoryItem/43151435235534',
   'availableDelta' => 500
 ];
 $inventoryItemAdjustments[] = (object)[
   'inventoryItemId' => 'gid://shopify/InventoryItem/43151435268302',
   'availableDelta' => 500
 ];

 $variables = array(
   'locationId' => ConfigClass::$locationId,
   'inventoryItemAdjustments' => $inventoryItemAdjustments
 );

$graphqlquery='mutation inventoryBulkAdjustQuantityAtLocation($inventoryItemAdjustments: [InventoryAdjustItemInput!]!, $locationId: ID!) 
    {inventoryBulkAdjustQuantityAtLocation(inventoryItemAdjustments: $inventoryItemAdjustments, locationId: $locationId) {userErrors { field message }}}';

$response = $client->query(['query' => $graphqlquery, 'variables' => $variables]); 
print_r($response);

Deleting a product works (and is a good test if the library is initialized well):

$query = <<<QUERY
  mutation {
    productDelete(input: {id: "gid://shopify/Product/6975310463182"})
    {
      deletedProductId
    }
  }
QUERY;
$response = $client->query(["query" => $query]); 
print_r($response);

Admin API : Rest Client : Not able to use it

Overview/summary

The documents on how to use the rest client is very poor. You'll get in a endless void of non documented specification:

  • Use the Shopify\Clients\Rest, this needs the shop domain and a authorization token, not described on page where they should come from
  • Looking that up, it might be in the session says the documentation. Nowhere is mentioned how the session is inserted (can't inject it for missing values, so need to call it static) and from what class. See https://github.com/Shopify/shopify-api-php/blob/main/docs/usage/rest.md. Why aren't these described on the rest api page? We need to have all the info needed to start and run the rest client on the same page.
  • Looking into Session.. Described in OAuth class (had to google a bit for that). Apparently it's stored in Context::$SESSION_STORAGE as stated https://github.com/Shopify/shopify-api-php/blob/main/docs/usage/oauth.md . So let's continue to yet another page.
  • There is also some vars stored in de db session storage. This needs a sessionId? So, where's that then? Ah i see, never is this function even used... Had me there for a second
  • Where do i need this? In a command... You can guess whats coming next, right? All these values aren't filled, since we are running a separate session.

How can i use this Rest client in laravel? Can someone provide the proper and full infromation on how to use the client in a controller and a command?

Add PHP 7.2 Support

We've been using another package for our apps. That package is going to be achieved soon. As our apps are using PHP 7.2, this is our request to you to add PHP 7.2 support as well so we can use this package.

Thanks!

Add (better) PHPDocs in the project

Overview/summary

The project could really do with some better documentation in general, although this ticket is more aimed at PHPDocs for functions. There are a lot of undocumented functions, that could do with a quick one-line explanation of what it's doing. For example, the src/Rest/Base.php file has no useful documentation at all, and not all functions even have the auto-generated function docs.

The library could really use some love!

Motivation

What inspired this enhancement?

The (in-code) documentation is severely lacking in some places.

Loosen Guzzlehttp requirement to allow v6

Overview/summary

I'd like to see the requirement for guzzle/guzzlehttp loosened to also allow v6, instead of ^7.0. I have forked the project, and downgraded the package. All tests still succeed, so I'm assuming v6 is fully compatible with this package as well.

I also have loosened doctrine/inflector to allow v1, which also doesn't break the tests. This is a deeper dependency to two Magento packages as well.

Motivation

Magento v2.4.3 uses Guzzlehttp v6, and upgrading Magento is simply not an option. In our case:

$ composer2 why guzzlehttp/guzzle
magento/ece-tools                                  2002.1.10   requires  guzzlehttp/guzzle (^6.3||^7.3)
magento/framework                                  103.0.3-p1  requires  guzzlehttp/guzzle (^6.3.3)
magento/module-catalog-sync-admin                  1.0.4       requires  guzzlehttp/guzzle (~6.0)
magento/module-product-recommendations-admin       3.0.4       requires  guzzlehttp/guzzle (~6.0)
magento/module-product-recommendations-sync-admin  1.0.1       requires  guzzlehttp/guzzle (~6.0)
magento/product-community-edition                  2.4.3-p1    requires  guzzlehttp/guzzle (^6.3.3)                                                                                                                                                        
magento/product-enterprise-edition                 2.4.3-p1    requires  guzzlehttp/guzzle (^6.3.3)        
magento/product-recommendations-admin              3.0.5       requires  guzzlehttp/guzzle (~6.0)
magento/services-connector                         1.2.0       requires  guzzlehttp/guzzle (6.*)
$ composer2 why doctrine/inflector
illuminate/support  v5.8.36  requires  doctrine/inflector (^1.1)
$ composer2 why illuminate/support
illuminate/config  v5.8.36  requires  illuminate/support (5.8.*)  
$ composer2 why illuminate/config
magento/ece-tools             2002.1.10  requires  illuminate/config (^5.5||^8.77)
magento/magento-cloud-docker  1.3.2      requires  illuminate/config (^5.5||^8.77)

Would be great if it'd be allowed to use both packages with a lower version for better compatability.

Improve "Private App" API usage

Overview/summary

Currently using this library when connecting to a private app is confusing.

It takes quite a long time to work out what you are doing, when it feels like it could be really simple.

Motivation

In our usecase, we only want to consume the Shopify admin api via REST, with a private app access token.

Currently to do that you have to have the following code:

Context::initialize(
  'xxx',                                          // Not used
  'yyy',                                          // Not used
  'read_orders, write_orders',                    // Not used
  'http://localhost',                             // Not used
  new FileSessionStorage('/tmp/php_sessions'),    // Not used
  'latest',
  false,                                          // Not used
  false,                                          // Needs to (incorrectly) be set to false
);

$rest = new Rest($domain, $storeApiToken);

This is not helped by the fact that there is a bug on this line:

https://github.com/Shopify/shopify-php-api/blob/main/src/Clients/Rest.php#L46

So you actually have to Context::initialize with "privateApp" to to false, so it uses the access token not the secret key.

       $headers[HttpHeaders::X_SHOPIFY_ACCESS_TOKEN] =
            Context::$IS_PRIVATE_APP ? Context::$API_SECRET_KEY : $this->accessToken;

There is barely any point in having to call Context::initialize, the only reason for doing it is to:

  • Set Context::$IS_INITIALIZED (to prevent an exception)
  • Default Context::$HTTP_CLIENT_FACTORY = new HttpClientFactory();

In an ideal situation I would just need to do this:

$rest = new Rest($domain, $storeApiToken);

Possible Improvements

  • Remove the need to call Context::initialize
  • Default the API version to 'unstable'
  • Default the initialization of $HTTP_CLIENT_FACTORY if null
  • Don't throw an exception during log if not initialized

Happy to contribute these changes, if you are welcome to receive them.

PHP 8

Overview/summary

Please add php 8 support as the package cannot be used with the laravel 8 and psr 2.0

How to upgrade version to 3.0.0

Issue summary

run command: composer require shopify/shopify-api:3.0.0, error:

Expected behavior

Actual behavior

image

Steps to reproduce the problem

  1. composer require shopify/shopify-api:3.0.0, report an error.
  2. composer require guzzlehttp/guzzle:7.4.5, successful installation.
  3. composer require shopify/shopify-api:3.0.0, same error.

How to run non embeded app

I am trying to setup non embedded app with the help shopify cli3 using php template.
I have disabled embedded app from the shopify section but app still not working as non embedded. Please help what change we need to do at script level under the laravel.

Abuse of `catch` statement

Overview/summary

} catch (Exception $error) {

This catch statement is inappropriate for the following reasons:

  • The Exception object is been discarded because of the $error->getMessage(), the exception object has useful information which is not even accessible.
  • It creates extremely unpredictable behaviour for this library. Most developers would expect "unhandled" exceptions to be handled by their default exception handler which might logs error or alert the developer of the exception in other ways. But this catch statement is bypassing all of that.
  • Furthermore, if the Webhook handler did throw an exception and this library was not "hijacking" the exception int the way it is, then this would usually result in a http 500 error anyway, which is still a desirable outcome. The failed webhook would still return a non 200 level response which is the appropriate behaviour of a failed response.
  • The way this catch statement is coded is not consistent with how most of PHP Library and frameworks would behave. I don't think this is coded in accordance with any credible PHP coding guideline.

App Bridge 2.o

I want to add app bridge 2.0 to my App . Currently I am using PHP for public app. Is there any way to do so ?

Missing optional paramater in graphqlProxy method.

As shown below the graphqlProxy method does not accept access mode as a parameter and there is no way to pass it.

    public static function graphqlProxy(array $rawHeaders, array $cookies, string $rawBody): HttpResponse
    {
        $session = self::loadCurrentSession($rawHeaders, $cookies, true);
        if (!$session) {
            throw new SessionNotFoundException("Could not find session for GraphQL proxy");
        }

        $client = new Graphql($session->getShop(), $session->getAccessToken());

        return $client->proxy($rawBody);
    }

Discount Code Lookup - Request fails due to Error handling on expected 303 status header

Issue summary

Discount code lookup fails due to error handling on redirect.

API returns 303 redirect code, which is handled in the Base.php as error, yet this is expected behavior:

https://shopify.dev/api/admin-rest/2022-07/resources/discountcode#get-discount-codes-lookup?code=SUMMERSALE10OFF

This is due to checking for error code above 300 in the request method of Base.php

https://github.com/Shopify/shopify-api-php/blob/main/src/Rest/Base.php#L189

Expected behavior

Follow redirect or return headers to read pricelist and discount code id.

Actual behavior

DiscountCode::lookup($session, [], ["code" => "SUMMERSALE10OFF"]);

throws RestResourceRequestException.

Steps to reproduce the problem

Request valid Discount code:

DiscountCode::lookup($session, [], ["code" => "SUMMERSALE10OFF"]);

Reduced test case

Create discount code and try to look it up:

use Shopify\Rest\Admin2022_07\DiscountCode;
use Shopify\Utils;
$this->test_session = Utils::loadCurrentSession(
    $requestHeaders,
    $requestCookies,
    $isOnline
);
DiscountCode::lookup(
    $this->test_session, // Session
    [], // Url Ids
    ["code" => "SUMMERSALE10OFF"], // Params
);

This will result in a RestResourceRequestException Exception being thrown.

[PHP 8.2] Issue with dynamic properties

Hi,

As of today, the library dynamically create class properties, such as here.

This has been deprecated in PHP 8.2. Current version therefore lead to warning errors.

Thanks :)

Does the library support Basic Auth?

Overview/summary

Do you support Basic HTTP Auth for a Private App?

Motivation

Building a private app with apiKey + secret should be secure enough.

What inspired this enhancement?
OAuth not needed for private apps, IMHO

Area

Auth

Checklist

  • I have described this enhancement in a way that is actionable (if possible)

strict_types declared but usleep() receives a float

Issue summary

Shopify returns Retry-After header as a float. So when we run usleep($retryAfter * 1000000); on Clients/Http.php Line 204 it throws a TypeError Exception as seen here:

TypeError: usleep(): Argument #1 ($microseconds) must be of type int, float given in /home/user/project/vendor/shopify/shopify-api/src/Clients/Http.php:204

Expected behavior

Instead of throw an exception it should work and delays the program's execution for given microseconds.

Actual behavior

What actually happens?

Throws a TypeError Exception as seen here:

TypeError: usleep(): Argument #1 ($microseconds) must be of type int, float given in /home/user/project/vendor/shopify/shopify-api/src/Clients/Http.php:204

Steps to reproduce the problem

  1. Throttle the api above your rate limit and you will encounter with TypeError Exception.

Checklist

  • I have described this issue in a way that is actionable (if possible)

Don't write API deprecations to a file

It appears that if an API deprecation occurs, the SDK attempts to write this deprecation to a file named .last_api_deprecation_warning. This happens in the Http class and does not seem to be configurable behavior.

In our case, we (as most container-based environments) prevent write access to an application's directories except for a few selected ones, and /vendor definitely isn't one of them for obvious reasons. The file_put_contents call unfortunately doesn't have any error handling so a deprecation is now causing exceptions that then trigger our monitoring.

Would it be possible to remove this logic? If I'm being totally honest I don't see the need to write anything directly to a file; that's what libraries such as Monolog or another PSR-compliant library are meant for.

PHP 8.1 currently broken

Issue summary

This library currently doesn't work on PHP 8.1

Expected behavior

A TypeError should not be thrown

Actual behavior

The setcookie signature is invalid and is throwing a TypeError

What actually happens?

This TypeError is thrown:
setcookie(): Argument #3 ($expires_or_options) must be of type array|int, null given

Steps to reproduce the problem

  1. Run ShopifyOAuth::callback()

Source of problem

It's this that causes the problem:

$cookieSet = setcookie( $signatureCookie->getName(), $signatureCookie->getValue(), $signatureCookie->getExpire(), "", "", $signatureCookie->isSecure(), $signatureCookie->isHttpOnly(), );

And it's when there is no expiry time set on the session, which is the case for offline access.

How to fix

Change this line:
$sessionExpiration = ($session->getExpires() ? (int)$session->getExpires()->format('U') : null);

To:
$sessionExpiration = ($session->getExpires() ? (int)$session->getExpires()->format('U') : 0);

I can submit a pull request if that's helpful :)

How does one connect a private app?

I wanted to test this package for my laravel app and i am very confused on how to define my private app. Which fields do i need? Because the fields in a private app are different from a public app. For example i don't need to get my session etc. because i only want to write products to my store from my Laravel app.

Thanks in advance.

How to send cookies in callback?

Hi

I have authorized the app and its install but when going on the callback step written send cookies and query
BUT we have not set any cookies then which cookies array need to send in this function.

Shopify\Auth\OAuth::callback
in this callback function which cookies array hash need to send anyone to explain a little bit.

Looking forward to support Payments Apps API reference?

Currently, API calls are fixed and cannot be customized, using different API paths.

GraphQL endpoint
The Payments Apps API is available at a single GraphQL endpoint:

POST https://{shop_domain}/payments_apps/api/2021-10/graphql.json

Please check the screenshot.
iShot2021-12-06 18 18 10

All requests should have the option to pass $tries

Overview/summary

Currently the abstract API calls will not handle rate limiting because $tries is not passed on here:

switch ($httpMethod) {
case "get":
$response = $client->get($path, [], $params);
break;
case "post":
$response = $client->post($path, $body, [], $params);
break;
case "put":
$response = $client->put($path, $body, [], $params);
break;
case "delete":
$response = $client->delete($path, [], $params);
break;
}

Thus $maxTries will default to 1:

$maxTries = $tries ?? 1;

Motivation

We ran into rate limiting issues that weren't handled by the library.

Possible solution

In Base.php it should take apart the $params array and take out a tries value from there, to pass it on to the appropriate function. Another solution would be to simply add an optional parameter up the chain, but that would involve changing every function in this library.


Checklist

  • I have described this enhancement in a way that is actionable (if possible)

Cookie duration for offline access token

Issue summary

I see cookie set for 1 minute for both access token (online/offline). For offline access token, token is permanent, but cookie expired after 1 minute. Here I see Utility function to load current session with headers and cookie. My app not embedded and If I try to access current access token, there is no cookie after 1 minute.

Can you please explain how I can get access token without re-authenticate after 1 minute. I know I can get access token by shop but then why this utility function ?

Expected behavior

I think For offline access token, We can set cookie permanent. Is there any issue if we make cookie permanent ?

I am not expert but This is my opinion. It may be wrong.

Thank you

Need Better Examples

Why provide the Cookies example using YII? Can you add framework-less examples? Any way to add all the code examples necessary to run everything on the main readme file like other shopify api plugins? Needs to be even more clear and easy for beginners and even intermediates to not waste time trying to figure it out.

Enable trial period billing using trialDays parameter in EnsureBilling class

Overview

The Shopify PHP app template already supports, using the EnsureBilling class, the management of some Billing APIs mutations.
Since the underlying billing mutations already support the usage of "trialDays" parameter to enable a trial period of the app (https://shopify.dev/apps/billing/purchase-adjustments/free-trials), I would like to be able to define its value in the shopify.php config file and use it through the EnsureBilling functions as we can do for all the other billing parameters.

Type

  • New feature
  • Changes to existing features

Motivation

The EnsureBilling class enables setting up easily the Shopify app billing using middleware.
Since the billing API mutations used by EnsureBilling's functions already support for the trial period using the "trialDays" parameter, it would be convenient to be able to use all the mutations' native options also through EnsureBilling's functions which wrap them.

...

Area

  • Billing

Checklist

  • Add "trialDays" parameter to shopify.php config file example
  • Edit requestRecurringPayment and requestOneTimePayment functions to use and support the new trialDays parameter
  • Edit RECURRING_PURCHASE_MUTATION and ONE_TIME_PURCHASE_MUTATION to support the new trialDays parameter

How to use ShopifyQL with Public App?

Hi
Using this package is it possible to query this SHOW sum(pageview_count) OVER month(timestamp) AS month statement?
If yes then how we can execute it programmatically?

Currently, I'm using this package: https://github.com/osiset/laravel-shopify, and using that package I'm trying like this way, But it throwing the error.

Example Code:

$response = $shop->api()->graph("SHOW sum(pageview_count) OVER month(timestamp) AS month");
dd($response);
Error: https://prnt.sc/2005osy

Can anyone help me with this?
Thank you.

FulfillmentEvent Can't Save for update

Issue summary

When creating a fulfillmentEvent, the return exception does not exist index 'event'

Expected behavior

It should return me the normal response as described in the documentation https://shopify.dev/api/admin-rest/2022-10/resources/fulfillmentevent#post-orders-order-id-fulfillments-fulfillment-id-events

Actual behavior

What actually happens?

it return exception does not exist index 'event'

After printing in the source code of the composer package, I found that the index in the returned result is 'fulfillment_event'
image
and the rewritten jsonBodyName of the fufillment is event, so this error occurs. I hope it can be fixed as soon as possible.
image
image

#225 (comment)

"psr/log": "^1.1",

Issue summary

Can you remove or update requirements of "psr/log": "^1.1", ?
current psr/log version is 3!

Implement a "RestResourceRequestJsonException" that extends ShopifyException to catch JsonException(s)

Overview

This library should implement a "RestResourceRequestJsonException" that extends ShopifyException, to be thrown when a malformed JSON response is returned by Shopify (yes, it happens).

This would allow for the raw response to be logged, alongside X-Request-ID, so that this can be reported and hopefully fixed.

Type

  • New feature

Motivation

What inspired this feature request? What problems were you facing?

At times Shopify returns JSON data that causes json_decode() to throw a JsonException.

Error When Trying To Fetch Webhooks List

Issue summary

Error when trying to fetch current webhooks.

Expected behavior

It should have returned a JSON response containing a list of webhooks

Actual behavior

we get this error:

Fatal error: Uncaught TypeError: Argument 1 passed to Shopify\Utils::loadCurrentSession() must be of the type array, null given, called in /www/doc/www.example.com/www/script/index.php on line 45 and defined in /www/doc/www.example.com/www/script/vendor/shopify/shopify-api/src/Utils.php:158 Stack trace: #0 /www/doc/www.example.com/www/script/index.php(45): Shopify\Utils::loadCurrentSession(NULL, NULL, NULL) #1 {main} thrown in /www/doc/www.example.com/www/script/vendor/shopify/shopify-api/src/Utils.php on line 158

Steps to reproduce the problem

  1. Include the library:
require("vendor/autoload.php");

use Shopify\Auth\FileSessionStorage;
use Shopify\Auth\Session;
use Shopify\Rest\Admin2022_10\Customer;
use Shopify\Rest\Admin2022_10\Webhookv2;
use Shopify\Utils;
  1. Initialize:
Shopify\Context::initialize(
    'apiKey',
    'apiSecretKey',
    'read_analytics, read_assigned_fulfillment_orders, read_customers, read_draft_orders, read_merchant_managed_fulfillment_orders, read_order_edits, read_orders, read_script_tags, read_third_party_fulfillment_orders',
    'https://sozialstar.de/script/',
    new FileSessionStorage('/tmp/php_sessions'),
    '2022-10',
);
  1. Request webhook list:
$this->test_session = Utils::loadCurrentSession(
    $requestHeaders,
    $requestCookies,
    $isOnline
);
Webhookv2::webhooks(
    $this->test_session, // Session
    [], // Url Ids
    [], // Params
);

composer conflicts with other packages

I tried to install shopify api in my yii2 project using
composer require shopify/shopify-api --with-all-dependencies

but its conflicting with other packages and geeting error like:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - fedemotta/yii2-aws-sdk is locked to version v2.0 and an update of this package was not requested.
    - Root composer.json requires shopify/shopify-api ^3.0 -> satisfiable by shopify/shopify-api[v3.0.0].
    - kushy/metrc-php-sdk is locked to version dev-master and an update of this package was not requested.
    - Conclusion: install guzzlehttp/guzzle 7.4.5 (conflict analysis result)
    - You can only install one version of a package, so only one of these can be installed: guzzlehttp/guzzle[5.3.0, ..., 5.3.4, 6.0.0, ..., 6.5.8, 7.0.0, ..., 7.4.5].
    - Conclusion: don't install guzzlehttp/guzzle[7.4.5] | install guzzlehttp/guzzle[6.5.4] (conflict analysis result)


Installation failed, reverting ./composer.json and ./composer.lock to their original content.

so please any help with this?

Can you please add example projects vanila php, codeigniter & laravel?

I'm trying to integrate the api with Codeigniter. While initializing, I'm stuck on SHOPIFY_APP_HOST_NAME and session.
I don't know what is the shopify app host name and where can I get it?
what is the session file or path I should use as I'm using Codeigniter?

Context::initialize(
$_ENV['SHOPIFY_API_KEY'],
$_ENV['SHOPIFY_API_SECRET'],
$_ENV['SHOPIFY_APP_SCOPES'],
$_ENV['SHOPIFY_APP_HOST_NAME'], // what is the shopify app host name? where can I get it?
new FileSessionStorage('/tmp/php_sessions'), // what is the session file or path I should use here?
'2021-04',
true,
false,
);

Is it possible you create example projects for vanila PHP, Codeigniter & Laravel so that developers like me can work on the shopify api.

Shopify\Auth\OAuth::begin issue

Hi there , on calling this "begin" function it return with authorization url
but if can check in query parameter
$query = [
'client_id' => Context::$API_KEY,
'scope' => Context::$SCOPES->toString(),
'redirect_uri' => Context::$HOST_SCHEME . '://' . Context::$HOST_NAME . $redirectPath,
'state' => $session->getState(),
'grant_options[]' => $grantOptions,
];
why we are writing Context::$HOST_NAME in redirect uri?

How to enable debug logging?

Overview

We attached a LoggerInterface to Context but couldn't find how can we enable debug logging so package logs every operation it made. Because even We checked and enabled retries for some requests and they resulted with success responses, some properties of result payload we try to read is throws undefined index exception. We want to log everything with request payloads and responses to take a full look to process.
...

Type

  • New feature
  • Changes to existing features

Motivation

What inspired this feature request? What problems were you facing?

Even We checked and enabled retries for some requests and they resulted with success responses, some properties of result payload we try to read is throws undefined index exception. We want to log everything with request payloads and responses to take a full look to process.
...

Is it possible to allow v2.* for psr/log ?

Overview/summary

Required version of psr/log can be updated so it won't be a conflict with other packages which uses a newer version of psr/log

Motivation

What inspired this enhancement?

When I tried to install this package on a Laravel 8 project, composer couldn't install it because my project uses psr/log 2.^
I downgraded psr/log version on my project since most of packages depends on it also accepts version 1.*

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.