Skip to content

Commit 6023c7c

Browse files
author
Fabian Pechstein
committed
[bug-fix] resolve Captures differently
1 parent 54d7d9b commit 6023c7c

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/PayoneBundle/Ecommerce/PaymentManager/BsPayone.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class BsPayone extends AbstractPayment implements \Pimcore\Bundle\EcommerceFrame
208208
* @param ServerToServerServiceInterface $serverService
209209
* @throws \Exception
210210
*/
211-
public function __construct(array $options, EngineInterface $templatingEngine, LoggerInterface $logger, IRegistry $registry, ServerToServerServiceInterface $serverService)
211+
public function __construct(array $options, EngineInterface $templatingEngine, LoggerInterface $logger, IRegistry $registry, ServerToServerServiceInterface $serverService, CaptureQueueInterface $captureQueue)
212212
{
213213

214214
$this->processOptions(
@@ -220,6 +220,7 @@ public function __construct(array $options, EngineInterface $templatingEngine, L
220220
$this->logger = $logger;
221221
$this->registry = $registry;
222222
$this->serverService = $serverService;
223+
$this->captureQueue = $captureQueue;
223224
}
224225

225226
/**
@@ -963,7 +964,7 @@ public function handleResponse($response)
963964
} else if ($response['reference'] !== null && (($response['txaction'] == 'paid'))) {
964965
$paymentStatus = StatusInterface::STATUS_CLEARED;
965966
// resolve capture
966-
//$this->captureQueue->resolveCapture($response['txid']);
967+
$this->captureQueue->resolveCapture($response['txid'], $this);
967968
} else if ($response['reference'] !== null && (($response['txaction'] == 'capture'))) {
968969
$paymentStatus = StatusInterface::STATUS_CLEARED;
969970
} else if ($response['reference'] !== null && (($response['txaction'] == 'cancelation'))) {

src/PayoneBundle/Registry/CaptureHandler.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ public function addCapture(string $txid,string $reference,string $amount,strin
7676

7777
/**
7878
* @param $txid
79+
* @param BsPayone $payone
80+
* @return mixed
81+
*
7982
* @throws \GuzzleHttp\Exception\GuzzleException
8083
*/
81-
public function resolveCapture($txid)
84+
public function resolveCapture($txid, BsPayone $payone)
8285
{
8386

84-
$this->payone = Factory::getInstance()->getPaymentManager()->getProvider('bspayone');
8587
$db = Db::get();
8688
$result = $db->fetchRow(
8789
"SELECT * FROM " . self::LOG_TABLE_NAME . " WHERE `" . self::COLUMN_TXID . "` = ?",
@@ -93,7 +95,7 @@ public function resolveCapture($txid)
9395
Lock::acquire(self::LOG_LOCK_KEY);
9496
$now = CarbonImmutable::now();
9597
//build request and send it! updated processed to current timestamp
96-
$params = $this->payone->buildCaptureRequest($txid, $result[self::COLUMN_AMOUNT], $result[self::COLUMN_CURRENCY], json_decode($result[self::COLUMN_DATA], true));
98+
$params = $payone->buildCaptureRequest($txid, $result[self::COLUMN_AMOUNT], $result[self::COLUMN_CURRENCY], json_decode($result[self::COLUMN_DATA], true));
9799
$this->serverService->serverToServerRequest($params);
98100

99101
$db->updateWhere(self::LOG_TABLE_NAME, [self::COLUMN_PROCESSED=> $now ], "id = ". $result['id'] );

src/PayoneBundle/Registry/CaptureQueueInterface.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
namespace PayoneBundle\Registry;
1212

1313

14+
use PayoneBundle\Ecommerce\PaymentManager\BsPayone;
15+
use Pimcore\Bundle\EcommerceFrameworkBundle\PaymentManager\PaymentManagerInterface;
16+
1417
interface CaptureQueueInterface
1518
{
1619

@@ -25,8 +28,9 @@ public function addCapture(string $txid,string $reference,string $amount,strin
2528

2629
/**
2730
* @param $txid
31+
* @param BsPayone $payone
2832
* @return mixed
2933
*/
30-
public function resolveCapture($txid);
34+
public function resolveCapture($txid, BsPayone $payone);
3135

3236
}

src/PayoneBundle/Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525
$options: []
2626
$templatingEngine: '@templating.engine.delegating'
2727
$serverService: '@PayoneBundle\Service\ServerToServerServiceInterface'
28-
# $captureQueue: '@PayoneBundle\Registry\CaptureQueueInterface'
28+
$captureQueue: '@PayoneBundle\Registry\CaptureQueueInterface'
2929

3030

3131
# The migration installer needs the bundle it is operating on upon construction to be able to build its migration configuration.

0 commit comments

Comments
 (0)