diff --git a/Frontend/MoptPaymentPayone/Components/Classes/PayoneConfig.php b/Frontend/MoptPaymentPayone/Components/Classes/PayoneConfig.php index 6ecc7a13..2dede057 100755 --- a/Frontend/MoptPaymentPayone/Components/Classes/PayoneConfig.php +++ b/Frontend/MoptPaymentPayone/Components/Classes/PayoneConfig.php @@ -62,6 +62,8 @@ class Mopt_PayoneConfig 'mopt_payone__ibt_bancontact', 'mopt_payone__ewallet_amazon_pay', 'mopt_payone__ewallet_alipay', + 'mopt_payone__ibt_trustly', + 'mopt_payone__ewallet_wechatpay', ]; const PAYMENTS_ADDRESSCHECK_EXCLUDED = [ @@ -105,6 +107,8 @@ class Mopt_PayoneConfig 'mopt_payone__acc_payone_safe_invoice', 'mopt_payone__ibt_bancontact', 'mopt_payone__ewallet_alipay', + 'mopt_payone__ibt_trustly', + 'mopt_payone__ewallet_wechatpay', ]; const PAYMENTS_EXCLUDED_FROM_ACCOUNTPAGE = [ @@ -121,6 +125,13 @@ class Mopt_PayoneConfig 'mopt_payone_klarna', ]; + const PAYMENTS_DONOTSENDCAPTUREMODE = [ + 'mopt_payone__acc_payone_safe_invoice', + 'mopt_payone__ewallet_alipay', + 'mopt_payone__ibt_trustly', + 'mopt_payone__ewallet_wechatpay', + ]; + /** * return array with configured valid IPs to accept transaction feedback from * diff --git a/Frontend/MoptPaymentPayone/Components/Payone/Api/Request/Abstract.php b/Frontend/MoptPaymentPayone/Components/Payone/Api/Request/Abstract.php index e6d0d012..b52c64af 100755 --- a/Frontend/MoptPaymentPayone/Components/Payone/Api/Request/Abstract.php +++ b/Frontend/MoptPaymentPayone/Components/Payone/Api/Request/Abstract.php @@ -137,6 +137,9 @@ public function toArray() * @var Payone_Api_Request_Parameter_Interface $data */ $result = array_merge($result, $data->toArray()); + if (empty($result['capturemode'])) { + unset($result['capturemode']); + } } elseif ($data instanceof Payone_Protocol_Service_ApplyFilters == false) { $result[$key] = $data; } diff --git a/Frontend/MoptPaymentPayone/Controllers/Backend/MoptPayoneOrder.php b/Frontend/MoptPaymentPayone/Controllers/Backend/MoptPayoneOrder.php index bd6a294d..a96340f0 100755 --- a/Frontend/MoptPaymentPayone/Controllers/Backend/MoptPayoneOrder.php +++ b/Frontend/MoptPaymentPayone/Controllers/Backend/MoptPayoneOrder.php @@ -107,6 +107,9 @@ public function moptPayoneCaptureOrderAction() $payment = $order->getPayment(); $paymentName = $payment->getName(); + // remove _1 ,_2 ... from duplicated payments before matching + $cleanedPaymentName = preg_replace('/_[0-9]*$/', '', $paymentName); + if ($request->getParam('includeShipment') === 'true') { $includeShipment = true; } else { @@ -138,8 +141,12 @@ public function moptPayoneCaptureOrderAction() if ($this->moptPayone__main->getPaymentHelper()->isPayoneSafeInvoice($paymentName)){ $autoSettleAccount = true; + } + + if (in_array( $cleanedPaymentName,\Mopt_PayoneConfig::PAYMENTS_DONOTSENDCAPTUREMODE)) { $doNotSendCaptureMode = true; } + $response = $this->moptPayone_callCaptureService($params, $invoicing, $autoSettleAccount, $doNotSendCaptureMode); if ($response->getStatus() == Payone_Api_Enum_ResponseType::APPROVED) { diff --git a/Frontend/MoptPaymentPayone/Controllers/Frontend/MoptShopNotification.php b/Frontend/MoptPaymentPayone/Controllers/Frontend/MoptShopNotification.php index fb4704a2..831ebb00 100755 --- a/Frontend/MoptPaymentPayone/Controllers/Frontend/MoptShopNotification.php +++ b/Frontend/MoptPaymentPayone/Controllers/Frontend/MoptShopNotification.php @@ -78,14 +78,18 @@ public function indexAction() $request = $this->Request(); $this->logger->debug('notification controller called'); - + if (!$request->isPost()) { $this->redirect(array('controller' => 'index', 'action' => 'error')); return; } + $this->logger->debug('received $_POST:' . PHP_EOL . var_export($_POST, true) . PHP_EOL); + $rawPost = $_POST; - $_POST = array_map('utf8_encode', $_POST); // utf8 encode all post params to avoid encoding issues + + $_POST = $this->utf8_encode_array($_POST); + $this->logger->debug('successfully converted $_POST to utf-8:' . PHP_EOL . var_export($_POST, true) . PHP_EOL); $request->setParamSources(array('_POST')); // only retrieve data from POST $this->CheckAndFixActiveShopIfNeeded($request->getParam('param')); @@ -129,7 +133,7 @@ public function indexAction() $validators = $service->getValidators(); foreach ($validators as $validator) { if ($validator instanceof Payone_TransactionStatus_Validator_Ip) { - $validator->getConfig()->setValue('validator/proxy/enabled',1); + $validator->getConfig()->setValue('validator/proxy/enabled', 1); } } @@ -168,7 +172,7 @@ public function indexAction() $this->logger->debug('finished, output TSOK'); echo $response->getStatus(); $this->logger->debug('starting tx forwards'); - $this->moptPayoneForwardTransactionStatus($rawPost, $paymentId); + $this->moptPayoneForwardTransactionStatus($_POST, $paymentId); $this->logger->debug('finished all tasks, exit'); exit; } @@ -220,7 +224,7 @@ public function indexAction() $this->savePaymentStatus($transactionId, $order['temporaryID'], $mappedShopwareState); } - } elseif ($request->getParam('txaction') === 'reminder' && $request->getParam('reminderlevel') === '0') { + } elseif ($request->getParam('txaction') === 'reminder' && $request->getParam('reminderlevel') === '0') { // ignore txaction reminder with reminderlevel 0 since this only marks the end of dunning process } else { // ! Amazonpay @@ -241,7 +245,7 @@ public function indexAction() $this->logger->debug('finished, output TSOK'); echo $response->getStatus(); $this->logger->debug('starting tx forwards'); - $this->moptPayoneForwardTransactionStatus($rawPost, $paymentId); + $this->moptPayoneForwardTransactionStatus($_POST, $paymentId); // fire event to do some custom stuff, e.g. synchronising with merchandise management software // please note that processing this event has to be fast because Payone will mark this request as @@ -286,8 +290,6 @@ protected function moptPayoneInitTransactionService($key, $validIps) */ protected function moptPayoneForwardTransactionStatus($post, $paymentID) { - $post = array_map('utf8_encode', $post); // utf8 encode all post params to avoid encoding issues - $post['paymentID'] = $paymentID; $queueWorker = new Mopt_PayoneTransactionForwardingQueueWorker(); @@ -453,7 +455,7 @@ protected function saveOrderAttributeData($order, $attributeData, $saveOrderHash ); $sql = 'UPDATE s_order_attributes SET mopt_payone_status=?, mopt_payone_sequencenumber=?, ' - . 'mopt_payone_payment_reference=? '; + . 'mopt_payone_payment_reference=? '; if ($saveOrderHash) { $sql = $sql . ' , mopt_payone_order_hash=? '; @@ -488,7 +490,7 @@ protected function CheckAndFixActiveShopIfNeeded($customParam) $shopRepository = Shopware()->Models()->getRepository('Shopware\Models\Shop\Shop'); $shop = $shopRepository->getActiveById($shopId); $shop->registerResources(Shopware()->Bootstrap()); - + $this->logger->info( 'different shop active, submitted id, new shopid', array($activeShopId, $shopId, Shopware()->Shop()->getId()) @@ -525,6 +527,24 @@ protected function clearingDataExists($order) protected function buildPayoneTransactionLogPath() { $logDir = Shopware()->Container()->get('kernel')->getLogDir(); - return $logDir . '/moptPayoneTransactionStatus.log'; + return $logDir . '/moptPayoneTransactionStatus.log'; } + + /** + * converts multi dimensional arrays to utf8 + * @param $array + * @return mixed + */ + private function utf8_encode_array($array) + { + foreach ($array as $key => $value) { + if (is_array($value)) { + $array[$key] = $this->utf8_encode_array($value); + } else { + $array[$key] = utf8_encode($value); + } + } + return $array; + } + }