@@ -51,9 +51,10 @@ trait CartPay
5151 public function payFreeCart (CartInterface $ cart ): array
5252 {
5353 return app (AtomicServiceInterface::class)->block ($ this , function () use ($ cart ) {
54+ $ basketDto = $ cart ->getBasketDto ();
5455 $ basketService = app (BasketServiceInterface::class);
5556 $ availabilityAssembler = app (AvailabilityDtoAssemblerInterface::class);
56- if (!$ basketService ->availability ($ availabilityAssembler ->create ($ this , $ cart -> getBasketDto () , false ))) {
57+ if (!$ basketService ->availability ($ availabilityAssembler ->create ($ this , $ basketDto , false ))) {
5758 throw new ProductEnded (
5859 app (TranslatorServiceInterface::class)->get ('wallet::errors.product_stock ' ),
5960 ExceptionInterface::PRODUCT_ENDED
@@ -65,13 +66,13 @@ public function payFreeCart(CartInterface $cart): array
6566 $ transfers = [];
6667 $ prepareService = app (PrepareServiceInterface::class);
6768 $ assistantService = app (AssistantServiceInterface::class);
68- foreach ($ cart -> getBasketDto () ->cursor () as $ product ) {
69+ foreach ($ basketDto ->cursor () as $ product ) {
6970 $ transfers [] = $ prepareService ->transferLazy (
7071 $ this ,
7172 $ product ,
7273 Transfer::STATUS_PAID ,
7374 0 ,
74- $ assistantService ->getMeta ($ cart , $ product )
75+ $ assistantService ->getMeta ($ basketDto , $ product )
7576 );
7677 }
7778
@@ -116,6 +117,7 @@ public function payCart(CartInterface $cart, bool $force = false): array
116117 }
117118
118119 $ transfers = [];
120+ $ basketDto = $ cart ->getBasketDto ();
119121 $ prepareService = app (PrepareServiceInterface::class);
120122 $ assistantService = app (AssistantServiceInterface::class);
121123 foreach ($ cart ->getBasketDto ()->cursor () as $ product ) {
@@ -124,7 +126,7 @@ public function payCart(CartInterface $cart, bool $force = false): array
124126 $ product ,
125127 Transfer::STATUS_PAID ,
126128 $ product ->getAmountProduct ($ this ),
127- $ assistantService ->getMeta ($ cart , $ product )
129+ $ assistantService ->getMeta ($ basketDto , $ product )
128130 );
129131 }
130132
@@ -173,8 +175,9 @@ public function safeRefundCart(CartInterface $cart, bool $force = false, bool $g
173175 public function refundCart (CartInterface $ cart , bool $ force = false , bool $ gifts = false ): bool
174176 {
175177 return app (AtomicServiceInterface::class)->block ($ this , function () use ($ cart , $ force , $ gifts ) {
176- $ transfers = app (PurchaseServiceInterface::class)->already ($ this , $ cart ->getBasketDto (), $ gifts );
177- if (count ($ transfers ) !== $ cart ->getBasketDto ()->total ()) {
178+ $ basketDto = $ cart ->getBasketDto ();
179+ $ transfers = app (PurchaseServiceInterface::class)->already ($ this , $ basketDto , $ gifts );
180+ if (count ($ transfers ) !== $ basketDto ->total ()) {
178181 throw new ModelNotFoundException (
179182 "No query results for model [ {$ this ->transfers ()
180183 ->getMorphClass ()}] " ,
@@ -188,14 +191,14 @@ public function refundCart(CartInterface $cart, bool $force = false, bool $gifts
188191 $ transfers = array_values ($ transfers );
189192 $ prepareService = app (PrepareServiceInterface::class);
190193 $ assistantService = app (AssistantServiceInterface::class);
191- foreach ($ cart -> getBasketDto () ->cursor () as $ product ) {
194+ foreach ($ basketDto ->cursor () as $ product ) {
192195 $ transferIds [] = $ transfers [$ index ]->getKey ();
193196 $ objects [] = $ prepareService ->transferLazy (
194197 $ product ,
195198 $ transfers [$ index ]->withdraw ->wallet ,
196199 Transfer::STATUS_TRANSFER ,
197200 $ transfers [$ index ]->deposit ->amount ,
198- $ assistantService ->getMeta ($ cart , $ product )
201+ $ assistantService ->getMeta ($ basketDto , $ product )
199202 );
200203
201204 ++$ index ;
0 commit comments