Skip to content

Commit

Permalink
Fix dal validation errors
Browse files Browse the repository at this point in the history
ISSUE: CS-6135
  • Loading branch information
AleksandarBoljanovic committed Nov 15, 2024
1 parent 3e7ccbe commit 7d5dce2
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@

namespace Adyen\Shopware\Core\Checkout\Order\Aggregate\OrderTransaction;

use Adyen\Shopware\Entity\AdyenPayment\AdyenPaymentEntityDefinition;
use Adyen\Shopware\Entity\PaymentCapture\PaymentCaptureEntityDefinition;
use Adyen\Shopware\Entity\PaymentResponse\PaymentResponseEntityDefinition;
use Adyen\Shopware\Entity\Refund\RefundEntityDefinition;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition;
use Shopware\Core\Framework\Api\Context\SalesChannelApiSource;
use Shopware\Core\Framework\DataAbstractionLayer\EntityExtension;
Expand All @@ -49,14 +52,47 @@ public function extendFields(FieldCollection $collection): void
'order_transaction_id'
);

$refundField = new OneToManyAssociationField(
'adyenRefund',
RefundEntityDefinition::class,
'order_transaction_id'
);

$captureField = new OneToManyAssociationField(
'adyenCapture',
PaymentCaptureEntityDefinition::class,
'order_transaction_id'
);

$paymentField = new OneToManyAssociationField(
'adyenPayment',
AdyenPaymentEntityDefinition::class,
'order_transaction_id'
);

// Ensure the data is not available via the Store API in older Shopware versions.
if (!class_exists(ApiAware::class) &&
class_exists(Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected::class)) {
$field->addFlags(
new Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected(SalesChannelApiSource::class)
);

$refundField->addFlags(
new Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected(SalesChannelApiSource::class)
);

$captureField->addFlags(
new Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected(SalesChannelApiSource::class)
);

$paymentField->addFlags(
new Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected(SalesChannelApiSource::class)
);
}

$collection->add($field);
$collection->add($refundField);
$collection->add($captureField);
$collection->add($paymentField);
}
}
24 changes: 23 additions & 1 deletion src/Entity/AdyenPayment/AdyenPaymentEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace Adyen\Shopware\Entity\AdyenPayment;

use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity;
use Shopware\Core\Framework\DataAbstractionLayer\Entity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;

Expand Down Expand Up @@ -96,6 +97,11 @@ class AdyenPaymentEntity extends Entity
*/
protected $updatedAt;

/**
* @var OrderTransactionEntity
*/
protected OrderTransactionEntity $orderTransaction;

/**
* @return string
*/
Expand Down Expand Up @@ -171,7 +177,7 @@ public function getOrderTransactionId(): string
/**
* @param int $orderTransactionId
*/
public function setEventCode(int $orderTransactionId): void
public function setOrderTransactionId(int $orderTransactionId): void
{
$this->orderTransactionId = $orderTransactionId;
}
Expand Down Expand Up @@ -279,4 +285,20 @@ public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}

/**
* @return OrderTransactionEntity
*/
public function getOrderTransaction(): OrderTransactionEntity
{
return $this->orderTransaction;
}

/**
* @param OrderTransactionEntity $orderTransaction
*/
public function setOrderTransaction(OrderTransactionEntity $orderTransaction): void
{
$this->orderTransaction = $orderTransaction;
}
}
8 changes: 1 addition & 7 deletions src/Entity/AdyenPayment/AdyenPaymentEntityDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@

use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\LongTextField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IntField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\DateTimeField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\UpdatedAtField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\CreatedAtField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
Expand Down Expand Up @@ -65,11 +63,7 @@ protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()),
(new FkField(
'order_transaction_id',
'orderTransactionId',
OrderTransactionDefinition::class
))->addFlags(new Required()),
new IdField('order_transaction_id', 'orderTransactionId'),
new StringField('pspreference', 'pspreference'),
new StringField('original_reference', 'originalReference'),
new StringField('merchant_reference', 'merchantReference'),
Expand Down
7 changes: 1 addition & 6 deletions src/Entity/PaymentCapture/PaymentCaptureEntityDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
Expand Down Expand Up @@ -58,11 +57,7 @@ protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()),
(new FkField(
'order_transaction_id',
'orderTransactionId',
OrderTransactionDefinition::class
))->addFlags(new Required()),
new IdField('order_transaction_id', 'orderTransactionId'),
new StringField('psp_reference', 'pspReference'),
(new IntField('amount', 'amount'))->addFlags(new Required()),
(new StringField('source', 'source'))->addFlags(new Required()),
Expand Down
53 changes: 11 additions & 42 deletions src/Entity/PaymentResponse/PaymentResponseEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ class PaymentResponseEntity extends Entity
*/
protected $resultCode;

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

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

/**
* @var string
*/
Expand All @@ -71,6 +61,7 @@ class PaymentResponseEntity extends Entity
*/
protected $pspreference;


/**
* @return string
*/
Expand Down Expand Up @@ -119,38 +110,6 @@ public function setResultCode(string $resultCode): void
$this->resultCode = $resultCode;
}

/**
* @return string
*/
public function getRefusalReason(): ?string
{
return $this->refusalReason;
}

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

/**
* @return string
*/
public function getRefusalReasonCode(): ?string
{
return $this->refusalReasonCode;
}

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

/**
* @return string
*/
Expand Down Expand Up @@ -182,4 +141,14 @@ public function setPspreference(?string $pspreference): void
{
$this->pspreference = $pspreference;
}

public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}

public function setCreatedAt(?\DateTimeInterface $createdAt): void
{
$this->createdAt = $createdAt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\CreatedAtField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
Expand Down Expand Up @@ -59,11 +58,7 @@ protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()),
(new FkField(
'order_transaction_id',
'orderTransactionId',
OrderTransactionDefinition::class
))->addFlags(new Required()),
new IdField('order_transaction_id', 'orderTransactionId'),
new StringField('result_code', 'resultCode'),
new StringField('pspreference', 'pspreference'),
new LongTextField('response', 'response'),
Expand Down
10 changes: 1 addition & 9 deletions src/Entity/Refund/RefundEntityDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
namespace Adyen\Shopware\Entity\Refund;

use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition;
use Shopware\Core\Checkout\Order\OrderDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\BoolField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\CreatedAtField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
Expand Down Expand Up @@ -61,11 +57,7 @@ protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()),
(new FkField(
'order_transaction_id',
'orderTransactionId',
OrderTransactionDefinition::class
))->addFlags(new Required()),
new IdField('order_transaction_id', 'orderTransactionId'),
new StringField('psp_reference', 'pspReference'),
(new IntField('amount', 'amount'))->addFlags(new Required()),
(new StringField('source', 'source'))->addFlags(new Required()),
Expand Down
2 changes: 0 additions & 2 deletions src/Handlers/PaymentResponseHandlerResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public function createFromPaymentResponse(PaymentResponseEntity $paymentResponse
{
// Set result code
$this->setResultCode($paymentResponse->getResultCode());
$this->setRefusalReason($paymentResponse->getRefusalReason());
$this->setRefusalReasonCode($paymentResponse->getRefusalReasonCode());

$response = $paymentResponse->getResponse();

Expand Down

0 comments on commit 7d5dce2

Please sign in to comment.