Skip to content

Commit

Permalink
Merge pull request #341 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 3.9.0
  • Loading branch information
candemiralp authored Jan 19, 2023
2 parents baabae0 + 1ec3daa commit f7f74ab
Show file tree
Hide file tree
Showing 63 changed files with 2,303 additions and 968 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen",
"version": "3.8.1",
"version": "3.9.0",
"type": "shopware-platform-plugin",
"license": "MIT",
"require": {
Expand Down
593 changes: 306 additions & 287 deletions composer.lock

Large diffs are not rendered by default.

69 changes: 63 additions & 6 deletions src/Controller/StoreApi/OrderApi/OrderApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@

namespace Adyen\Shopware\Controller\StoreApi\OrderApi;

use Adyen\Shopware\Exception\ValidationException;
use Adyen\Shopware\Service\PaymentMethodsBalanceService;
use Adyen\Shopware\Service\OrdersService;
use Adyen\Shopware\Service\OrdersCancelService;
use Adyen\Shopware\Service\PaymentStateDataService;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -55,6 +57,10 @@ class OrderApiController
* @var OrdersService
*/
private $ordersCancelService;
/**
* @var PaymentStateDataService
*/
private $paymentStateDataService;
/**
* @var LoggerInterface
*/
Expand All @@ -64,18 +70,22 @@ class OrderApiController
* StoreApiController constructor.
*
* @param PaymentMethodsBalanceService $paymentMethodsBalanceService
* @param OrdersService $orderService
* @param OrdersCancelService $orderCancelService
* @param OrdersService $ordersService
* @param OrdersCancelService $ordersCancelService
* @param PaymentStateDataService $paymentStateDataService
* @param LoggerInterface $logger
*/
public function __construct(
PaymentMethodsBalanceService $paymentMethodsBalanceService,
OrdersService $ordersService,
OrdersCancelService $ordersCancelService,
PaymentStateDataService $paymentStateDataService,
LoggerInterface $logger
) {
$this->paymentMethodsBalanceService = $paymentMethodsBalanceService;
$this->ordersService = $ordersService;
$this->ordersCancelService = $ordersCancelService;
$this->paymentStateDataService = $paymentStateDataService;
$this->logger = $logger;
}

Expand All @@ -92,12 +102,10 @@ public function __construct(
*/
public function getPaymentMethodsBalance(SalesChannelContext $context, Request $request): JsonResponse
{
$number = $request->request->get('number');
$type = $request->request->get('type');
$cvc = $request->request->get('cvc');
$paymentMethodData = $request->request->get('paymentMethod');

return new JsonResponse(
$this->paymentMethodsBalanceService->getPaymentMethodsBalance($context, $type, $number, $cvc)
$this->paymentMethodsBalanceService->getPaymentMethodsBalance($context, (array) $paymentMethodData)
);
}

Expand Down Expand Up @@ -137,4 +145,53 @@ public function cancelOrder(SalesChannelContext $context, Request $request): Jso

return new JsonResponse($this->ordersCancelService->cancelOrder($context, $orderData, $pspReference));
}

/**
* @Route(
* "/store-api/adyen/giftcard",
* name="store-api.action.adyen.giftcard",
* methods={"POST"}
* )
* @param SalesChannelContext $context
* @param Request $request
* @return JsonResponse
* @throws ValidationException
* @throws \Adyen\AdyenException
*/
public function giftcardStateData(SalesChannelContext $context, Request $request): JsonResponse
{
// store giftcard state data for context
$stateData = $request->request->get('stateData');
if ('giftcard' !== $stateData['paymentMethod']['type']) {
throw new ValidationException('Only giftcard state data is allowed to be stored.');
}
$this->paymentStateDataService->insertPaymentStateData(
$context->getToken(),
json_encode($stateData),
[
'amount' => (int) $request->request->get('amount'),
'paymentMethodId' => $request->request->get('paymentMethodId'),
'balance' => (int) $request->request->get('balance'),
]
);

return new JsonResponse(['paymentMethodId' => $request->request->get('paymentMethodId')]);
}

/**
* @Route(
* "/store-api/adyen/giftcard/remove",
* name="store-api.action.adyen.giftcard.remove",
* methods={"POST"}
* )
* @param SalesChannelContext $context
* @param Request $request
* @return JsonResponse
*/
public function deleteGiftCardStateData(SalesChannelContext $context, Request $request): JsonResponse
{
$this->paymentStateDataService->deletePaymentStateDataFromContextToken($context->getToken());

return new JsonResponse(['token' => $context->getToken()]);
}
}
261 changes: 261 additions & 0 deletions src/Entity/AdyenPayment/AdyenPaymentEntity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
<?php declare(strict_types=1);
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2022 Adyen N.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <[email protected]>
*/

