Skip to content

Commit d351c39

Browse files
author
Tyler King
authored
* Some ITP code to test on live server * Added log * Completed ITP flow for testing * Cleanup of code for ITP. Removed unneeded config service and config trait. Moved config to a helper function * Cleanup for StyleCI * Modified Blade to access new helper for config * Fix to test suite to include ITP cookies for calls * Completed test suite for new ITP * Fix for styleCI
1 parent 60a7da4 commit d351c39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+880
-350
lines changed

src/ShopifyApp/Actions/AfterAuthorize.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
66
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
77
use Osiset\ShopifyApp\Contracts\ShopModel as IShopModel;
8-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
8+
use function Osiset\ShopifyApp\getShopifyConfig;
99

1010
/**
1111
* Run after authentication jobs.
1212
*/
1313
class AfterAuthorize
1414
{
15-
use ConfigAccessible;
16-
1715
/**
1816
* Querier for shops.
1917
*
@@ -59,7 +57,7 @@ public function __invoke(ShopIdValue $shopId): bool
5957
} else {
6058
// Run later
6159
$job::dispatch($shop)
62-
->onQueue($this->getConfig('job_queues')['after_authenticate']);
60+
->onQueue(getShopifyConfig('job_queues')['after_authenticate']);
6361
}
6462

6563
return true;
@@ -69,7 +67,7 @@ public function __invoke(ShopIdValue $shopId): bool
6967
$shop = $this->shopQuery->getById($shopId);
7068

7169
// Grab the jobs config
72-
$jobsConfig = $this->getConfig('after_authenticate_job');
70+
$jobsConfig = getShopifyConfig('after_authenticate_job');
7371

7472
if (isset($jobsConfig[0])) {
7573
// We have multi-jobs

src/ShopifyApp/Actions/AuthorizeShop.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44

55
use Osiset\ShopifyApp\Contracts\Commands\Shop as IShopCommand;
66
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
7+
use function Osiset\ShopifyApp\getShopifyConfig;
78
use Osiset\ShopifyApp\Objects\Enums\AuthMode;
89
use Osiset\ShopifyApp\Objects\Values\NullAccessToken;
910
use Osiset\ShopifyApp\Objects\Values\ShopDomain;
1011
use Osiset\ShopifyApp\Services\ShopSession;
11-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
1212
use stdClass;
1313

1414
/**
1515
* Authenticates a shop via HTTP request.
1616
*/
1717
class AuthorizeShop
1818
{
19-
use ConfigAccessible;
20-
2119
/**
2220
* Querier for shops.
2321
*
@@ -86,10 +84,10 @@ public function __invoke(ShopDomain $shopDomain, ?string $code): stdClass
8684

8785
// Access/grant mode
8886
$grantMode = $shop->hasOfflineAccess() ?
89-
AuthMode::fromNative($this->getConfig('api_grant_mode', $shop)) :
87+
AuthMode::fromNative(getShopifyConfig('api_grant_mode', $shop)) :
9088
AuthMode::OFFLINE();
9189

92-
$return['url'] = $apiHelper->buildAuthUrl($grantMode, $this->getConfig('api_scopes', $shop));
90+
$return['url'] = $apiHelper->buildAuthUrl($grantMode, getShopifyConfig('api_scopes', $shop));
9391

9492
// If there's no code
9593
if (empty($code)) {

src/ShopifyApp/Actions/CreateScripts.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
use Osiset\BasicShopifyAPI\ResponseAccess;
66
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
77
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
8-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
98

109
/**
1110
* Create scripttags for this app on the shop.
1211
*/
1312
class CreateScripts
1413
{
15-
use ConfigAccessible;
16-
1714
/**
1815
* Querier for shops.
1916
*

src/ShopifyApp/Actions/CreateWebhooks.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
use Osiset\BasicShopifyAPI\ResponseAccess;
66
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
77
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
8-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
98

109
/**
1110
* Create webhooks for this app on the shop.
1211
*/
1312
class CreateWebhooks
1413
{
15-
use ConfigAccessible;
16-
1714
/**
1815
* Querier for shops.
1916
*

src/ShopifyApp/Actions/DispatchScripts.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44

55
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
66
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
7-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
7+
use function Osiset\ShopifyApp\getShopifyConfig;
88

99
/**
1010
* Attempt to install script tags on a shop.
1111
*/
1212
class DispatchScripts
1313
{
14-
use ConfigAccessible;
15-
1614
/**
1715
* Querier for shops.
1816
*
@@ -55,7 +53,7 @@ public function __invoke(ShopIdValue $shopId, bool $inline = false): bool
5553
$shop = $this->shopQuery->getById($shopId);
5654

5755
// Get the scripttags
58-
$scripttags = $this->getConfig('scripttags');
56+
$scripttags = getShopifyConfig('scripttags');
5957
if (count($scripttags) === 0) {
6058
// Nothing to do
6159
return false;
@@ -71,7 +69,7 @@ public function __invoke(ShopIdValue $shopId, bool $inline = false): bool
7169
($this->jobClass)::dispatch(
7270
$shop->getId(),
7371
$scripttags
74-
)->onQueue($this->getConfig('job_queues')['scripttags']);
72+
)->onQueue(getShopifyConfig('job_queues')['scripttags']);
7573
}
7674

7775
return true;

src/ShopifyApp/Actions/DispatchWebhooks.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44

55
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
66
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
7-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
7+
use function Osiset\ShopifyApp\getShopifyConfig;
88

99
/**
1010
* Attempt to install webhooks on a shop.
1111
*/
1212
class DispatchWebhooks
1313
{
14-
use ConfigAccessible;
15-
1614
/**
1715
* Querier for shops.
1816
*
@@ -55,7 +53,7 @@ public function __invoke(ShopIdValue $shopId, bool $inline = false): bool
5553
$shop = $this->shopQuery->getById($shopId);
5654

5755
// Get the webhooks
58-
$webhooks = $this->getConfig('webhooks');
56+
$webhooks = getShopifyConfig('webhooks');
5957
if (count($webhooks) === 0) {
6058
// Nothing to do
6159
return false;
@@ -71,7 +69,7 @@ public function __invoke(ShopIdValue $shopId, bool $inline = false): bool
7169
($this->jobClass)::dispatch(
7270
$shop->getId(),
7371
$webhooks
74-
)->onQueue($this->getConfig('job_queues')['webhooks']);
72+
)->onQueue(getShopifyConfig('job_queues')['webhooks']);
7573
}
7674

7775
return true;

src/ShopifyApp/Exceptions/BaseException.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
namespace Osiset\ShopifyApp\Exceptions;
44

55
use Exception;
6-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
76

87
/**
98
* Base exception for all exceptions of the package.
109
* Mainly to handle render in production.
1110
*/
1211
abstract class BaseException extends Exception
1312
{
14-
use ConfigAccessible;
1513
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Osiset\ShopifyApp\Http\Controllers;
4+
5+
use Illuminate\Routing\Controller;
6+
use Osiset\ShopifyApp\Traits\ItpController as ItpControllerTrait;
7+
8+
/**
9+
* Responsible for handling ITP issues.
10+
*/
11+
class ItpController extends Controller
12+
{
13+
use ItpControllerTrait;
14+
}

src/ShopifyApp/Http/Middleware/AuthProxy.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
use Illuminate\Http\Request;
77
use Illuminate\Support\Facades\Response;
88
use function Osiset\ShopifyApp\createHmac;
9+
use function Osiset\ShopifyApp\getShopifyConfig;
910
use Osiset\ShopifyApp\Objects\Values\NullableShopDomain;
1011
use function Osiset\ShopifyApp\parseQueryString;
1112
use Osiset\ShopifyApp\Services\ShopSession;
12-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
1313

1414
/**
1515
* Responsible for ensuring a proper app proxy request.
1616
*/
1717
class AuthProxy
1818
{
19-
use ConfigAccessible;
20-
2119
/**
2220
* Shop session helper.
2321
*
@@ -63,7 +61,7 @@ public function handle(Request $request, Closure $next)
6361
'data' => $query,
6462
'buildQuery' => true,
6563
],
66-
$this->getConfig('api_secret', $shop)
64+
getShopifyConfig('api_secret', $shop)
6765
);
6866
if ($signature !== $signatureLocal || $shop->isNull()) {
6967
// Issue with HMAC or missing shop header

src/ShopifyApp/Http/Middleware/AuthShopify.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
use Closure;
66
use Illuminate\Http\RedirectResponse;
77
use Illuminate\Http\Request;
8+
use Illuminate\Support\Facades\Auth;
9+
use Illuminate\Support\Facades\Log;
810
use Illuminate\Support\Facades\Redirect;
911
use Illuminate\Support\Facades\Session;
1012
use Osiset\ShopifyApp\Contracts\ApiHelper as IApiHelper;
1113
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopDomain as ShopDomainValue;
1214
use Osiset\ShopifyApp\Exceptions\MissingShopDomainException;
1315
use Osiset\ShopifyApp\Exceptions\SignatureVerificationException;
16+
use function Osiset\ShopifyApp\getShopifyConfig;
1417
use Osiset\ShopifyApp\Objects\Enums\DataSource;
1518
use Osiset\ShopifyApp\Objects\Values\NullShopDomain;
1619
use Osiset\ShopifyApp\Objects\Values\ShopDomain;
1720
use Osiset\ShopifyApp\Services\ShopSession;
18-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
1921

2022
/**
2123
* Response for ensuring an authenticated request.
2224
*/
2325
class AuthShopify
2426
{
25-
use ConfigAccessible;
26-
2727
/**
2828
* The API helper.
2929
*
@@ -349,7 +349,7 @@ private function handleBadVerification(Request $request, ShopDomainValue $domain
349349

350350
// Mis-match of shops
351351
return Redirect::route(
352-
$this->getConfig('route_names.authenticate.oauth'),
352+
getShopifyConfig('route_names.authenticate.oauth'),
353353
['shop' => $domain->toNative()]
354354
);
355355
}

src/ShopifyApp/Http/Middleware/AuthToken.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
use function Osiset\ShopifyApp\base64url_decode;
88
use function Osiset\ShopifyApp\base64url_encode;
99
use Osiset\ShopifyApp\Exceptions\HttpException;
10+
use function Osiset\ShopifyApp\getShopifyConfig;
1011
use Osiset\ShopifyApp\Objects\Values\ShopDomain;
1112
use Osiset\ShopifyApp\Services\ShopSession;
12-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
1313

1414
class AuthToken
1515
{
16-
use ConfigAccessible;
17-
1816
/**
1917
* The shop session helper.
2018
*
@@ -90,7 +88,7 @@ public function handle(Request $request, Closure $next)
9088
throw new HttpException('Invalid token', 400);
9189
}
9290

93-
if ($body->aud !== $this->getConfig('api_key')) {
91+
if ($body->aud !== getShopifyConfig('api_key')) {
9492
throw new HttpException('Invalid token', 400);
9593
}
9694

@@ -125,7 +123,7 @@ private function checkSignature($token)
125123
$shop = isset($url['host']) ? $url['host'] : null;
126124
}
127125

128-
$secret = $this->getConfig('api_secret', $shop);
126+
$secret = getShopifyConfig('api_secret', $shop);
129127
$hmac = hash_hmac('sha256', $check, $secret, true);
130128
$encoded = base64url_encode($hmac);
131129

src/ShopifyApp/Http/Middleware/AuthWebhook.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
use Illuminate\Http\Request;
77
use Illuminate\Support\Facades\Response;
88
use function Osiset\ShopifyApp\createHmac;
9-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
9+
use function Osiset\ShopifyApp\getShopifyConfig;
1010

1111
/**
1212
* Response for ensuring a proper webhook request.
1313
*/
1414
class AuthWebhook
1515
{
16-
use ConfigAccessible;
17-
1816
/**
1917
* Handle an incoming request to ensure webhook is valid.
2018
*
@@ -34,7 +32,7 @@ public function handle(Request $request, Closure $next)
3432
'raw' => true,
3533
'encode' => true,
3634
],
37-
$this->getConfig('api_secret', $shop)
35+
getShopifyConfig('api_secret', $shop)
3836
);
3937

4038
if (! hash_equals($hmac, $hmacLocal) || empty($shop)) {

src/ShopifyApp/Http/Middleware/Billable.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
use Closure;
66
use Illuminate\Http\Request;
77
use Illuminate\Support\Facades\Redirect;
8+
use function Osiset\ShopifyApp\getShopifyConfig;
89
use Osiset\ShopifyApp\Services\ShopSession;
9-
use Osiset\ShopifyApp\Traits\ConfigAccessible;
1010

1111
/**
1212
* Responsible for ensuring the shop is being billed.
1313
*/
1414
class Billable
1515
{
16-
use ConfigAccessible;
17-
1816
/**
1917
* The shop session helper.
2018
*
@@ -44,11 +42,11 @@ public function __construct(ShopSession $shopSession)
4442
*/
4543
public function handle(Request $request, Closure $next)
4644
{
47-
if ($this->getConfig('billing_enabled') === true) {
45+
if (getShopifyConfig('billing_enabled') === true) {
4846
$shop = $this->shopSession->getShop();
4947
if (! $shop->isFreemium() && ! $shop->isGrandfathered() && ! $shop->plan) {
5048
// They're not grandfathered in, and there is no charge or charge was declined... redirect to billing
51-
return Redirect::route($this->getConfig('route_names.billing'), $request->input());
49+
return Redirect::route(getShopifyConfig('route_names.billing'), $request->input());
5250
}
5351
}
5452

0 commit comments

Comments
 (0)