Skip to content

Commit

Permalink
Remove payment helper
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed May 21, 2024
2 parents 140b916 + 8e25eff commit 4490d81
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions PlaceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,24 @@ public function __construct(
public function place(array $orderList): array
{
try {
$mollieOrders = [];
foreach ($orderList as $order) {
$this->orderManagement->place($order);
if (substr($order->getPayment()->getMethod(), 0, 6) === 'mollie') {
// Only process Mollie orders; some orders _could_ have been paid with 'free' method.
$mollieOrders[] = $order;
}
}

$firstOrder = reset($orderList);
if (count($mollieOrders) === 0) {
// This situation should not happen, as the quote would then have 'free' payment method.
// This class will then never be called. But to be sure...
return $this->errorList;
}

$firstOrder = reset($mollieOrders);
$storeId = $firstOrder->getStoreId();
$paymentData = $this->buildPaymentData($orderList, $storeId);
$paymentData = $this->buildPaymentData($mollieOrders, $storeId);

$paymentData = $this->mollieHelper->validatePaymentData($paymentData);
$this->mollieHelper->addTolog('request', $paymentData);
Expand All @@ -140,7 +151,7 @@ public function place(array $orderList): array
return $errorList;
}

foreach ($orderList as $order) {
foreach ($mollieOrders as $order) {
try {
$this->molliePaymentsApi->processResponse($order, $paymentResponse);
} catch (\Exception $exception) {
Expand Down

0 comments on commit 4490d81

Please sign in to comment.