44
55use Mond1SWR5 \Components \PluginConfig \Service \ConfigService ;
66use Mond1SWR5 \Enum \PaymentMethods ;
7+ use Mond1SWR5 \Services \OrderServices \AbstractOrderAdditionalCostsService ;
78use Monolog \Logger ;
89use Shopware \Components \HttpClient \RequestException ;
910use Shopware \Components \Model \ModelManager ;
@@ -43,20 +44,27 @@ class OrderHelper
4344 */
4445 private $ customerHelper ;
4546
47+ /**
48+ * @var AbstractOrderAdditionalCostsService
49+ */
50+ private $ orderAdditionalCostsService ;
51+
4652 public function __construct (
4753 ModelManager $ modelManager ,
4854 DocumentHelper $ documentHelper ,
4955 Logger $ logger ,
5056 ConfigService $ configService ,
5157 CartHelper $ cartHelper ,
52- CustomerHelper $ customerHelper
58+ CustomerHelper $ customerHelper ,
59+ AbstractOrderAdditionalCostsService $ orderAdditionalCostsService
5360 ) {
5461 $ this ->modelManager = $ modelManager ;
5562 $ this ->documentHelper = $ documentHelper ;
5663 $ this ->logger = $ logger ;
5764 $ this ->configService = $ configService ;
5865 $ this ->cartHelper = $ cartHelper ;
5966 $ this ->customerHelper = $ customerHelper ;
67+ $ this ->orderAdditionalCostsService = $ orderAdditionalCostsService ;
6068 }
6169
6270 public function canShipOrder ($ order ): bool
@@ -72,7 +80,7 @@ public function canShipOrder($order): bool
7280 */
7381 public function shipOrder ($ order ) {
7482 /**
75- * @var MonduClient
83+ * @var $client MonduClient
7684 */
7785 $ client = Shopware ()->Container ()->get (MonduClient::class);
7886
@@ -195,6 +203,7 @@ public function getOrderFromOrderVariables($orderVariables) {
195203 'lines ' => [
196204 [
197205 'discount_cents ' => $ this ->getTotalDiscount ($ content , $ chargeVat ),
206+ 'buyer_fee_cents ' => $ this ->orderAdditionalCostsService ->getAdditionalCostsCentsFromOrderVariables ($ orderVariables ),
198207 'shipping_price_cents ' => round ($ shippingAmount * 100 ),
199208 'line_items ' => $ this ->removeDuplicateSwReferenceIds ($ this ->getLineItems ($ content , $ chargeVat ))
200209 ]
@@ -238,6 +247,7 @@ public function getOrderAdjustment($order) {
238247 'lines ' => [
239248 [
240249 'discount_cents ' => $ totalDiscountGross ,
250+ 'buyer_fee_cents ' => $ this ->orderAdditionalCostsService ->getAdditionalCostsCentsFromOrder ($ order ),
241251 'shipping_price_cents ' => round ($ order ->getInvoiceShipping () * 100 ),
242252 'line_items ' => $ this ->removeDuplicateSwReferenceIds ($ lineitems )
243253 ]
@@ -336,18 +346,19 @@ public function getInvoiceCreateState()
336346 }
337347
338348 private function getBuyerParams ($ userData ) {
339- $ params = $ userData ['additional ' ]['user ' ];
349+ $ user = $ userData ['additional ' ]['user ' ];
340350 $ billing = $ userData ['billingaddress ' ];
341351
342- $ phone = !$ billing ['phone ' ] ? null : (trim ($ billing ['phone ' ]) ?: null );
343-
344352 return [
345- 'email ' => $ params ['email ' ],
346- 'phone ' => $ phone ,
353+ 'email ' => $ user ['email ' ],
354+ 'first_name ' => $ user ['firstname ' ],
355+ 'last_name ' => $ user ['lastname ' ],
347356 'company_name ' => $ billing ['company ' ],
348- 'first_name ' => $ billing ['firstname ' ] ,
349- 'last_name ' => $ billing [ ' lastname ' ],
357+ 'phone ' => ! $ billing ['phone ' ] ? null : ( trim ( $ billing [ ' phone ' ]) ?: null ) ,
358+ 'is_registered ' => ( bool ) $ user [ ' userID ' ],
350359 'salutation ' => $ billing ['salutation ' ],
360+ 'created_at ' => $ user ['firstlogin ' ] . ' 00:00:00 ' ,
361+ 'updated_at ' => $ user ['changed ' ],
351362 'address_line1 ' => $ billing ['street ' ]
352363 ];
353364 }
0 commit comments