Skip to content

Commit

Permalink
fix: change php client version and fix Alma order save in array
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Gomis committed Oct 8, 2024
1 parent 253bde8 commit 0e6185c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"license": "MIT",
"require": {
"php": "~7.3 || ~7.4 || ~8.0 || ~8.1 || ~8.2",
"alma/alma-php-client": ">=1.11.2",
"alma/alma-php-client": ">=2.2.0",
"sylius/sylius": ">=v1.9.0",
"ext-json": "*"
},
Expand Down
28 changes: 27 additions & 1 deletion src/Payum/Action/ValidatePaymentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ public function execute($request): void
$paymentData
);

// Convert Alma's orders to an array to save on Sylius' Payment details
$paymentData->orders = $this->convertOrderToArrayForDBSave($paymentData->orders);

// Save Alma's payment data on Sylius' Payment details
$details[AlmaBridgeInterface::DETAILS_KEY_PAYMENT_DATA] = $paymentData;

$payment->setDetails($details);
}

Expand All @@ -63,4 +65,28 @@ public function supports($request): bool
return $request instanceof ValidatePayment
&& $request->getModel() instanceof PaymentInterface;
}

/**
* Convert Alma's orders to an array to save on Sylius' Payment details
*
* @param array $orders
* @return array
*/
private function convertOrderToArrayForDBSave(array $orders): array
{
$arrayOrders = [];
foreach ($orders as $order) {
$arrayOrders[] = [
'comment' => $order->getComment(),
'created' => $order->getCreatedAt(),
'customer_url' => $order->getCustomerUrl(),
'data' => $order->getOrderData(),
'id' => $order->getExternalId(),
'merchant_reference' => $order->getMerchantReference(),
'merchant_url' => $order->getMerchantUrl(),
'payment' =>$order->getPaymentId()
];
}
return $arrayOrders;
}
}

0 comments on commit 0e6185c

Please sign in to comment.