From 9ba97d36ba62d347bf7ee3df5151e5083384586d Mon Sep 17 00:00:00 2001 From: Turtuvshin Date: Thu, 22 Feb 2024 14:25:14 +0800 Subject: [PATCH 1/7] fix add store hours form --- addon/components/schedule-manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/components/schedule-manager.js b/addon/components/schedule-manager.js index 23f25f8..90d3d54 100644 --- a/addon/components/schedule-manager.js +++ b/addon/components/schedule-manager.js @@ -44,8 +44,8 @@ export default class ScheduleManagerComponent extends Component { }); this.modalsManager.show('modals/add-store-hours', { - title: this.intl.t('storefront.component.schedule-manager.add-new-hours-for-day', { Day: day }), - acceptButtonText: this.intl.t('storefront.component.schedule-manager-add-hours'), + title: this.intl.t('storefront.component.schedule-manager.add-new-hours-for-day', { day: day }), + acceptButtonText: this.intl.t('storefront.component.schedule-manager.add-hours'), acceptButtonIcon: 'save', hours, confirm: (modal) => { From 5f03288f963907e8b0794bf8792c8a15adaacc91 Mon Sep 17 00:00:00 2001 From: Turtuvshin Date: Thu, 22 Feb 2024 16:07:44 +0800 Subject: [PATCH 2/7] fix store location list --- server/src/Models/StoreLocation.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/Models/StoreLocation.php b/server/src/Models/StoreLocation.php index 9f8bcfd..d064bae 100644 --- a/server/src/Models/StoreLocation.php +++ b/server/src/Models/StoreLocation.php @@ -7,12 +7,14 @@ use Fleetbase\Traits\HasApiModelBehavior; use Fleetbase\Traits\HasPublicid; use Fleetbase\Traits\HasUuid; +use Fleetbase\LaravelMysqlSpatial\Eloquent\SpatialTrait; class StoreLocation extends StorefrontModel { use HasUuid; use HasPublicid; use HasApiModelBehavior; + use SpatialTrait; /** * The type of public Id to generate. From 7a9c2cfaa382c0e2b474ec333bd8de660ef754d5 Mon Sep 17 00:00:00 2001 From: Turtuvshin Date: Thu, 22 Feb 2024 18:29:28 +0800 Subject: [PATCH 3/7] fix generate a checkout token --- server/src/Http/Controllers/v1/CheckoutController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/Http/Controllers/v1/CheckoutController.php b/server/src/Http/Controllers/v1/CheckoutController.php index 781602e..84744b3 100644 --- a/server/src/Http/Controllers/v1/CheckoutController.php +++ b/server/src/Http/Controllers/v1/CheckoutController.php @@ -7,6 +7,7 @@ use Fleetbase\FleetOps\Models\Entity; use Fleetbase\FleetOps\Models\Order; use Fleetbase\FleetOps\Models\Payload; +use Fleetbase\Storefront\Models\Customer; use Fleetbase\FleetOps\Models\Place; use Fleetbase\FleetOps\Models\ServiceQuote; use Fleetbase\FleetOps\Support\Utils; @@ -53,7 +54,7 @@ public function beforeCheckout(InitializeCheckoutRequest $request) // find and validate cart session $cart = Cart::retrieve($cartId); $gateway = Storefront::findGateway($gatewayCode); - $customer = Contact::findFromCustomerId($customerId); + $customer = Customer::findFromCustomerId($customerId); $serviceQuote = ServiceQuote::select(['amount', 'meta', 'uuid', 'public_id'])->where('public_id', $serviceQuoteId)->first(); // handle cash orders From 69ff6cf223a7898c895df7fdb8b502973aab1ef0 Mon Sep 17 00:00:00 2001 From: Turtuvshin Date: Fri, 23 Feb 2024 10:53:22 +0800 Subject: [PATCH 4/7] fix create gateway on network --- addon/controllers/networks/index/network/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addon/controllers/networks/index/network/index.js b/addon/controllers/networks/index/network/index.js index 0bfb88c..3f12a8a 100644 --- a/addon/controllers/networks/index/network/index.js +++ b/addon/controllers/networks/index/network/index.js @@ -49,6 +49,13 @@ export default class NetworksIndexNetworkIndexController extends Controller { */ @service intl; + /** + * Store service to handle file uploads and other network requests. + * + * @property {Service} store + */ + @service store; + /** * Proof of delivery methods. * From 4619981d3d1711e77945aa0ccf745dbeee776003 Mon Sep 17 00:00:00 2001 From: Turtuvshin Date: Fri, 23 Feb 2024 13:03:27 +0800 Subject: [PATCH 5/7] Fix capture order --- server/src/Expansions/EntityExpansion.php | 10 +++--- .../Controllers/v1/CheckoutController.php | 35 +++++++------------ server/src/Models/Checkout.php | 4 +-- server/src/routes.php | 4 +-- 4 files changed, 23 insertions(+), 30 deletions(-) diff --git a/server/src/Expansions/EntityExpansion.php b/server/src/Expansions/EntityExpansion.php index caf7863..d9ea5e1 100644 --- a/server/src/Expansions/EntityExpansion.php +++ b/server/src/Expansions/EntityExpansion.php @@ -2,6 +2,8 @@ namespace Fleetbase\Storefront\Expansions; +use Fleetbase\FleetOps\Models\Entity; +use Fleetbase\Storefront\Models\Product; use Fleetbase\Build\Expansion; class EntityExpansion implements Expansion @@ -13,18 +15,18 @@ class EntityExpansion implements Expansion */ public static function target() { - return \Fleetbase\FleetOps\Models\Entity::class; + return Entity::class; } /** * Create a new Entity from a Storefront Product. * - * @return \Fleetbase\FleetOps\Models\Entity + * @return Entity */ public function fromStorefrontProduct() { - return static function (\Fleetbase\Storefront\Models\Product $product) { - return new static([ + return static function (Product $product) { + return new Entity([ 'company_uuid' => session('company'), 'photo_uuid' => $product->primary_image_uuid, 'internal_id' => $product->public_id, diff --git a/server/src/Http/Controllers/v1/CheckoutController.php b/server/src/Http/Controllers/v1/CheckoutController.php index 84744b3..cac9810 100644 --- a/server/src/Http/Controllers/v1/CheckoutController.php +++ b/server/src/Http/Controllers/v1/CheckoutController.php @@ -114,7 +114,7 @@ public static function initializeCashCheckout(Contact $customer, Gateway $gatewa 'gateway_uuid' => $gateway->uuid ?? null, 'service_quote_uuid' => $serviceQuote->uuid, 'owner_uuid' => $customer->uuid, - 'owner_type' => 'contact', + 'owner_type' => 'fleet-ops:contact', 'amount' => $amount, 'currency' => $currency, 'is_cod' => true, @@ -188,7 +188,7 @@ public static function initializeStripeCheckout(Contact $customer, Gateway $gate 'gateway_uuid' => $gateway->uuid, 'service_quote_uuid' => $serviceQuote->uuid, 'owner_uuid' => $customer->uuid, - 'owner_type' => 'contact', + 'owner_type' => 'fleet-ops:contact', 'amount' => $amount, 'currency' => $currency, 'is_pickup' => $isPickup, @@ -250,7 +250,7 @@ public static function initializeQpayCheckout(Contact $customer, Gateway $gatewa 'gateway_uuid' => $gateway->uuid, 'service_quote_uuid' => $serviceQuote->uuid, 'owner_uuid' => $customer->uuid, - 'owner_type' => 'contact', + 'owner_type' => 'fleet-ops:contact', 'amount' => $amount, 'currency' => $currency, 'is_pickup' => $isPickup, @@ -346,7 +346,7 @@ public function captureOrder(CaptureOrderRequest $request) $transaction = Transaction::create([ 'company_uuid' => session('company'), 'customer_uuid' => $customer->uuid, - 'customer_type' => 'contact', + 'customer_type' => Utils::getMutationType('fleet-ops:contact'), 'gateway_transaction_id' => Utils::or($transactionDetails, ['id', 'transaction_id']) ?? Transaction::generateNumber(), 'gateway' => $gateway->code, 'gateway_uuid' => $gateway->uuid, @@ -459,18 +459,7 @@ public function captureOrder(CaptureOrderRequest $request) // create entities foreach ($cart->items as $cartItem) { $product = Product::where('public_id', $cartItem->product_id)->first(); - $entity = Entity::fromStorefrontProduct($product)->fill([ - 'company_uuid' => session('company'), - 'payload_uuid' => $payload->uuid, - 'customer_uuid' => $customer->uuid, - 'customer_type' => 'contact', - ])->setMetas([ - 'variants' => $cartItem->variants, - 'addons' => $cartItem->addons, - 'subtotal' => $cartItem->subtotal, - 'quantity' => $cartItem->quantity, - 'scheduled_at' => $cartItem->scheduled_at ?? null, - ]); + $entity = Entity::fromStorefrontProduct($product); $entity->save(); } @@ -506,7 +495,7 @@ public function captureOrder(CaptureOrderRequest $request) 'company_uuid' => $store->company_uuid ?? session('company'), 'payload_uuid' => $payload->uuid, 'customer_uuid' => $customer->uuid, - 'customer_type' => 'contact', + 'customer_type' => Utils::getMutationType('fleet-ops:contact'), 'transaction_uuid' => $transaction->uuid, 'adhoc' => $about->isOption('auto_dispatch'), 'type' => 'storefront', @@ -526,6 +515,8 @@ public function captureOrder(CaptureOrderRequest $request) // create order $order = Order::create($orderInput); + info('Order created', $order->toArray()); + // notify order creation Storefront::alertNewOrder($order); @@ -611,7 +602,7 @@ public function captureMultipleOrders(CaptureOrderRequest $request) $transaction = Transaction::create([ 'company_uuid' => session('company'), 'customer_uuid' => $customer->uuid, - 'customer_type' => 'contact', + 'customer_type' => Utils::getMutationType('fleet-ops:contact'), 'gateway_transaction_id' => Utils::or($transactionDetails, ['id', 'transaction_id']) ?? Transaction::generateNumber(), 'gateway' => $gateway->code, 'gateway_uuid' => $gateway->uuid, @@ -707,7 +698,7 @@ public function captureMultipleOrders(CaptureOrderRequest $request) 'company_uuid' => $store->company_uuid, 'payload_uuid' => $payload->uuid, 'customer_uuid' => $customer->uuid, - 'customer_type' => 'contact', + 'customer_type' => Utils::getMutationType('fleet-ops:contact'), ])->setMetas([ 'variants' => $cartItem->variants, 'addons' => $cartItem->addons, @@ -747,7 +738,7 @@ public function captureMultipleOrders(CaptureOrderRequest $request) 'company_uuid' => $store->company_uuid, 'payload_uuid' => $payload->uuid, 'customer_uuid' => $customer->uuid, - 'customer_type' => 'contact', + 'customer_type' => Utils::getMutationType('fleet-ops:contact'), 'transaction_uuid' => $transaction->uuid, 'adhoc' => $about->isOption('auto_dispatch'), 'type' => 'storefront', @@ -812,7 +803,7 @@ public function captureMultipleOrders(CaptureOrderRequest $request) 'company_uuid' => session('company'), 'payload_uuid' => $payload->uuid, 'customer_uuid' => $customer->uuid, - 'customer_type' => 'contact', + 'customer_type' => Utils::getMutationType('fleet-ops:contact'), ])->setMetas([ 'variants' => $cartItem->variants, 'addons' => $cartItem->addons, @@ -850,7 +841,7 @@ public function captureMultipleOrders(CaptureOrderRequest $request) 'company_uuid' => session('company'), 'payload_uuid' => $payload->uuid, 'customer_uuid' => $customer->uuid, - 'customer_type' => 'contact', + 'customer_type' => Utils::getMutationType('fleet-ops:contact'), 'transaction_uuid' => $transaction->uuid, 'adhoc' => $about->isOption('auto_dispatch'), 'type' => 'storefront', diff --git a/server/src/Models/Checkout.php b/server/src/Models/Checkout.php index 214d3ad..8ae0fce 100644 --- a/server/src/Models/Checkout.php +++ b/server/src/Models/Checkout.php @@ -3,9 +3,9 @@ namespace Fleetbase\Storefront\Models; use Fleetbase\Casts\Json; -use Fleetbase\FleetOps\Support\Utils; +use Fleetbase\Support\Utils; use Fleetbase\Models\Company; -use Fleetbase\Models\ServiceQuote; +use Fleetbase\FleetOps\Models\ServiceQuote; use Fleetbase\Traits\HasOptionsAttributes; use Fleetbase\Traits\HasPublicid; use Fleetbase\Traits\HasUuid; diff --git a/server/src/routes.php b/server/src/routes.php index 5831512..08eae34 100644 --- a/server/src/routes.php +++ b/server/src/routes.php @@ -39,7 +39,7 @@ function ($router) { // storefront/v1/checkouts $router->group(['prefix' => 'checkouts'], function () use ($router) { $router->get('before', 'CheckoutController@beforeCheckout'); - $router->get('capture', 'CheckoutController@captureOrder'); + $router->post('capture', 'CheckoutController@captureOrder'); }); // storefront/v1/service-quotes @@ -105,7 +105,7 @@ function ($router) { */ $router->prefix(config('storefront.api.routing.internal_prefix', 'int'))->group( function ($router) { - $router->group(['prefix' => 'int/v1', 'middleware' => ['internal.cors']], function () use ($router) { + $router->group(['prefix' => 'v1'], function () use ($router) { $router->get('networks/find/{id}', 'NetworkController@findNetwork'); }); From 1e7b854b90af7b112fb6291d46eec7411166183f Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 23 Feb 2024 13:39:29 +0800 Subject: [PATCH 6/7] bump version and upgrade dependencies --- composer.json | 6 +++--- extension.json | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 37db3ca..f37bbaf 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fleetbase/storefront-api", - "version": "0.3.1", + "version": "0.3.2", "description": "Headless Commerce & Marketplace Extension for Fleetbase", "keywords": [ "fleetbase-extension", @@ -22,8 +22,8 @@ ], "require": { "php": "^8.0", - "fleetbase/core-api": "^1.4.7", - "fleetbase/fleetops-api": "^0.4.13", + "fleetbase/core-api": "^1.4.9", + "fleetbase/fleetops-api": "^0.4.15", "geocoder-php/google-maps-places-provider": "^1.4", "laravel-notification-channels/apn": "^5.0", "laravel-notification-channels/fcm": "^4.1", diff --git a/extension.json b/extension.json index 70bc4b9..b3793b0 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "Storefront", - "version": "0.3.1", + "version": "0.3.2", "description": "Headless Commerce & Marketplace Extension for Fleetbase", "repository": "https://github.com/fleetbase/storefront", "license": "MIT", diff --git a/package.json b/package.json index 9a8a264..87d6fed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/storefront-engine", - "version": "0.3.1", + "version": "0.3.2", "description": "Headless Commerce & Marketplace Extension for Fleetbase", "fleetbase": { "route": "storefront", From 5ab00829310f26fe9e32f41491f474055e0e6f8f Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 23 Feb 2024 13:39:42 +0800 Subject: [PATCH 7/7] ran linter --- server/src/Expansions/EntityExpansion.php | 2 +- server/src/Http/Controllers/v1/CheckoutController.php | 4 ++-- server/src/Models/Checkout.php | 4 ++-- server/src/Models/StoreLocation.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/Expansions/EntityExpansion.php b/server/src/Expansions/EntityExpansion.php index d9ea5e1..7a893a9 100644 --- a/server/src/Expansions/EntityExpansion.php +++ b/server/src/Expansions/EntityExpansion.php @@ -2,9 +2,9 @@ namespace Fleetbase\Storefront\Expansions; +use Fleetbase\Build\Expansion; use Fleetbase\FleetOps\Models\Entity; use Fleetbase\Storefront\Models\Product; -use Fleetbase\Build\Expansion; class EntityExpansion implements Expansion { diff --git a/server/src/Http/Controllers/v1/CheckoutController.php b/server/src/Http/Controllers/v1/CheckoutController.php index cac9810..04d9c57 100644 --- a/server/src/Http/Controllers/v1/CheckoutController.php +++ b/server/src/Http/Controllers/v1/CheckoutController.php @@ -7,7 +7,6 @@ use Fleetbase\FleetOps\Models\Entity; use Fleetbase\FleetOps\Models\Order; use Fleetbase\FleetOps\Models\Payload; -use Fleetbase\Storefront\Models\Customer; use Fleetbase\FleetOps\Models\Place; use Fleetbase\FleetOps\Models\ServiceQuote; use Fleetbase\FleetOps\Support\Utils; @@ -18,6 +17,7 @@ use Fleetbase\Storefront\Http\Requests\InitializeCheckoutRequest; use Fleetbase\Storefront\Models\Cart; use Fleetbase\Storefront\Models\Checkout; +use Fleetbase\Storefront\Models\Customer; use Fleetbase\Storefront\Models\Gateway; use Fleetbase\Storefront\Models\Product; use Fleetbase\Storefront\Models\Store; @@ -346,7 +346,7 @@ public function captureOrder(CaptureOrderRequest $request) $transaction = Transaction::create([ 'company_uuid' => session('company'), 'customer_uuid' => $customer->uuid, - 'customer_type' => Utils::getMutationType('fleet-ops:contact'), + 'customer_type' => Utils::getMutationType('fleet-ops:contact'), 'gateway_transaction_id' => Utils::or($transactionDetails, ['id', 'transaction_id']) ?? Transaction::generateNumber(), 'gateway' => $gateway->code, 'gateway_uuid' => $gateway->uuid, diff --git a/server/src/Models/Checkout.php b/server/src/Models/Checkout.php index 8ae0fce..c804fed 100644 --- a/server/src/Models/Checkout.php +++ b/server/src/Models/Checkout.php @@ -3,9 +3,9 @@ namespace Fleetbase\Storefront\Models; use Fleetbase\Casts\Json; -use Fleetbase\Support\Utils; -use Fleetbase\Models\Company; use Fleetbase\FleetOps\Models\ServiceQuote; +use Fleetbase\Models\Company; +use Fleetbase\Support\Utils; use Fleetbase\Traits\HasOptionsAttributes; use Fleetbase\Traits\HasPublicid; use Fleetbase\Traits\HasUuid; diff --git a/server/src/Models/StoreLocation.php b/server/src/Models/StoreLocation.php index d064bae..24c428c 100644 --- a/server/src/Models/StoreLocation.php +++ b/server/src/Models/StoreLocation.php @@ -3,11 +3,11 @@ namespace Fleetbase\Storefront\Models; use Fleetbase\FleetOps\Models\Place; +use Fleetbase\LaravelMysqlSpatial\Eloquent\SpatialTrait; use Fleetbase\Models\User; use Fleetbase\Traits\HasApiModelBehavior; use Fleetbase\Traits\HasPublicid; use Fleetbase\Traits\HasUuid; -use Fleetbase\LaravelMysqlSpatial\Eloquent\SpatialTrait; class StoreLocation extends StorefrontModel {