@@ -29,9 +29,21 @@ protected function getTransactionId($transaction){
2929
3030 protected function processOrderRelatedInner (array $ order_info , $ transaction ){
3131 /* @var \Wallee\Sdk\Model\Transaction $transaction */
32- $ transaction_info = \Wallee \Entity \TransactionInfo::loadByOrderId ($ this ->registry , $ order_info ['order_id ' ]);
32+ $ transactionInfo = \Wallee \Entity \TransactionInfo::loadByOrderId ($ this ->registry , $ order_info ['order_id ' ]);
33+
34+ $ finalStates = [
35+ \Wallee \Sdk \Model \TransactionState::FAILED ,
36+ \Wallee \Sdk \Model \TransactionState::VOIDED ,
37+ \Wallee \Sdk \Model \TransactionState::DECLINE ,
38+ \Wallee \Sdk \Model \TransactionState::FULFILL
39+ ];
40+
3341 \WalleeHelper::instance ($ this ->registry )->ensurePaymentCode ($ order_info , $ transaction );
34- if ($ transaction ->getState () != $ transaction_info ->getState ()) {
42+
43+ $ transactionInfoState = strtoupper ($ transactionInfo ->getState ());
44+ if (!in_array ($ transactionInfoState , $ finalStates )) {
45+ \Wallee \Service \Transaction::instance ($ this ->registry )->updateTransactionInfo ($ transaction , $ order_info ['order_id ' ]);
46+
3547 switch ($ transaction ->getState ()) {
3648 case \Wallee \Sdk \Model \TransactionState::CONFIRMED :
3749 $ this ->processing ($ transaction , $ order_info );
@@ -49,7 +61,8 @@ protected function processOrderRelatedInner(array $order_info, $transaction){
4961 $ this ->failed ($ transaction , $ order_info );
5062 break ;
5163 case \Wallee \Sdk \Model \TransactionState::FULFILL :
52- if ($ transaction_info ->getState () != 'AUTHORIZED ' && $ transaction_info ->getState () != 'COMPLETED ' ) {
64+
65+ if (!in_array ($ transactionInfoState , ['AUTHORIZED ' , 'COMPLETED ' ])) {
5366 $ this ->authorize ($ transaction , $ order_info );
5467 }
5568 $ this ->fulfill ($ transaction , $ order_info );
@@ -65,8 +78,6 @@ protected function processOrderRelatedInner(array $order_info, $transaction){
6578 break ;
6679 }
6780 }
68-
69- \Wallee \Service \Transaction::instance ($ this ->registry )->updateTransactionInfo ($ transaction , $ order_info ['order_id ' ]);
7081 }
7182
7283 protected function processing (\Wallee \Sdk \Model \Transaction $ transaction , array $ order_info ){
0 commit comments