|
14 | 14 | use GuzzleHttp\Exception\GuzzleException; |
15 | 15 | use PayoneBundle\Model\AbstractDataProcessor; |
16 | 16 | use PayoneBundle\PayoneBundle; |
| 17 | +use PayoneBundle\Registry\CaptureQueueInterface; |
17 | 18 | use PayoneBundle\Registry\IRegistry; |
18 | 19 | use PayoneBundle\Registry\Registry; |
19 | 20 | use PayoneBundle\Service\ServerToServerServiceInterface; |
@@ -203,33 +204,35 @@ class BsPayone extends AbstractPayment implements \Pimcore\Bundle\EcommerceFrame |
203 | 204 | * @var ServerToServerServiceInterface |
204 | 205 | */ |
205 | 206 | private $serverService; |
| 207 | + /** |
| 208 | + * @var CaptureQueueInterface |
| 209 | + */ |
| 210 | + private $captureQueue; |
206 | 211 |
|
207 | 212 |
|
208 | 213 | /** |
209 | 214 | * BsPayone constructor. |
210 | 215 | * @param array $options |
211 | 216 | * @param EngineInterface $templatingEngine |
212 | | - * @param SessionInterface $session |
213 | | - * @param FormFactoryInterface $formFactory |
214 | 217 | * @param LoggerInterface $logger |
215 | 218 | * @param IRegistry $registry |
| 219 | + * @param CaptureQueueInterface $captureQueue |
216 | 220 | * @param ServerToServerServiceInterface $serverService |
217 | 221 | * @throws \Exception |
218 | 222 | */ |
219 | | - public function __construct(array $options, EngineInterface $templatingEngine, SessionInterface $session, FormFactoryInterface $formFactory, LoggerInterface $logger, IRegistry $registry, ServerToServerServiceInterface $serverService) |
| 223 | + public function __construct(array $options, EngineInterface $templatingEngine, LoggerInterface $logger, IRegistry $registry, CaptureQueueInterface $captureQueue, ServerToServerServiceInterface $serverService) |
220 | 224 | { |
221 | | - $this->formFactory = $formFactory; |
222 | 225 |
|
223 | 226 | $this->processOptions( |
224 | 227 | $this->configureOptions(new OptionsResolver())->resolve($options) |
225 | 228 | ); |
226 | 229 | $this->templatingEngine = $templatingEngine; |
227 | | - $this->session = $session; |
228 | 230 | $this->mode = getenv('PAYONE_MODE'); |
229 | 231 |
|
230 | 232 | $this->logger = $logger; |
231 | 233 | $this->registry = $registry; |
232 | 234 | $this->serverService = $serverService; |
| 235 | + $this->captureQueue = $captureQueue; |
233 | 236 | } |
234 | 237 |
|
235 | 238 | /** |
@@ -657,26 +660,17 @@ public function getInitPaymentRedirectUrl($config) |
657 | 660 |
|
658 | 661 | $redirectURL = $result['redirecturl']; |
659 | 662 |
|
660 | | - if ($result['status'] == "APPROVED") { |
661 | | - |
662 | | - |
663 | | - if ($paymentType == self::METHOD_INVOICE || $paymentType == self::METHOD_PREPAYMENT) { |
| 663 | + if ( $paymentType == self::METHOD_PREPAYMENT) { |
| 664 | + if ($result['status'] == "APPROVED") { |
664 | 665 | //commit the order already |
665 | 666 | $checkoutManager = Factory::getInstance()->getCheckoutManager($cart); |
666 | 667 | $checkoutManager->handlePaymentResponseAndCommitOrderPayment($result); |
667 | 668 |
|
668 | 669 | //change redirect to checkout complete |
669 | 670 | $result['redirecturl'] = $config['completedURL']; |
670 | 671 | $result['status'] = 'REDIRECT'; |
| 672 | + $redirectURL = $result['redirecturl']; |
671 | 673 | } |
672 | | - |
673 | | - /* |
674 | | - $redirectURL = $result['redirecturl']; |
675 | | - if($paymentType == "PREPAYMENT"){ |
676 | | - $result['poll'] = $config['pollingURL']."?ref=". $result['reference']; |
677 | | - } |
678 | | - */ |
679 | | - |
680 | 674 | } |
681 | 675 |
|
682 | 676 | if (!$redirectURL) { |
@@ -980,6 +974,9 @@ public function handleResponse($response) |
980 | 974 | $paymentStatus = StatusInterface::STATUS_AUTHORIZED; |
981 | 975 | } else if ($response['reference'] !== null && (($response['txaction'] == 'paid'))) { |
982 | 976 | $paymentStatus = StatusInterface::STATUS_CLEARED; |
| 977 | + // resolve capture |
| 978 | + $this->captureQueue->resolveCapture($response['txid']); |
| 979 | + |
983 | 980 | } |
984 | 981 |
|
985 | 982 | $status = new Status( |
|
0 commit comments