namespace Adyen\Shopware\Entity\AdyenPayment;

use Shopware\Core\Framework\DataAbstractionLayer\Entity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;

class AdyenPaymentEntity extends Entity
{
use EntityIdTrait;

/**
* @var string
*/
protected $pspreference;

/**
* @var string
*/
protected $originalReference;

/**
* @var string
*/
protected $merchantReference;

/**
* @var string
*/
protected $merchantOrderReference;

/**
* @var string
*/
protected $orderTransactionId;

/**
* @var string
*/
protected $paymentMethod;

/**
* @var int
*/
protected $amountValue;

/**
* @var string
*/
protected $amountCurrency;

/**
* @var string
*/
protected $additionalData;

/**
* @var string
*/
protected $captureMode;

/**
* @var \DateTimeInterface|null
*/
protected $createdAt;

/**
* @var \DateTimeInterface|null
*/
protected $updatedAt;

/**
* @return string
*/
public function getPspreference(): string
{
return $this->pspreference;
}

/**
* @param string $pspreference
*/
public function setPspreference(string $pspreference): void
{
$this->pspreference = $pspreference;
}

/**
* @return string
*/
public function getOriginalReference(): string
{
return $this->originalReference;
}

/**
* @param string $originalReference
*/
public function setOriginalReference(string $originalReference): void
{
$this->originalReference = $originalReference;
}

/**
* @return string
*/
public function getMerchantReference(): string
{
return $this->merchantReference;
}

/**
* @param string $merchantReference
*/
public function setMerchantReference(string $merchantReference): void
{
$this->merchantReference = $merchantReference;
}

/**
* @return string
*/
public function getMerchantOrderReference(): string
{
return $this->merchantOrderReference;
}

/**
* @param string $merchantOrderReference
*/
public function setMerchantOrderReference(string $merchantOrderReference): void
{
$this->merchantOrderReference = $merchantOrderReference;
}

/**
* @return string
*/
public function getOrderTransactionId(): string
{
return $this->orderTransactionId;
}

/**
* @param int $orderTransactionId
*/
public function setEventCode(int $orderTransactionId): void
{
$this->orderTransactionId = $orderTransactionId;
}

/**
* @return string
*/
public function getPaymentMethod(): string
{
return $this->paymentMethod;
}

/**
* @param string $paymentMethod
*/
public function setPaymentMethod(string $paymentMethod): void
{
$this->paymentMethod = $paymentMethod;
}

/**
* @return int
*/
public function getAmountValue(): int
{
return $this->amountValue;
}

/**
* @param int $amountValue
*/
public function setAmountValue(int $amountValue): void
{
$this->amountValue = $amountValue;
}

/**
* @return string
*/
public function getAmountCurrency(): string
{
return $this->amountCurrency;
}

/**
* @param string $amountCurrency
*/
public function setAmountCurrency(string $amountCurrency): void
{
$this->amountCurrency = $amountCurrency;
}

/**
* @return string
*/
public function getAdditionalData(): string
{
return $this->additionalData;
}

/**
* @param string $additionalData
*/
public function setAdditionalData(string $additionalData): void
{
$this->additionalData = $additionalData;
}

/**
* @return string
*/
public function getCaptureMode(): string
{
return $this->captureMode;
}

/**
* @param string $captureMode
*/
public function setCaptureMode(string $captureMode): void
{
$this->captureMode = $captureMode;
}

/**
* @return \DateTimeInterface|null
*/
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
}
Loading

0 comments on commit f7f74ab

Please sign in to comment.