Skip to content

Commit

Permalink
Merge pull request #56 from p1fb/SW6-55-fix-prepayment-bug
Browse files Browse the repository at this point in the history
SW6-55: Fix Prepayment Implementation
  • Loading branch information
hreinberger authored Aug 28, 2020
2 parents 8f3b63b + e138b4b commit 43a40cc
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 7 deletions.
23 changes: 23 additions & 0 deletions src/Components/RequestBuilder/EpsRequestBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace PayonePayment\Components\RequestBuilder;

use PayonePayment\PaymentMethod\PayoneEps;
use PayonePayment\Struct\PaymentTransaction;
use Shopware\Core\Framework\Context;
use Symfony\Component\HttpFoundation\ParameterBag;

class EpsRequestBuilder extends AbstractRequestBuilder
{
public function supports(string $paymentMethodId): bool
{
return $paymentMethodId === PayoneEps::UUID;
}

public function getAdditionalRequestParameters(PaymentTransaction $transaction, Context $context, ParameterBag $parameterBag): array
{
return [];
}
}
23 changes: 23 additions & 0 deletions src/Components/RequestBuilder/IDealRequestBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace PayonePayment\Components\RequestBuilder;

use PayonePayment\PaymentMethod\PayoneIDeal;
use PayonePayment\Struct\PaymentTransaction;
use Shopware\Core\Framework\Context;
use Symfony\Component\HttpFoundation\ParameterBag;

class IDealRequestBuilder extends AbstractRequestBuilder
{
public function supports(string $paymentMethodId): bool
{
return $paymentMethodId === PayoneIDeal::UUID;
}

public function getAdditionalRequestParameters(PaymentTransaction $transaction, Context $context, ParameterBag $parameterBag): array
{
return [];
}
}
23 changes: 23 additions & 0 deletions src/Components/RequestBuilder/PaydirektRequestBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace PayonePayment\Components\RequestBuilder;

use PayonePayment\PaymentMethod\PayonePaydirekt;
use PayonePayment\Struct\PaymentTransaction;
use Shopware\Core\Framework\Context;
use Symfony\Component\HttpFoundation\ParameterBag;

class PaydirektRequestBuilder extends AbstractRequestBuilder
{
public function supports(string $paymentMethodId): bool
{
return $paymentMethodId === PayonePaydirekt::UUID;
}

public function getAdditionalRequestParameters(PaymentTransaction $transaction, Context $context, ParameterBag $parameterBag): array
{
return [];
}
}
23 changes: 23 additions & 0 deletions src/Components/RequestBuilder/PrepaymentRequestBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace PayonePayment\Components\RequestBuilder;

use PayonePayment\PaymentMethod\PayonePrepayment;
use PayonePayment\Struct\PaymentTransaction;
use Shopware\Core\Framework\Context;
use Symfony\Component\HttpFoundation\ParameterBag;

class PrepaymentRequestBuilder extends AbstractRequestBuilder
{
public function supports(string $paymentMethodId): bool
{
return $paymentMethodId === PayonePrepayment::UUID;
}

public function getAdditionalRequestParameters(PaymentTransaction $transaction, Context $context, ParameterBag $parameterBag): array
{
return [];
}
}
2 changes: 1 addition & 1 deletion src/DependencyInjection/handler/payment_handler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
<argument type="service" id="order_line_item.repository" />
<argument type="service" id="request_stack" />

<tag name="shopware.payment.method.async" />
<tag name="shopware.payment.method.sync" />
</service>

<service id="PayonePayment\PaymentHandler\PayonePaydirektPaymentHandler">
Expand Down
16 changes: 16 additions & 0 deletions src/DependencyInjection/handler/request_handler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,21 @@
<service id="PayonePayment\Components\RequestBuilder\SofortBankingRequestBuilder">
<tag name="payone_payment.request_handler" />
</service>

<service id="PayonePayment\Components\RequestBuilder\PrepaymentRequestBuilder">
<tag name="payone_payment.request_handler" />
</service>

<service id="PayonePayment\Components\RequestBuilder\PaydirektRequestBuilder">
<tag name="payone_payment.request_handler" />
</service>

<service id="PayonePayment\Components\RequestBuilder\IDealRequestBuilder">
<tag name="payone_payment.request_handler" />
</service>

<service id="PayonePayment\Components\RequestBuilder\EpsRequestBuilder">
<tag name="payone_payment.request_handler" />
</service>
</services>
</container>
1 change: 1 addition & 0 deletions src/Installer/PaymentMethodInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class PaymentMethodInstaller implements InstallerInterface
PayoneEps::class,
PayoneIDeal::class,
PayonePaydirekt::class,
PayonePrepayment::class,
];

/** @var PluginIdProvider */
Expand Down
6 changes: 5 additions & 1 deletion src/PaymentHandler/PayonePaypalPaymentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ public static function isCapturable(array $transactionData, array $customFields)
*/
public static function isRefundable(array $transactionData, array $customFields): bool
{
return strtolower($transactionData['txaction']) === TransactionStatusService::ACTION_CAPTURE && (float) $transactionData['receivable'] !== 0.0;
if (strtolower($transactionData['txaction']) === TransactionStatusService::ACTION_CAPTURE && (float) $transactionData['receivable'] !== 0.0) {
return true;
}

return strtolower($transactionData['txaction']) === TransactionStatusService::ACTION_PAID;
}
}
6 changes: 1 addition & 5 deletions src/PaymentHandler/PayonePrepaymentPaymentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ public static function isCapturable(array $transactionData, array $customFields)
*/
public static function isRefundable(array $transactionData, array $customFields): bool
{
if (strtolower($transactionData['txaction']) === TransactionStatusService::ACTION_CAPTURE && (float) $transactionData['receivable'] !== 0.0) {
return true;
}

return strtolower($transactionData['txaction']) === TransactionStatusService::ACTION_PAID;
return strtolower($transactionData['txaction']) === TransactionStatusService::ACTION_CAPTURE && (float) $transactionData['receivable'] !== 0.0;
}
}

0 comments on commit 43a40cc

Please sign in to comment.