9
9
use Kanvas \Companies \Models \CompaniesBranches ;
10
10
use Kanvas \Connectors \Stripe \Enums \ConfigurationEnum ;
11
11
use Kanvas \Exceptions \ValidationException ;
12
- use Kanvas \Souk \Orders \Models \Order ;
13
- use Kanvas \Souk \Services \B2BConfigurationService ;
14
12
use Stripe \PaymentIntent ;
15
13
use Stripe \Stripe ;
16
14
@@ -32,16 +30,9 @@ public function processPayment(mixed $root, array $request): array
32
30
33
31
public function generatePaymentIntent (mixed $ root , array $ request ): array
34
32
{
35
- $ user = auth ()->user ();
33
+ // $user = auth()->user();
36
34
$ app = app (Apps::class);
37
- $ orderId = $ request ['id ' ];
38
- $ company = B2BConfigurationService::getConfiguredB2BCompany ($ app , $ user ->getCurrentCompany ());
39
-
40
- $ order = Order::getByIdFromCompanyApp ($ orderId , $ company , $ app );
41
-
42
- if ($ order ->isFulfilled ()) {
43
- throw new ValidationException ('Order is already fulfilled ' );
44
- }
35
+ $ amount = (float ) $ request ['amount ' ];
45
36
46
37
$ stripeApiKey = $ app ->get (ConfigurationEnum::STRIPE_SECRET_KEY ->value );
47
38
if (empty ($ stripeApiKey )) {
@@ -50,7 +41,7 @@ public function generatePaymentIntent(mixed $root, array $request): array
50
41
51
42
Stripe::setApiKey ($ stripeApiKey );
52
43
53
- $ totalAmount = $ order -> total_gross_amount * 100 ;
44
+ $ totalAmount = $ amount * 100 ;
54
45
$ intent = PaymentIntent::create ([
55
46
'amount ' => $ totalAmount ,
56
47
'currency ' => 'usd ' ,
@@ -61,7 +52,7 @@ public function generatePaymentIntent(mixed $root, array $request): array
61
52
'client_secret ' => $ intent ->client_secret ,
62
53
'message ' => [
63
54
'message ' => 'Payment intent generated successfully ' ,
64
- 'amount ' => $ order -> total_gross_amount ,
55
+ 'amount ' => $ amount ,
65
56
'currency ' => 'usd ' ,
66
57
],
67
58
];
0 commit comments