@fleetbase/storefront-engine 0.2.5 → 0.2.6
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/controllers/products/index/category/new.js +5 -9
- package/addon/models/product-addon-category.js +10 -1
- package/addon/models/product-variant.js +0 -2
- package/addon/models/product.js +35 -2
- package/addon/serializers/product.js +16 -0
- package/addon/templates/products/index/category/new.hbs +2 -2
- package/composer.json +3 -3
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/src/Auth/Schemas/Storefront.php +31 -39
- package/server/src/Console/Commands/NotifyStorefrontOrderNearby.php +9 -11
- package/server/src/Expansions/ContactFilterExpansion.php +1 -1
- package/server/src/Expansions/EntityExpansion.php +12 -12
- package/server/src/Expansions/OrderFilterExpansion.php +1 -1
- package/server/src/Expansions/VendorFilterExpansion.php +1 -1
- package/server/src/Http/Controllers/ActionController.php +9 -11
- package/server/src/Http/Controllers/AddonCategoryController.php +1 -1
- package/server/src/Http/Controllers/CustomerController.php +1 -1
- package/server/src/Http/Controllers/GatewayController.php +1 -1
- package/server/src/Http/Controllers/MetricsController.php +17 -17
- package/server/src/Http/Controllers/NetworkController.php +16 -26
- package/server/src/Http/Controllers/NotificationChannelController.php +1 -1
- package/server/src/Http/Controllers/OrderController.php +18 -22
- package/server/src/Http/Controllers/ProductAddonCategoryController.php +1 -2
- package/server/src/Http/Controllers/ProductAddonController.php +1 -2
- package/server/src/Http/Controllers/ProductController.php +89 -44
- package/server/src/Http/Controllers/ProductHourController.php +1 -1
- package/server/src/Http/Controllers/ProductVariantController.php +1 -1
- package/server/src/Http/Controllers/ProductVariantOptionController.php +1 -1
- package/server/src/Http/Controllers/ReviewController.php +1 -1
- package/server/src/Http/Controllers/StoreController.php +1 -2
- package/server/src/Http/Controllers/StoreHourController.php +1 -1
- package/server/src/Http/Controllers/StoreLocationController.php +1 -1
- package/server/src/Http/Controllers/StorefrontController.php +0 -2
- package/server/src/Http/Controllers/VoteController.php +1 -1
- package/server/src/Http/Controllers/v1/CartController.php +16 -26
- package/server/src/Http/Controllers/v1/CategoryController.php +3 -4
- package/server/src/Http/Controllers/v1/CheckoutController.php +283 -286
- package/server/src/Http/Controllers/v1/CustomerController.php +54 -67
- package/server/src/Http/Controllers/v1/GatewayControllerController.php +0 -2
- package/server/src/Http/Controllers/v1/NetworkController.php +26 -23
- package/server/src/Http/Controllers/v1/PaymentMethodController.php +0 -2
- package/server/src/Http/Controllers/v1/ProductController.php +1 -4
- package/server/src/Http/Controllers/v1/ReviewController.php +31 -35
- package/server/src/Http/Controllers/v1/ServiceQuoteController.php +57 -53
- package/server/src/Http/Controllers/v1/StoreController.php +8 -16
- package/server/src/Http/Filter/AddonCategoryFilter.php +1 -1
- package/server/src/Http/Filter/OrderFilter.php +2 -2
- package/server/src/Http/Middleware/SetStorefrontSession.php +9 -20
- package/server/src/Http/Requests/AddStoreToNetworkCategory.php +3 -3
- package/server/src/Http/Requests/CreateCustomerRequest.php +5 -7
- package/server/src/Http/Requests/CreateReviewRequest.php +4 -5
- package/server/src/Http/Requests/GetServiceQuoteFromCart.php +2 -2
- package/server/src/Http/Requests/InitializeCheckoutRequest.php +5 -5
- package/server/src/Http/Requests/NetworkActionRequest.php +2 -2
- package/server/src/Http/Requests/VerifyCreateCustomerRequest.php +2 -2
- package/server/src/Http/Resources/Cart.php +19 -18
- package/server/src/Http/Resources/Category.php +12 -11
- package/server/src/Http/Resources/Customer.php +15 -14
- package/server/src/Http/Resources/Gateway.php +12 -11
- package/server/src/Http/Resources/Media.php +9 -8
- package/server/src/Http/Resources/Network.php +32 -31
- package/server/src/Http/Resources/Product.php +88 -85
- package/server/src/Http/Resources/Review.php +14 -13
- package/server/src/Http/Resources/ReviewCustomer.php +12 -11
- package/server/src/Http/Resources/Store.php +38 -36
- package/server/src/Http/Resources/StoreHour.php +9 -8
- package/server/src/Http/Resources/StoreLocation.php +9 -8
- package/server/src/Imports/ProductsImport.php +0 -2
- package/server/src/Jobs/DownloadProductImageUrl.php +7 -4
- package/server/src/Listeners/HandleOrderCompleted.php +2 -1
- package/server/src/Listeners/HandleOrderDispatched.php +2 -1
- package/server/src/Listeners/HandleOrderDriverAssigned.php +2 -1
- package/server/src/Listeners/HandleOrderStarted.php +4 -3
- package/server/src/Mail/StorefrontNetworkInvite.php +7 -6
- package/server/src/Models/AddonCategory.php +2 -4
- package/server/src/Models/Cart.php +117 -124
- package/server/src/Models/Checkout.php +14 -12
- package/server/src/Models/Customer.php +9 -9
- package/server/src/Models/Gateway.php +22 -22
- package/server/src/Models/Network.php +41 -52
- package/server/src/Models/NetworkStore.php +6 -5
- package/server/src/Models/NotificationChannel.php +11 -9
- package/server/src/Models/PaymentMethod.php +9 -7
- package/server/src/Models/Product.php +152 -30
- package/server/src/Models/ProductAddon.php +14 -11
- package/server/src/Models/ProductAddonCategory.php +9 -8
- package/server/src/Models/ProductHour.php +6 -5
- package/server/src/Models/ProductStoreLocation.php +7 -5
- package/server/src/Models/ProductVariant.php +15 -11
- package/server/src/Models/ProductVariantOption.php +12 -9
- package/server/src/Models/Review.php +9 -7
- package/server/src/Models/Store.php +68 -84
- package/server/src/Models/StoreHour.php +6 -5
- package/server/src/Models/StoreLocation.php +12 -8
- package/server/src/Models/StorefrontModel.php +1 -1
- package/server/src/Models/Vote.php +8 -6
- package/server/src/Notifications/StorefrontOrderCanceled.php +15 -19
- package/server/src/Notifications/StorefrontOrderCompleted.php +15 -19
- package/server/src/Notifications/StorefrontOrderCreated.php +31 -36
- package/server/src/Notifications/StorefrontOrderDriverAssigned.php +15 -20
- package/server/src/Notifications/StorefrontOrderEnroute.php +14 -19
- package/server/src/Notifications/StorefrontOrderNearby.php +16 -21
- package/server/src/Notifications/StorefrontOrderPreparing.php +15 -18
- package/server/src/Notifications/StorefrontOrderReadyForPickup.php +15 -18
- package/server/src/Observers/NetworkObserver.php +2 -3
- package/server/src/Observers/ProductObserver.php +17 -33
- package/server/src/Providers/EventServiceProvider.php +15 -4
- package/server/src/Providers/StorefrontServiceProvider.php +8 -10
- package/server/src/Support/Metrics.php +12 -12
- package/server/src/Support/OrderConfig.php +3 -2
- package/server/src/Support/QPay.php +22 -20
- package/server/src/Support/Storefront.php +18 -17
- package/server/src/routes.php +1 -1
|
@@ -6,22 +6,22 @@ use GuzzleHttp\Client;
|
|
|
6
6
|
|
|
7
7
|
class QPay
|
|
8
8
|
{
|
|
9
|
-
private string $host
|
|
9
|
+
private string $host = 'https://merchant.qpay.mn/';
|
|
10
10
|
private string $namespace = 'v2';
|
|
11
11
|
private ?string $callbackUrl;
|
|
12
12
|
private array $requestOptions = [];
|
|
13
13
|
private Client $client;
|
|
14
14
|
|
|
15
|
-
public function __construct(
|
|
15
|
+
public function __construct(string $username = null, string $password = null, string $callbackUrl = null)
|
|
16
16
|
{
|
|
17
|
-
$this->callbackUrl
|
|
17
|
+
$this->callbackUrl = $callbackUrl;
|
|
18
18
|
$this->requestOptions = [
|
|
19
19
|
'base_uri' => $this->buildRequestUrl(),
|
|
20
|
-
'auth'
|
|
21
|
-
'headers'
|
|
20
|
+
'auth' => [$username, $password],
|
|
21
|
+
'headers' => [
|
|
22
22
|
'Content-Type' => 'application/json',
|
|
23
|
-
'Accept'
|
|
24
|
-
]
|
|
23
|
+
'Accept' => 'application/json',
|
|
24
|
+
],
|
|
25
25
|
];
|
|
26
26
|
$this->client = new Client($this->requestOptions);
|
|
27
27
|
}
|
|
@@ -29,7 +29,7 @@ class QPay
|
|
|
29
29
|
public function updateRequestOption($key, $value)
|
|
30
30
|
{
|
|
31
31
|
$this->requestOptions[$key] = $value;
|
|
32
|
-
$this->client
|
|
32
|
+
$this->client = new Client($this->requestOptions);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
public function getClient()
|
|
@@ -48,6 +48,7 @@ class QPay
|
|
|
48
48
|
private function buildRequestUrl(string $path = ''): string
|
|
49
49
|
{
|
|
50
50
|
$url = trim($this->host . $this->namespace . '/' . $path);
|
|
51
|
+
|
|
51
52
|
return $url;
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -59,7 +60,7 @@ class QPay
|
|
|
59
60
|
return $this;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
public static function instance(
|
|
63
|
+
public static function instance(string $username = null, string $password = null, string $callbackUrl = null): QPay
|
|
63
64
|
{
|
|
64
65
|
return new static($username, $password, $callbackUrl);
|
|
65
66
|
}
|
|
@@ -74,9 +75,9 @@ class QPay
|
|
|
74
75
|
$options['http_errors'] = false;
|
|
75
76
|
|
|
76
77
|
$response = $this->client->request($method, $path, $options);
|
|
77
|
-
$body
|
|
78
|
+
$body = $response->getBody();
|
|
78
79
|
$contents = $body->getContents();
|
|
79
|
-
$json
|
|
80
|
+
$json = json_decode($contents);
|
|
80
81
|
|
|
81
82
|
return $json;
|
|
82
83
|
}
|
|
@@ -119,13 +120,13 @@ class QPay
|
|
|
119
120
|
return $this;
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
public function setAuthToken(
|
|
123
|
+
public function setAuthToken(string $accessToken = null): QPay
|
|
123
124
|
{
|
|
124
125
|
if ($accessToken) {
|
|
125
126
|
$this->useBearerToken($accessToken);
|
|
126
127
|
} else {
|
|
127
128
|
$response = $this->getAuthToken();
|
|
128
|
-
$token
|
|
129
|
+
$token = $response->access_token;
|
|
129
130
|
|
|
130
131
|
if (isset($token)) {
|
|
131
132
|
$this->useBearerToken($token);
|
|
@@ -135,19 +136,19 @@ class QPay
|
|
|
135
136
|
return $this;
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
public function createSimpleInvoice(int $amount, ?string $invoiceCode = '', ?string $invoiceDescription = '', ?string $invoiceReceiverCode = '', ?string $senderInvoiceNo = '',
|
|
139
|
+
public function createSimpleInvoice(int $amount, ?string $invoiceCode = '', ?string $invoiceDescription = '', ?string $invoiceReceiverCode = '', ?string $senderInvoiceNo = '', string $callbackUrl = null)
|
|
139
140
|
{
|
|
140
141
|
if (!$callbackUrl && $this->hasCallbackUrl()) {
|
|
141
142
|
$callbackUrl = $this->callbackUrl;
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
$params = array_filter([
|
|
145
|
-
'invoice_code'
|
|
146
|
-
'amount'
|
|
147
|
-
'callback_url'
|
|
148
|
-
'invoice_description'
|
|
146
|
+
'invoice_code' => $invoiceCode,
|
|
147
|
+
'amount' => $amount,
|
|
148
|
+
'callback_url' => $callbackUrl,
|
|
149
|
+
'invoice_description' => $invoiceDescription,
|
|
149
150
|
'invoice_receiver_code' => $invoiceReceiverCode,
|
|
150
|
-
'sender_invoice_no'
|
|
151
|
+
'sender_invoice_no' => $senderInvoiceNo,
|
|
151
152
|
]);
|
|
152
153
|
|
|
153
154
|
return $this->createQPayInvoice($params);
|
|
@@ -166,7 +167,7 @@ class QPay
|
|
|
166
167
|
{
|
|
167
168
|
$params = [
|
|
168
169
|
'object_type' => 'INVOICE',
|
|
169
|
-
'object_id'
|
|
170
|
+
'object_id' => $invoiceId,
|
|
170
171
|
];
|
|
171
172
|
|
|
172
173
|
return $this->post('payment/check', $params, $options);
|
|
@@ -203,6 +204,7 @@ class QPay
|
|
|
203
204
|
public static function cleanCode(string $code)
|
|
204
205
|
{
|
|
205
206
|
$code = str_replace(' ', '-', $code);
|
|
207
|
+
|
|
206
208
|
return preg_replace('/[^A-Za-z0-9\-]/', '', $code);
|
|
207
209
|
}
|
|
208
210
|
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\Storefront\Support;
|
|
4
4
|
|
|
5
|
+
use Fleetbase\FleetOps\Models\Contact;
|
|
6
|
+
use Fleetbase\FleetOps\Models\Order;
|
|
7
|
+
use Fleetbase\Models\User;
|
|
5
8
|
use Fleetbase\Storefront\Models\Gateway;
|
|
6
9
|
use Fleetbase\Storefront\Models\Network;
|
|
7
10
|
use Fleetbase\Storefront\Models\Product;
|
|
8
11
|
use Fleetbase\Storefront\Models\Store;
|
|
9
|
-
use Fleetbase\FleetOps\Models\Contact;
|
|
10
|
-
use Fleetbase\FleetOps\Models\Order;
|
|
11
|
-
use Fleetbase\Models\User;
|
|
12
12
|
use Fleetbase\Storefront\Notifications\StorefrontOrderCreated;
|
|
13
13
|
use Illuminate\Support\Facades\Notification;
|
|
14
14
|
use Illuminate\Support\Facades\Redis;
|
|
@@ -22,6 +22,7 @@ class Storefront
|
|
|
22
22
|
* with bare minimum columns, but can optionally pass in more columns to receive.
|
|
23
23
|
*
|
|
24
24
|
* @param array $columns
|
|
25
|
+
*
|
|
25
26
|
* @return \Fleetbase\Models\Storefront\Network|\Fleetbase\Models\Storefront\Store
|
|
26
27
|
*/
|
|
27
28
|
public static function about($columns = [], $with = [])
|
|
@@ -42,7 +43,7 @@ class Storefront
|
|
|
42
43
|
$about = Network::select($columns)->where('key', $key)->with($with)->first();
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
$about->is_store
|
|
46
|
+
$about->is_store = Str::startsWith($key, 'store');
|
|
46
47
|
$about->is_network = Str::startsWith($key, 'network');
|
|
47
48
|
|
|
48
49
|
return $about;
|
|
@@ -64,7 +65,7 @@ class Storefront
|
|
|
64
65
|
return $about;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
$about->is_store
|
|
68
|
+
$about->is_store = Str::startsWith($id, 'store');
|
|
68
69
|
$about->is_network = Str::startsWith($id, 'network');
|
|
69
70
|
|
|
70
71
|
return $about;
|
|
@@ -114,7 +115,7 @@ class Storefront
|
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
return Gateway::where([
|
|
117
|
-
'code'
|
|
118
|
+
'code' => $code,
|
|
118
119
|
'owner_uuid' => session('storefront_store') ?? session('storefront_network'),
|
|
119
120
|
])->first();
|
|
120
121
|
}
|
|
@@ -150,21 +151,21 @@ class Storefront
|
|
|
150
151
|
|
|
151
152
|
public static function alertNewOrder(Order $order, $sendNow = false)
|
|
152
153
|
{
|
|
153
|
-
$about
|
|
154
|
+
$about = static::about(['alertable']);
|
|
154
155
|
$alertables = [];
|
|
155
156
|
|
|
156
157
|
if ($about->is_network) {
|
|
157
158
|
$store = static::findAbout($order->getMeta('storefront_id'), ['alertable']);
|
|
158
159
|
|
|
159
160
|
if ($store && $store->public_id !== $about->public_id) {
|
|
160
|
-
$merge
|
|
161
|
+
$merge = Utils::get($store, 'alertable.for_new_order', []);
|
|
161
162
|
$alertables = array_merge($alertables, $merge);
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
|
|
165
|
-
$merge
|
|
166
|
+
$merge = Utils::get($about, 'alertable.for_new_order', []);
|
|
166
167
|
$alertables = array_merge($alertables, $merge);
|
|
167
|
-
$users
|
|
168
|
+
$users = collect($alertables)->map(function ($id) {
|
|
168
169
|
return User::where('public_id', $id)->first();
|
|
169
170
|
});
|
|
170
171
|
|
|
@@ -183,14 +184,14 @@ class Storefront
|
|
|
183
184
|
{
|
|
184
185
|
$stripeCustomer = \Stripe\Customer::create([
|
|
185
186
|
'description' => 'Customer created in Fleetbase Storefront',
|
|
186
|
-
'email'
|
|
187
|
-
'name'
|
|
188
|
-
'phone'
|
|
189
|
-
'metadata'
|
|
190
|
-
'contact_id'
|
|
187
|
+
'email' => $customer->email,
|
|
188
|
+
'name' => $customer->name,
|
|
189
|
+
'phone' => $customer->phone,
|
|
190
|
+
'metadata' => [
|
|
191
|
+
'contact_id' => $customer->public_id,
|
|
191
192
|
'storefront_id' => session('storefront_store') ?? session('storefront_network'),
|
|
192
|
-
'company_id'
|
|
193
|
-
]
|
|
193
|
+
'company_id' => session('company'),
|
|
194
|
+
],
|
|
194
195
|
]);
|
|
195
196
|
|
|
196
197
|
// set the stripe customer to customer meta
|
package/server/src/routes.php
CHANGED
|
@@ -161,7 +161,7 @@ Route::prefix(config('storefront.api.routing.prefix', 'storefront'))->namespace(
|
|
|
161
161
|
$router->group(
|
|
162
162
|
[],
|
|
163
163
|
function ($router) {
|
|
164
|
-
|
|
164
|
+
/* Dashboard Build */
|
|
165
165
|
$router->get('dashboard', 'MetricsController@dashboard');
|
|
166
166
|
|
|
167
167
|
$router->group(
|