2020use Pimcore \Bundle \EcommerceFrameworkBundle \CartManager \Cart ;
2121use Pimcore \Bundle \EcommerceFrameworkBundle \CartManager \ICart ;
2222use Pimcore \Bundle \EcommerceFrameworkBundle \Factory ;
23+ use Pimcore \Bundle \EcommerceFrameworkBundle \Model \AbstractOrder ;
2324use Pimcore \Bundle \EcommerceFrameworkBundle \Model \AbstractPaymentInformation ;
2425use Pimcore \Bundle \EcommerceFrameworkBundle \Model \Currency ;
2526use Pimcore \Bundle \EcommerceFrameworkBundle \OrderManager \OrderAgentInterface ;
26- use Pimcore \Bundle \EcommerceFrameworkBundle \PaymentManager \IStatus ;
2727use Pimcore \Bundle \EcommerceFrameworkBundle \PaymentManager \Payment \AbstractPayment ;
2828use Pimcore \Bundle \EcommerceFrameworkBundle \PaymentManager \Status ;
29+ use Pimcore \Bundle \EcommerceFrameworkBundle \PaymentManager \StatusInterface ;
2930use Pimcore \Bundle \EcommerceFrameworkBundle \PaymentManager \V7 \Payment \StartPaymentRequest \AbstractRequest ;
3031use Pimcore \Bundle \EcommerceFrameworkBundle \PaymentManager \V7 \Payment \StartPaymentResponse \SnippetResponse ;
3132use Pimcore \Bundle \EcommerceFrameworkBundle \PaymentManager \V7 \Payment \StartPaymentResponse \StartPaymentResponseInterface ;
@@ -888,7 +889,7 @@ private function setupPostParametersFor($paymentType, $cart, $orderIdent, $confi
888889 /**
889890 * @param mixed $response
890891 *
891- * @return IStatus
892+ * @return StatusInterface
892893 *
893894 * @throws \Exception
894895 */
@@ -931,7 +932,7 @@ public function handleResponse($response)
931932 $ orderIdent ,
932933 $ response ['reference ' ],
933934 $ response ['errormessage ' ],
934- IStatus ::STATUS_CANCELLED ,
935+ StatusInterface ::STATUS_CANCELLED ,
935936 [
936937 'response ' => json_encode ($ response )
937938 ]
@@ -943,10 +944,10 @@ public function handleResponse($response)
943944 return $ status ;
944945 }
945946
946- $ paymentStatus = IStatus ::STATUS_CANCELLED ;
947+ $ paymentStatus = StatusInterface ::STATUS_CANCELLED ;
947948
948949 //this will throw an exception if there is no such entry in the DB!
949- $ logData = $ this ->registry ->findTranslationLogsForPayoneReference ($ response ['reference ' ]);
950+ $ logData = $ this ->registry ->findTransactionLogsForPayoneReference ($ response ['reference ' ]);
950951
951952 $ response ['clearingtype ' ] = $ logData [Registry::COLUMN_METHOD ];
952953
@@ -961,9 +962,12 @@ public function handleResponse($response)
961962
962963 $ price = new Price (Decimal::create ($ authorizedData ['price ' ]), new Currency ($ authorizedData ['currency ' ]));
963964
965+ $ this ->registry ->logTransaction ($ response ['reference ' ], $ response ['txid ' ],$ response ['txaction ' ], $ response );
964966
965- if ($ response ['reference ' ] !== null && (($ response ['txaction ' ] == 'appointed ' ) || ($ response ['txaction ' ] == 'paid ' ))) {
966- $ paymentStatus = IStatus::STATUS_CLEARED ;
967+ if ($ response ['reference ' ] !== null && (($ response ['txaction ' ] == 'appointed ' ) )) {
968+ $ paymentStatus = StatusInterface::STATUS_AUTHORIZED ;
969+ }else if ($ response ['reference ' ] !== null && (($ response ['txaction ' ] == 'paid ' ))) {
970+ $ paymentStatus = StatusInterface::STATUS_CLEARED ;
967971 }
968972
969973 $ status = new Status (
@@ -992,7 +996,7 @@ public function handleResponse($response)
992996
993997
994998 if ($ orderIdent !== null && (($ response ['status ' ] == 'APPROVED ' ))) {
995- $ paymentStatus = IStatus ::STATUS_AUTHORIZED ;
999+ $ paymentStatus = StatusInterface ::STATUS_AUTHORIZED ;
9961000 $ authorizedData = array_intersect_key ($ response , $ authorizedData );
9971001 $ authorizedData ['response ' ] = var_export ($ response , true );
9981002
@@ -1001,7 +1005,11 @@ public function handleResponse($response)
10011005
10021006 $ this ->setAuthorizedData ($ authorizedData );
10031007 }
1004-
1008+ else {
1009+ // failed
1010+ $ paymentStatus = AbstractOrder::ORDER_STATE_ABORTED ;
1011+ $ message = $ response ['errorDetail ' ];
1012+ }
10051013
10061014 $ status = new Status (
10071015 $ orderIdent ,
@@ -1012,7 +1020,6 @@ public function handleResponse($response)
10121020 'userId ' => $ response ['userid ' ],
10131021 'txid ' => $ response ['txid ' ],
10141022 'response ' => print_r ($ response , true ),
1015-
10161023 ]
10171024 );
10181025
@@ -1047,7 +1054,7 @@ public function setAuthorizedData(array $authorizedData)
10471054 * @param IPrice $price
10481055 * @param string $reference
10491056 *
1050- * @return IStatus
1057+ * @return StatusInterface
10511058 */
10521059 public function executeDebit (PriceInterface $ price = null , $ reference = null )
10531060 {
@@ -1061,7 +1068,7 @@ public function executeDebit(PriceInterface $price = null, $reference = null)
10611068 * @param string $reference
10621069 * @param $transactionId
10631070 *
1064- * @return IStatus
1071+ * @return StatusInterface
10651072 */
10661073 public function executeCredit (PriceInterface $ price , $ reference , $ transactionId )
10671074 {
0 commit comments