@fleetbase/storefront-engine 0.3.17 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addon/components/customer-panel/orders.hbs +107 -104
- package/addon/components/customer-panel/orders.js +52 -45
- package/addon/components/modals/incoming-order.hbs +208 -199
- package/addon/components/modals/manage-addons.js +6 -2
- package/addon/components/modals/order-ready-assign-driver.hbs +1 -1
- package/addon/components/order-panel/details.js +0 -2
- package/addon/components/order-panel.hbs +314 -1
- package/addon/components/order-panel.js +51 -3
- package/addon/components/widget/customers.hbs +75 -51
- package/addon/components/widget/customers.js +29 -41
- package/addon/components/widget/orders.hbs +278 -119
- package/addon/components/widget/orders.js +75 -80
- package/addon/components/widget/storefront-metrics.hbs +3 -6
- package/addon/components/widget/storefront-metrics.js +25 -41
- package/addon/controllers/orders/index.js +214 -105
- package/addon/controllers/products/index/category/new.js +2 -1
- package/addon/controllers/products/index/index.js +0 -23
- package/addon/controllers/settings/gateways.js +14 -18
- package/addon/helpers/get-tip-amount.js +13 -2
- package/addon/models/product-addon-category.js +3 -0
- package/addon/routes/application.js +2 -4
- package/addon/services/order-actions.js +248 -0
- package/addon/services/storefront.js +2 -0
- package/addon/styles/storefront-engine.css +55 -0
- package/addon/templates/home.hbs +2 -1
- package/addon/templates/orders/index/view.hbs +1 -1
- package/addon/templates/orders/index.hbs +26 -3
- package/addon/templates/products/index/category/new.hbs +4 -1
- package/addon/templates/products/index/index.hbs +28 -28
- package/addon/templates/settings/gateways.hbs +1 -1
- package/addon/templates/settings/index.hbs +2 -2
- package/addon/templates/settings.hbs +1 -1
- package/app/services/order-actions.js +1 -0
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/migrations/2023_05_03_025307_create_carts_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_checkouts_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_gateways_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_network_stores_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_networks_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_notification_channels_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_payment_methods_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_addon_categories_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_addons_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_hours_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_store_locations_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_variant_options_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_variants_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_products_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_reviews_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_store_hours_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_store_locations_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_stores_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_votes_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_carts_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_checkouts_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_gateways_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_network_stores_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_networks_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_notification_channels_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_payment_methods_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_addon_categories_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_addons_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_hours_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_store_locations_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_variant_options_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_variants_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_products_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_reviews_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_store_hours_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_store_locations_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_stores_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_votes_table.php +1 -1
- package/server/src/Http/Controllers/ActionController.php +2 -1
- package/server/src/Http/Controllers/OrderController.php +15 -2
- package/server/src/Http/Controllers/ProductController.php +2 -0
- package/server/src/Http/Controllers/v1/CheckoutController.php +337 -40
- package/server/src/Http/Controllers/v1/CustomerController.php +88 -3
- package/server/src/Http/Controllers/v1/ServiceQuoteController.php +5 -5
- package/server/src/Http/Controllers/v1/StoreController.php +35 -5
- package/server/src/Http/Requests/CreateCustomerRequest.php +4 -0
- package/server/src/Http/Requests/CreateStripeSetupIntentRequest.php +31 -0
- package/server/src/Http/Requests/CustomerRequest.php +31 -0
- package/server/src/Http/Requests/InitializeCheckoutRequest.php +2 -1
- package/server/src/Http/Resources/Cart.php +18 -1
- package/server/src/Http/Resources/Customer.php +19 -14
- package/server/src/Http/Resources/Store.php +5 -1
- package/server/src/Models/AddonCategory.php +14 -16
- package/server/src/Models/Cart.php +10 -5
- package/server/src/Models/Customer.php +2 -2
- package/server/src/Models/Gateway.php +9 -4
- package/server/src/Models/Product.php +9 -10
- package/server/src/Models/ProductAddonCategory.php +2 -0
- package/server/src/Models/Store.php +2 -2
- package/server/src/Observers/OrderObserver.php +7 -1
- package/server/src/Rules/IsValidLocation.php +2 -2
- package/server/src/Support/QPay.php +35 -1
- package/server/src/Support/Storefront.php +34 -0
- package/server/src/Support/StripeUtils.php +38 -0
- package/server/src/routes.php +19 -0
- package/translations/en-us.yaml +8 -2
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\Storefront\Support;
|
|
4
4
|
|
|
5
|
+
use Fleetbase\Storefront\Models\Checkout;
|
|
6
|
+
use Fleetbase\Support\Utils;
|
|
5
7
|
use GuzzleHttp\Client;
|
|
8
|
+
use Illuminate\Support\Str;
|
|
6
9
|
|
|
7
10
|
class QPay
|
|
8
11
|
{
|
|
@@ -14,7 +17,7 @@ class QPay
|
|
|
14
17
|
|
|
15
18
|
public function __construct(?string $username = null, ?string $password = null, ?string $callbackUrl = null)
|
|
16
19
|
{
|
|
17
|
-
$this->callbackUrl = $callbackUrl;
|
|
20
|
+
$this->callbackUrl = $callbackUrl ?? Utils::apiUrl('storefront/v1/checkouts/process-qpay');
|
|
18
21
|
$this->requestOptions = [
|
|
19
22
|
'base_uri' => $this->buildRequestUrl(),
|
|
20
23
|
'auth' => [$username, $password],
|
|
@@ -37,6 +40,13 @@ class QPay
|
|
|
37
40
|
return $this->client;
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
public function setCallback(string $url)
|
|
44
|
+
{
|
|
45
|
+
$this->callbackUrl = $url;
|
|
46
|
+
|
|
47
|
+
return $this;
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
public function setNamespace(string $namespace): ?QPay
|
|
41
51
|
{
|
|
42
52
|
$this->namespace = $namespace;
|
|
@@ -163,6 +173,11 @@ class QPay
|
|
|
163
173
|
return $this->post('invoice', $params, $options);
|
|
164
174
|
}
|
|
165
175
|
|
|
176
|
+
public function paymentGet(string $paymentId)
|
|
177
|
+
{
|
|
178
|
+
return $this->get('payment/' . $paymentId);
|
|
179
|
+
}
|
|
180
|
+
|
|
166
181
|
public function paymentCheck(string $invoiceId, $options = [])
|
|
167
182
|
{
|
|
168
183
|
$params = [
|
|
@@ -207,4 +222,23 @@ class QPay
|
|
|
207
222
|
|
|
208
223
|
return preg_replace('/[^A-Za-z0-9\-]/', '', $code);
|
|
209
224
|
}
|
|
225
|
+
|
|
226
|
+
public static function createTestPaymentDataFromCheckout(Checkout $checkout): array
|
|
227
|
+
{
|
|
228
|
+
return [
|
|
229
|
+
'payment_id' => (string) Str::uuid(),
|
|
230
|
+
'payment_status' => 'PAID',
|
|
231
|
+
'payment_fee' => '1.00',
|
|
232
|
+
'payment_amount' => $checkout->amount,
|
|
233
|
+
'payment_currency' => $checkout->currency,
|
|
234
|
+
'payment_date' => now(),
|
|
235
|
+
'payment_wallet' => 'TEST',
|
|
236
|
+
'object_type' => 'INVOICE',
|
|
237
|
+
'object_id' => $checkout->getOption('qpay_invoice_id', (string) Str::uuid()),
|
|
238
|
+
'next_payment_date' => null,
|
|
239
|
+
'transaction_type' => 'P2P',
|
|
240
|
+
'card_transactions' => [],
|
|
241
|
+
'p2p_transactions' => [],
|
|
242
|
+
];
|
|
243
|
+
}
|
|
210
244
|
}
|
|
@@ -12,6 +12,7 @@ use Fleetbase\Storefront\Models\Network;
|
|
|
12
12
|
use Fleetbase\Storefront\Models\Product;
|
|
13
13
|
use Fleetbase\Storefront\Models\Store;
|
|
14
14
|
use Fleetbase\Storefront\Notifications\StorefrontOrderCreated;
|
|
15
|
+
use Fleetbase\Support\Auth;
|
|
15
16
|
use Fleetbase\Support\Utils;
|
|
16
17
|
use Illuminate\Support\Facades\Notification;
|
|
17
18
|
use Illuminate\Support\Facades\Redis;
|
|
@@ -203,6 +204,39 @@ class Storefront
|
|
|
203
204
|
return $stripeCustomer;
|
|
204
205
|
}
|
|
205
206
|
|
|
207
|
+
public static function patchOrderConfig(Order $order)
|
|
208
|
+
{
|
|
209
|
+
$orderConfig = $order->config();
|
|
210
|
+
if (!$orderConfig) {
|
|
211
|
+
$orderConfig = Storefront::getDefaultOrderConfig();
|
|
212
|
+
if ($orderConfig) {
|
|
213
|
+
$order->update(['order_config_uuid' => $orderConfig->uuid]);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return $orderConfig;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public static function getDefaultOrderConfig()
|
|
221
|
+
{
|
|
222
|
+
$company = Auth::getCompany();
|
|
223
|
+
if ($company) {
|
|
224
|
+
return static::getOrderConfig($company);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
public static function getOrderConfig(Company $company)
|
|
231
|
+
{
|
|
232
|
+
$orderConfig = OrderConfig::where(['company_uuid' => $company->uuid, 'key' => 'storefront', 'namespace' => 'system:order-config:storefront'])->first();
|
|
233
|
+
if (!$orderConfig) {
|
|
234
|
+
$orderConfig = static::createStorefrontConfig($company);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return $orderConfig;
|
|
238
|
+
}
|
|
239
|
+
|
|
206
240
|
/**
|
|
207
241
|
* Creates or retrieves an existing storefront configuration for a given company.
|
|
208
242
|
*
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Support;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Storefront\Models\Customer;
|
|
6
|
+
use Illuminate\Support\Facades\Log;
|
|
7
|
+
use Stripe\PaymentMethod;
|
|
8
|
+
|
|
9
|
+
class StripeUtils
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Checks if the given customer's saved payment method is valid and attached to them on Stripe.
|
|
13
|
+
* If not, attempts to attach it.
|
|
14
|
+
*
|
|
15
|
+
* @param Customer $customer an instance of your Customer model
|
|
16
|
+
*
|
|
17
|
+
* @return bool true if the payment method is valid and attached, false otherwise
|
|
18
|
+
*/
|
|
19
|
+
public static function isCustomerPaymentMethodValid(Customer $customer): bool
|
|
20
|
+
{
|
|
21
|
+
$stripeCustomerId = $customer->getMeta('stripe_id');
|
|
22
|
+
$paymentMethodId = $customer->getMeta('stripe_payment_method_id');
|
|
23
|
+
|
|
24
|
+
if (!$stripeCustomerId || !$paymentMethodId) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
$pm = PaymentMethod::retrieve($paymentMethodId);
|
|
30
|
+
|
|
31
|
+
return $pm && $pm->customer === $stripeCustomerId;
|
|
32
|
+
} catch (\Exception $e) {
|
|
33
|
+
Log::error('Error verifying or attaching payment method: ' . $e->getMessage());
|
|
34
|
+
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
package/server/src/routes.php
CHANGED
|
@@ -15,6 +15,20 @@ use Illuminate\Support\Facades\Route;
|
|
|
15
15
|
|
|
16
16
|
Route::prefix(config('storefront.api.routing.prefix', 'storefront'))->namespace('Fleetbase\Storefront\Http\Controllers')->group(
|
|
17
17
|
function ($router) {
|
|
18
|
+
/*
|
|
19
|
+
|--------------------------------------------------------------------------
|
|
20
|
+
| Public/Callback Receivable Storefront API Routes
|
|
21
|
+
|--------------------------------------------------------------------------
|
|
22
|
+
|
|
|
23
|
+
| End-user API routes, these are routes that the SDK and applications will interface with, and require API credentials.
|
|
24
|
+
*/
|
|
25
|
+
Route::group(['prefix' => 'v1', 'namespace' => 'v1'], function ($router) {
|
|
26
|
+
// storefront/v1/checkouts
|
|
27
|
+
$router->group(['prefix' => 'checkouts'], function () use ($router) {
|
|
28
|
+
$router->match(['get', 'post'], 'capture-qpay', 'CheckoutController@captureQpayCallback');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
18
32
|
/*
|
|
19
33
|
|--------------------------------------------------------------------------
|
|
20
34
|
| Consumable Storefront API Routes
|
|
@@ -26,6 +40,7 @@ Route::prefix(config('storefront.api.routing.prefix', 'storefront'))->namespace(
|
|
|
26
40
|
->middleware('storefront.api')
|
|
27
41
|
->namespace('v1')
|
|
28
42
|
->group(function ($router) {
|
|
43
|
+
$router->get('lookup/{id}', 'StoreController@lookup');
|
|
29
44
|
$router->get('about', 'StoreController@about');
|
|
30
45
|
$router->get('locations/{id}', 'StoreController@location');
|
|
31
46
|
$router->get('locations', 'StoreController@locations');
|
|
@@ -40,6 +55,8 @@ Route::prefix(config('storefront.api.routing.prefix', 'storefront'))->namespace(
|
|
|
40
55
|
$router->group(['prefix' => 'checkouts'], function () use ($router) {
|
|
41
56
|
$router->get('before', 'CheckoutController@beforeCheckout');
|
|
42
57
|
$router->post('capture', 'CheckoutController@captureOrder');
|
|
58
|
+
$router->post('stripe-setup-intent', 'CheckoutController@createStripeSetupIntentForCustomer');
|
|
59
|
+
$router->put('stripe-update-payment-intent', 'CheckoutController@updateStripePaymentIntent');
|
|
43
60
|
});
|
|
44
61
|
|
|
45
62
|
// storefront/v1/service-quotes
|
|
@@ -80,6 +97,8 @@ Route::prefix(config('storefront.api.routing.prefix', 'storefront'))->namespace(
|
|
|
80
97
|
$router->post('verify-code', 'CustomerController@verifyCode');
|
|
81
98
|
$router->post('login', 'CustomerController@login');
|
|
82
99
|
$router->post('request-creation-code', 'CustomerController@requestCustomerCreationCode');
|
|
100
|
+
$router->post('stripe-ephemeral-key', 'CustomerController@getStripeEphemeralKey');
|
|
101
|
+
$router->post('stripe-setup-intent', 'CustomerController@getStripeSetupIntent');
|
|
83
102
|
});
|
|
84
103
|
|
|
85
104
|
// hotfix! storefront-app sending customer update to /contacts/ route
|
package/translations/en-us.yaml
CHANGED
|
@@ -226,7 +226,8 @@ storefront:
|
|
|
226
226
|
orders:
|
|
227
227
|
widget-title: Recent Orders
|
|
228
228
|
id-column: Order ID
|
|
229
|
-
|
|
229
|
+
cancel-order: Cancel Order
|
|
230
|
+
accept-order: Accept Order!
|
|
230
231
|
mark-as-ready: Mark as Ready!
|
|
231
232
|
mark-as-completed: Mark as Completed
|
|
232
233
|
more-details: More Details
|
|
@@ -236,8 +237,11 @@ storefront:
|
|
|
236
237
|
delivery-fee: Delivery fee
|
|
237
238
|
delivery-tip: Delivery tip
|
|
238
239
|
tip: Tip
|
|
240
|
+
total: Total
|
|
239
241
|
change-driver: Change Driver
|
|
240
242
|
assign-driver: Assign Driver
|
|
243
|
+
customer-pickup: Customer Pickup
|
|
244
|
+
pickup-order: Pickup Order
|
|
241
245
|
mark-as-ready-modal-pickup-title: Mark order ready for pickup?
|
|
242
246
|
mark-as-ready-modal-pickup-body: Marking the order as ready will notify the customer their order is ready for pickup!
|
|
243
247
|
mark-as-ready-modal-pickup-accept-button-text: Ready for Pickup!
|
|
@@ -429,6 +433,7 @@ storefront:
|
|
|
429
433
|
select-order-dropoff-location: Select order dropoff location
|
|
430
434
|
scheduled-at: Scheduled At
|
|
431
435
|
transaction-total: Transaction Total
|
|
436
|
+
total: Total
|
|
432
437
|
tracking-number: Tracking Number
|
|
433
438
|
driver-assigned: Driver Assigned
|
|
434
439
|
select-driver-for-order: Select driver for order
|
|
@@ -598,7 +603,8 @@ storefront:
|
|
|
598
603
|
proof-of-delivery-method: Proof of Delivery Method
|
|
599
604
|
enable-cash-on-delivery: Enable cash on delivery
|
|
600
605
|
enable-order-pickup: Enable order pickup
|
|
601
|
-
enable-
|
|
606
|
+
enable-tips: Enable tips
|
|
607
|
+
enable-delivery-tips: Enable delivery tips
|
|
602
608
|
enable-integrated-vendors: Enable integrated vendors
|
|
603
609
|
save-changes: Save Changes
|
|
604
610
|
locations:
|