Move gateway reference generation to gateway checkout service
This commit is contained in:
@@ -224,18 +224,13 @@ class PaypalGateway implements GatewayInterface
|
||||
];
|
||||
}
|
||||
|
||||
private function getPaypalReference(GatewayCheckout $checkout, GatewayCharge $charge): string
|
||||
{
|
||||
return sprintf('CO%d-CH%d', $checkout->getId(), $charge->getId());
|
||||
}
|
||||
|
||||
private function getPaypalPurchaseUnits(GatewayCheckout $checkout): array
|
||||
{
|
||||
$units = [];
|
||||
|
||||
foreach ($checkout->getCharges() as $charge) {
|
||||
$money = $this->getPaypalMoney($charge);
|
||||
$reference = $this->getPaypalReference($checkout, $charge);
|
||||
$reference = $this->checkoutService->getGatewayReference($checkout, $charge);
|
||||
|
||||
$units[] = [
|
||||
'reference_id' => $reference,
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Service;
|
||||
|
||||
use App\Controller\GatewaysController;
|
||||
use App\Entity\GatewayCharge;
|
||||
use App\Entity\GatewayCheckout;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
|
||||
class GatewayCheckoutService
|
||||
@@ -12,8 +14,7 @@ class GatewayCheckoutService
|
||||
|
||||
public function __construct(
|
||||
private RouterInterface $router,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function generateRedirectUrl(string $gateway, string $type = self::RESPONSE_TYPE_SUCCESS, array $parameters = []): string
|
||||
{
|
||||
@@ -26,4 +27,15 @@ class GatewayCheckoutService
|
||||
RouterInterface::ABSOLUTE_URL
|
||||
);
|
||||
}
|
||||
|
||||
public function getGatewayReference(GatewayCheckout $checkout, GatewayCharge $charge): string
|
||||
{
|
||||
return sprintf(
|
||||
'AO%d-CO%d-CH%d-AT%d',
|
||||
$checkout->getOrigin()->getId(),
|
||||
$checkout->getId(),
|
||||
$charge->getId(),
|
||||
$charge->getTarget()->getId()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user