Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 7.1.9
* Anpassungen für Unzer Shopware 6.7 plugin zur Unterstützung des Unzer Refund Manager

# 7.1.8
* Zuverlässigerer Checkout: Der „Bezahlen“-Button wartet jetzt, bis alle erforderlichen Komponenten vollständig geladen sind, wodurch fehlgeschlagene Bestellungen verhindert werden.
* Leistungsverbesserung: Ein redundanter Abruf der Händlerkonfiguration wurde entfernt, wenn die Konfiguration bereits vorhanden ist.
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG_en-GB.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 7.1.9
* Changes for Unzer Shopware 6.7 plugin to support Unzer Refund Manager

# 7.1.8
* More reliable checkout: The "Pay" button now waits until all required components are fully loaded, preventing failed orders.
* Performance improvement: Eliminated a redundant merchant config fetch when the config is already provided.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "unzerdev/shopware6",
"description": "Unzer payment integration for Shopware 6",
"version": "7.1.8",
"version": "7.1.9",
"type": "shopware-platform-plugin",
"license": "Apache-2.0",
"minimum-stability": "dev",
Expand Down
23 changes: 13 additions & 10 deletions src/Components/CancelService/CancelService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class CancelService implements CancelServiceInterface
{
private const PAYLATER_PAYMENT_METHODS = [
public const PAYLATER_PAYMENT_METHODS = [
PaymentInstaller::PAYMENT_ID_PAYLATER_INVOICE,
PaymentInstaller::PAYMENT_ID_PAYLATER_INSTALLMENT,
PaymentInstaller::PAYMENT_ID_PAYLATER_DIRECT_DEBIT_SECURED,
Expand All @@ -41,7 +41,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function cancelChargeById(string $orderTransactionId, string $chargeId, float $amountGross, ?string $reasonCode, Context $context): void
public function cancelChargeById(string $orderTransactionId, string $chargeId, float $amountGross, ?string $reasonCode, Context $context, string $referenceText = ''): Cancellation
{
$decimalPrecision = UnzerPayment6::MAX_DECIMAL_PRECISION;

Expand Down Expand Up @@ -76,24 +76,27 @@ public function cancelChargeById(string $orderTransactionId, string $chargeId, f
$payment = UnzerTransactionUtil::fetchPaymentFromOrderTransaction($transaction, $client);
if ($this->isPaylaterPaymentMethod($transaction->getPaymentMethodId())) {
$cancellation = new Cancellation($amountGross);
$cancellation->setPaymentReference($referenceText);

$client->cancelChargedPayment(
$responseCancellation = $client->cancelChargedPayment(
$payment,
$cancellation
);
} else {
$client->cancelChargeById(
$responseCancellation = $client->cancelChargeById(
$payment,
$chargeId,
$amountGross,
$this->getCancelReasonCode($reasonCode),
'',
$referenceText,
$amountNet,
$amountVat
);
}

$this->updateOrderStatus($client, $transaction, $context);

return $responseCancellation;
}

/**
Expand Down Expand Up @@ -121,6 +124,11 @@ public function cancelAuthorizationById(string $orderTransactionId, string $paym
$this->updateOrderStatus($client, $transaction, $context);
}

public function isPaylaterPaymentMethod(string $paymentMethodId): bool
{
return \in_array($paymentMethodId, self::PAYLATER_PAYMENT_METHODS, true);
}

protected function getOrderTransaction(string $orderTransactionId, Context $context): ?OrderTransactionEntity
{
$criteria = new Criteria([$orderTransactionId]);
Expand All @@ -139,11 +147,6 @@ protected function getCancelReasonCode(?string $reasonCode): string
return $reasonCode ?? CancelReasonCodes::REASON_CODE_CANCEL;
}

protected function isPaylaterPaymentMethod(string $paymentMethodId): bool
{
return \in_array($paymentMethodId, self::PAYLATER_PAYMENT_METHODS, true);
}

private function updateOrderStatus(Unzer $client, OrderTransactionEntity $orderTransaction, Context $context): void
{
try {
Expand Down
8 changes: 6 additions & 2 deletions src/Components/CancelService/CancelServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Shopware\Core\Framework\Context;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Resources\TransactionTypes\Cancellation;

interface CancelServiceInterface
{
Expand All @@ -18,8 +19,9 @@ public function cancelChargeById(
string $chargeId,
float $amountGross,
?string $reasonCode,
Context $context
): void;
Context $context,
string $referenceText = ''
): Cancellation;

/**
* @throws UnzerApiException
Expand All @@ -31,4 +33,6 @@ public function cancelAuthorizationById(
float $amountGross,
Context $context
): void;

public function isPaylaterPaymentMethod(string $paymentMethodId): bool;
}
1 change: 1 addition & 0 deletions src/Components/ConfigReader/ConfigReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ConfigReader implements ConfigReaderInterface
public const CONFIG_KEY_PAYPAL_SHOW_SAVE_ACCOUNT = 'paypalShowSaveAccount';
public const CONFIG_KEY_DELIVERY_STATUS_FOR_CAPTURE = 'deliveryStatusForAutomaticCapture';
public const CONFIG_KEY_DELIVERY_STATUS_FOR_REFUND = 'deliveryStatusForAutomaticRefund';
public const CONFIG_KEY_DELIVERY_STATUS_FOR_RETURNS_REFUND = 'deliveryStatusForAutomaticReturnsRefund';

public const CONFIG_KEY_USE_EXPRESS_PAYPAL = 'usePaypalExpress';
public const CONFIG_KEY_USE_EXPRESS_GOOGLE = 'useGooglePayExpress';
Expand Down
Loading
Loading