diff --git a/.gitmodules b/.gitmodules
index 5022b37..c1207ff 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
-[submodule "src/engine/Library/paymentwall"]
- path = src/engine/Library/paymentwall
- url = git@github.com:paymentwall/paymentwall-php.git
+[submodule "src/Paymentwall/Components/Libs/Paymentwall"]
+ path = src/Paymentwall/Components/Libs/Paymentwall
+ url = https://github.com/paymentwall/paymentwall-php.git
diff --git a/README.md b/README.md
index e595630..5a403ae 100644
--- a/README.md
+++ b/README.md
@@ -3,8 +3,8 @@ Paymentwall module for Shopware.
###Versions
-* Tested on Shopware 5.3.5
-* PHP 5.3 or later
+* Tested on Shopware 5.3.5, 5.6.9
+* PHP 7.2 or later
#Installation
To install Paymentwall Shopware module, please follow the [instructions](https://docs.paymentwall.com/modules/shopware).
diff --git a/src/Paymentwall/Components/Libs/Paymentwall b/src/Paymentwall/Components/Libs/Paymentwall
new file mode 160000
index 0000000..040cbd3
--- /dev/null
+++ b/src/Paymentwall/Components/Libs/Paymentwall
@@ -0,0 +1 @@
+Subproject commit 040cbd3aecafe25af35568590f78b6cef4b72015
diff --git a/src/Paymentwall/Components/Services/DeliveryConfirmationService.php b/src/Paymentwall/Components/Services/DeliveryConfirmationService.php
new file mode 100644
index 0000000..1423016
--- /dev/null
+++ b/src/Paymentwall/Components/Services/DeliveryConfirmationService.php
@@ -0,0 +1,65 @@
+getShipping();
+ $data = [
+ 'payment_id' => $order->getTransactionId(),
+ 'merchant_reference_id' => $order->getId(),
+ 'type' => ($order->getEsd()) ? self::PRODUCT_DIGITAL : self::PRODUCT_PHYSICAL,
+ 'status' => $status,
+ 'estimated_delivery_datetime' => date('Y/m/d H:i:s'),
+ 'estimated_update_datetime' => date('Y/m/d H:i:s'),
+ 'refundable' => 'yes',
+ 'details' => 'Order status has been updated on ' . date('Y/m/d H:i:s'),
+ 'product_description' => '',
+ 'shipping_address[country]' => $shipping->getCountry()->getIso(),
+ 'shipping_address[city]' => $shipping->getCountry(),
+ 'shipping_address[zip]' => $shipping->getZipCode(),
+ 'shipping_address[state]' => !empty($shipping->getState()) ? $shipping->getState() : 'N/A',
+ 'shipping_address[street]' => $shipping->getStreet(),
+ 'shipping_address[phone]' => !empty($shipping->getPhone()) ? $shipping->getPhone() : 'N/A',
+ 'shipping_address[firstname]' => $shipping->getFirstName(),
+ 'shipping_address[lastname]' => $shipping->getLastName(),
+ 'shipping_address[email]' => $order->getCustomer()->getEmail(),
+ 'reason' => 'none',
+ 'attachments' => null,
+ 'is_test' => PaymentwallSettings::getTestMode(),
+ ];
+
+ if (!empty($trackingData)) {
+ return array_merge($data, $trackingData);
+ }
+ return $data;
+ }
+
+ public function sendDeliveryData($dataPrepared)
+ {
+ if (empty($dataPrepared)) {
+ return;
+ }
+
+ $delivery = new Paymentwall_GenerericApiObject('delivery');
+ $delivery->post($dataPrepared);
+ }
+}
diff --git a/src/Paymentwall/Components/Services/OrderService.php b/src/Paymentwall/Components/Services/OrderService.php
new file mode 100644
index 0000000..ff79352
--- /dev/null
+++ b/src/Paymentwall/Components/Services/OrderService.php
@@ -0,0 +1,103 @@
+connection = $connection;
+ }
+
+ public function setOrderStatus($orderId, $orderStatusId)
+ {
+ return $this->connection->createQueryBuilder()
+ ->update('s_order')
+ ->set('status', ':orderStatusId')
+ ->where('id = :orderId')
+ ->setParameters([
+ ':orderId' => $orderId,
+ ':orderStatusId' => $orderStatusId,
+ ])
+ ->execute();
+ }
+
+ public function getOrderStatus($orderId)
+ {
+ return $this->connection->createQueryBuilder()
+ ->select('status')
+ ->from('s_order')
+ ->where('id = :orderId')
+ ->setParameters([
+ ':orderId' => $orderId
+ ])
+ ->execute()
+ ->fetchColumn();
+ }
+
+ public function isOrderHistoryEmpty($orderId)
+ {
+ return !$this->connection->createQueryBuilder()
+ ->select('id')
+ ->from('s_order_history')
+ ->where('orderId = :orderId')
+ ->setParameters([
+ ':orderId' => $orderId,
+ ])
+ ->execute()
+ ->fetchColumn();
+ }
+
+ public function updateTransactionId($transactionId, $orderId)
+ {
+ return $this->connection->createQueryBuilder()
+ ->update('s_order')
+ ->set('transactionID', ':transactionId')
+ ->where('id = :orderId')
+ ->setParameters([
+ ':orderId' => $orderId,
+ ':transactionId' => $transactionId,
+ ])
+ ->execute();
+ }
+
+ public function getPaymentIdByOrderId($orderId)
+ {
+ return $this->connection->createQueryBuilder()
+ ->select('paymentID')
+ ->from('s_order')
+ ->where('id = :orderId')
+ ->setParameters([
+ ':orderId' => $orderId,
+ ])
+ ->execute()
+ ->fetchColumn();
+ }
+
+ public function loadOrderRepositoryById($orderId)
+ {
+ $repository = Shopware()->Models()->getRepository(Order::class);
+ return $repository->find($orderId);
+ }
+
+ public function checkOrderWasPaid($orderId)
+ {
+ return $this->connection->createQueryBuilder()
+ ->select('id')
+ ->from('s_order_history')
+ ->where('orderId = :orderId')
+ ->andWhere('payment_status_id = :payment_status_id')
+ ->setParameters([
+ ':orderId' => $orderId,
+ ':payment_status_id' => Status::PAYMENT_STATE_COMPLETELY_PAID
+ ])
+ ->execute()
+ ->fetchColumn();
+ }
+}
diff --git a/src/Paymentwall/Components/Services/PaymentService.php b/src/Paymentwall/Components/Services/PaymentService.php
new file mode 100644
index 0000000..669275c
--- /dev/null
+++ b/src/Paymentwall/Components/Services/PaymentService.php
@@ -0,0 +1,51 @@
+Container()->get('session');
+ $selectedPaymentMethod = $session->offsetGet('paymentwall-localpayment');
+
+ return new Paymentwall_Widget(
+ !empty($user['userID']) ? $user['userID'] : $user['email'],
+ PaymentwallSettings::getWidgetCode(),
+ [
+ new Paymentwall_Product(
+ $orderId,
+ $totalAmount,
+ $currencyCode,
+ Paymentwall_Product::TYPE_FIXED
+ )
+ ],
+ [
+ 'integration_module' => 'shopware',
+ 'ps' => !empty($selectedPaymentMethod['id']) ? $selectedPaymentMethod['id'] : 'all',
+ 'test_mode' => PaymentwallSettings::getTestMode(),
+ 'success_url' => $this->getSuccessUrl()
+ ]
+ );
+ }
+
+ protected function getSuccessUrl()
+ {
+ $router = Shopware()->Front()->Router();
+ return $router->assemble(['controller' => 'Paymentwall', 'action' => 'success']);
+ }
+
+ public function getOrderIdByPaymentUniqueId($paymentUniqueId)
+ {
+ $repository = Shopware()->Models()->getRepository(Order::class);
+ $order = $repository->findOneBy([
+ 'temporaryId' => $paymentUniqueId,
+ 'transactionId' => $paymentUniqueId
+ ]);
+ return $order->getId();
+ }
+}
diff --git a/src/Paymentwall/Components/Services/PaymentSystemService.php b/src/Paymentwall/Components/Services/PaymentSystemService.php
new file mode 100644
index 0000000..031dcea
--- /dev/null
+++ b/src/Paymentwall/Components/Services/PaymentSystemService.php
@@ -0,0 +1,67 @@
+getPaymentMethodFromApi($userCountry);
+ $localPaymentMethods = $this->prepareLocalPayment($response);
+ }
+ return $localPaymentMethods;
+ }
+
+ protected function getPaymentMethodFromApi($userCountry)
+ {
+ if (empty($userCountry)) {
+ return null;
+ }
+
+ $params = array(
+ 'key' => PaymentwallSettings::getProjectKey(),
+ 'country_code' => $userCountry,
+ 'sign_version' => 3,
+ 'currencyCode' => Shopware()->Container()->get('currency')->getShortName(),
+ );
+
+ $params['sign'] = (new Paymentwall_Signature_Widget())->calculate(
+ $params,
+ $params['sign_version']
+ );
+
+ $url = Paymentwall_Config::API_BASE_URL . '/payment-systems/?' . http_build_query($params);
+ $curl = curl_init($url);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ $response = curl_exec($curl);
+ if (curl_error($curl)) {
+ return null;
+ }
+
+ return json_decode($response, true);
+ }
+
+ protected function prepareLocalPayment($payments)
+ {
+ $methods = [];
+ if (!empty($payments)) {
+ foreach ($payments as $payment) {
+ if (!empty($payment['id']) && !empty($payment['name'])) {
+ $methods[] = [
+ 'id' => $payment['id'],
+ 'name' => $payment['name'],
+ 'img_url' => !empty($payment['img_url']) ? $payment['img_url'] : ''
+ ];
+ }
+ }
+ }
+ return $methods;
+ }
+}
diff --git a/src/Paymentwall/Components/Services/PaymentwallSettings.php b/src/Paymentwall/Components/Services/PaymentwallSettings.php
new file mode 100644
index 0000000..723a9b6
--- /dev/null
+++ b/src/Paymentwall/Components/Services/PaymentwallSettings.php
@@ -0,0 +1,47 @@
+Container()->get('shopware.plugin.cached_config_reader')->getByPluginName('paymentwall');
+ }
+
+ public static function getTestMode()
+ {
+ $config = self::getConfig();
+ return $config['pwTestMode'];
+ }
+
+ public static function getWidgetCode()
+ {
+ $config = self::getConfig();
+ return $config['pwWidget'];
+ }
+
+ public static function getProjectKey()
+ {
+ $config = self::getConfig();
+ return $config['pwProjectKey'];
+ }
+
+ public static function getSecretKey()
+ {
+ $config = self::getConfig();
+ return $config['pwWipwSecretKey'];
+ }
+
+ public static function getRefundState()
+ {
+ $config = self::getConfig();
+ return $config['pwRefundState'];
+ }
+
+ public static function getRedirectPayment()
+ {
+ $config = self::getConfig();
+ return $config['pwRedirectPayment'];
+ }
+}
diff --git a/src/Paymentwall/Components/Services/PingbackService.php b/src/Paymentwall/Components/Services/PingbackService.php
new file mode 100644
index 0000000..6d5464e
--- /dev/null
+++ b/src/Paymentwall/Components/Services/PingbackService.php
@@ -0,0 +1,45 @@
+pingback = new Paymentwall_Pingback($pingbackParams, $ipAddress);
+ }
+
+ public function verifyPingback()
+ {
+ if ($this->pingback->validate(true)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public function isPingbackCancelable()
+ {
+ return $this->pingback->isCancelable();
+ }
+
+ public function isPingbackDeliverable()
+ {
+ return $this->pingback->isDeliverable();
+ }
+
+ public function isPingbackUnderReview()
+ {
+ return $this->pingback->isUnderReview();
+ }
+
+ public function getErrorSummary()
+ {
+ return $this->pingback->getErrorSummary();
+ }
+}
diff --git a/src/Paymentwall/Components/Services/RefundService.php b/src/Paymentwall/Components/Services/RefundService.php
new file mode 100644
index 0000000..cb01b59
--- /dev/null
+++ b/src/Paymentwall/Components/Services/RefundService.php
@@ -0,0 +1,33 @@
+ PaymentwallSettings::getProjectKey(),
+ 'ref' => $ref,
+ 'uid' => $uid,
+ 'sign_version' => 3,
+ 'type' => self::TYPE_FULL_REFUND,
+ 'message' => 'Shopware: website ' . strtoupper($host) . ' request full refund',
+ 'test_mode' => (int)PaymentwallSettings::getTestMode(),
+ ];
+
+ $params['sign'] = (new Paymentwall_Signature_Widget())->calculate($params, $params['sign_version']);
+ return $params;
+ }
+
+ public function sendCancellation($dataPrepared)
+ {
+ $delivery = new Paymentwall_GenerericApiObject('ticket');
+ return $delivery->post($dataPrepared);
+ }
+}
diff --git a/src/Paymentwall/Components/Services/UtilService.php b/src/Paymentwall/Components/Services/UtilService.php
new file mode 100644
index 0000000..750ed68
--- /dev/null
+++ b/src/Paymentwall/Components/Services/UtilService.php
@@ -0,0 +1,82 @@
+ PaymentwallSettings::getProjectKey(),
+ 'uid' => self::USER_ID_GEOLOCATION,
+ 'user_ip' => $ip
+ );
+
+ $url = Paymentwall_Config::API_BASE_URL . '/rest/country?' . http_build_query($params);
+ $curl = curl_init($url);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ $response = curl_exec($curl);
+
+ if (curl_error($curl)) {
+ return null;
+ }
+ $response = json_decode($response, true);
+
+ if (!empty($response['code'])) {
+ return $response['code'];
+ }
+ }
+ return null;
+ }
+
+ public static function getPaymentMethodActiveFlag()
+ {
+ /** @var Connection $connection */
+ $connection = Shopware()->Container()->get('dbal_connection');
+
+ return (bool) $connection->fetchColumn(
+ 'SELECT active FROM s_core_paymentmeans WHERE name = :paymentName',
+ [':paymentName' => Paymentwall::PAYMENT_NAME]
+ );
+ }
+
+ public static function getPaymentwallPaymentId()
+ {
+ /** @var Connection $connection */
+ $connection = Shopware()->Container()->get('dbal_connection');
+
+ return (int) $connection->fetchColumn(
+ 'SELECT id FROM s_core_paymentmeans WHERE name = :paymentName',
+ [':paymentName' => Paymentwall::PAYMENT_NAME,]
+ );
+ }
+}
diff --git a/src/Paymentwall/Controllers/Frontend/Paymentwall.php b/src/Paymentwall/Controllers/Frontend/Paymentwall.php
new file mode 100644
index 0000000..ab4f30b
--- /dev/null
+++ b/src/Paymentwall/Controllers/Frontend/Paymentwall.php
@@ -0,0 +1,109 @@
+get('kernel')->getPlugins()['Paymentwall'];
+ $this->get('template')->addTemplateDir($plugin->getPath() . '/Resources/views/');
+ $this->paymentService = $this->get('paymentwall.payment_service');
+ $this->orderService = $this->get('paymentwall.order_service');
+ $this->session = $this->get('session');
+ }
+
+ public function indexAction()
+ {
+ /**
+ * Check if one of the payment methods is selected. Else return to default controller.
+ */
+
+ if ($this->getPaymentShortName() == Paymentwall::PAYMENT_NAME) {
+ if (PaymentwallSettings::getRedirectPayment()) {
+ return $this->redirect(['action' => 'direct', 'forceSecure' => true]);
+ }
+ return $this->redirect(['action' => 'gateway', 'forceSecure' => true]);
+ }
+ return $this->redirect(['controller' => 'checkout']);
+ }
+
+ public function gatewayAction()
+ {
+ if (empty($this->getBasket())) {
+ $this->redirect(['controller' => 'index', 'action' => 'index']);
+ }
+
+ $this->View()->assign('gatewayUrl', $this->generateWidgetUrl());
+ }
+
+ public function directAction()
+ {
+ $providerUrl = $this->generateWidgetUrl();
+ if (!empty($providerUrl)) {
+ $this->redirect($providerUrl);
+ }
+ }
+
+ private function generateWidgetUrl()
+ {
+ $user = $this->getUser();
+ $orderId = $this->prepareTemporaryOrder();
+ $widget = $this->paymentService->prepareWidget($user['additional']['user'], $this->getAmount(), $this->getCurrencyShortName(), $orderId);
+ return $widget->getUrl();
+ }
+
+ private function prepareTemporaryOrder()
+ {
+ $orderId = $this->createOrder();
+ $this->session->offsetSet('paymentwall_neworderid', $orderId);
+
+ $this->orderService->setOrderStatus($orderId, Status::ORDER_STATE_CANCELLED);
+
+ if (!empty($orderId)) {
+ $this->clearBasketData();
+ }
+
+ return $orderId;
+ }
+
+ public function successAction()
+ {
+ try {
+ $orderId = $this->session->offsetGet('paymentwall_neworderid');
+ $currentStatus = $this->orderService->getOrderStatus($orderId);
+
+ if ($currentStatus == Status::ORDER_STATE_CANCELLED
+ && $this->orderService->isOrderHistoryEmpty($orderId)
+ ) {
+ $this->orderService->setOrderStatus($orderId, Status::ORDER_STATE_OPEN);
+ $this->session->offsetUnset('paymentwall_neworderid');
+ }
+ } catch (Exception $e) {
+
+ }
+ $this->redirect(['controller' => 'checkout', 'action' => 'finish']);
+ }
+
+ private function clearBasketData()
+ {
+ $this->session->offsetUnset('sBasketAmount');
+ $this->session->offsetUnset('sBasketQuantity');
+ }
+
+ private function createOrder()
+ {
+ $paymentUniqueId = $this->createPaymentUniqueId();
+ $this->saveOrder($paymentUniqueId, $paymentUniqueId, Status::PAYMENT_STATE_OPEN);
+ $orderId = $this->paymentService->getOrderIdByPaymentUniqueId($paymentUniqueId);
+
+ return $orderId;
+ }
+}
diff --git a/src/Paymentwall/Controllers/Frontend/PaymentwallPaymentSystem.php b/src/Paymentwall/Controllers/Frontend/PaymentwallPaymentSystem.php
new file mode 100644
index 0000000..06e8241
--- /dev/null
+++ b/src/Paymentwall/Controllers/Frontend/PaymentwallPaymentSystem.php
@@ -0,0 +1,19 @@
+Request()->isPost() && empty($this->Request()->getPost('psId'))) {
+ die;
+ }
+
+ $payment = [
+ 'id' => $this->Request()->getPost('psId'),
+ 'name' => !empty($this->Request()->getPost('psName')) ? $this->Request()->getPost('psName') : '',
+ ];
+ $session = $this->container->get('session');
+ $session->offsetSet('paymentwall-localpayment', $payment);
+ die($payment['id']);
+ }
+}
diff --git a/src/Paymentwall/Controllers/Frontend/PaymentwallPingback.php b/src/Paymentwall/Controllers/Frontend/PaymentwallPingback.php
new file mode 100644
index 0000000..2f1e0bb
--- /dev/null
+++ b/src/Paymentwall/Controllers/Frontend/PaymentwallPingback.php
@@ -0,0 +1,103 @@
+deliveryService = $this->get('paymentwall.delivery_service');
+ $this->paymentService = $this->get('paymentwall.payment_service');
+ $this->orderService = $this->get('paymentwall.order_service');
+ $this->pingbackService = $this->get('paymentwall.pingback_service');
+ }
+
+ public function indexAction()
+ {
+ $pingbackParams = $this->Request()->getParams();
+ $orderId = $pingbackParams['goodsid'];
+
+ $order = $this->orderService->loadOrderRepositoryById($orderId);
+ if (empty($order)) {
+ die('Order not found');
+ }
+
+ unset($pingbackParams['module'], $pingbackParams['controller'], $pingbackParams['action']);
+ $this->pingbackService->loadData($pingbackParams);
+
+ $orderPaymentId = $this->orderService->getPaymentIdByOrderId($orderId);
+ if ($orderPaymentId != UtilService::getPaymentwallPaymentId()) {
+ die('Wrong payment method');
+ }
+
+ if (!$this->canProcessPingback($order, $orderId)) {
+ die('Can not process pingback');
+ }
+
+ if ($this->pingbackService->verifyPingback()) {
+ $sOrder = Shopware()->Modules()->Order();
+
+ if ($this->pingbackService->isPingbackDeliverable()) {
+ $sOrder->setOrderStatus($orderId, Status::ORDER_STATE_IN_PROCESS);
+ $sOrder->setPaymentStatus($orderId, Status::PAYMENT_STATE_COMPLETELY_PAID);
+ $this->orderService->updateTransactionId($pingbackParams['ref'], $orderId);
+ $this->sendDeiliveryStatus($orderId);
+ }
+
+ if ($this->pingbackService->isPingbackCancelable()) {
+ $sOrder->setPaymentStatus($orderId, Status::PAYMENT_STATE_THE_PROCESS_HAS_BEEN_CANCELLED);
+ }
+ die('OK');
+ } else {
+ die($this->pingbackService->getErrorSummary());
+ }
+ }
+
+ protected function sendDeiliveryStatus($orderId)
+ {
+
+ $order = $this->orderService->loadOrderRepositoryById($orderId);
+
+ if (!($order instanceof Order)) {
+ return;
+ }
+
+ $deliveryStatus = !empty($order->getEsd())
+ ? DeliveryConfirmationService::STATUS_DELIVERED
+ : DeliveryConfirmationService::STATUS_ORDER_PLACED;
+
+ $deliveryDataPrepared = $this->deliveryService->prepareDeliveryData(
+ $order,
+ $deliveryStatus
+ );
+ $this->deliveryService->sendDeliveryData($deliveryDataPrepared);
+ }
+
+ /**
+ * @param Order $order
+ * @return bool
+ */
+ private function canProcessPingback($order, $orderId)
+ {
+ if (!$this->pingbackService->isPingbackDeliverable()) {
+ return true;
+ }
+
+ if ($this->orderService->checkOrderWasPaid($orderId)
+ && $order->getTransactionId() != $order->getTemporaryId()
+ ) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/src/Paymentwall/Paymentwall.php b/src/Paymentwall/Paymentwall.php
new file mode 100644
index 0000000..49fd9d7
--- /dev/null
+++ b/src/Paymentwall/Paymentwall.php
@@ -0,0 +1,74 @@
+setParameter('paymentwall.plugin_dir', $this->getPath());
+ parent::build($container);
+ }
+
+ public function install(InstallContext $context)
+ {
+ /** @var \Shopware\Components\Plugin\PaymentInstaller $installer */
+ $installer = $this->container->get('shopware.plugin_payment_installer');
+
+ $options = [
+ 'name' => self::PAYMENT_NAME,
+ 'description' => 'Paymentwall',
+ 'action' => 'Paymentwall',
+ 'active' => 0,
+ 'position' => -99999,
+ 'additionalDescription' =>
+ 'offer more than 150 local payment methods, including e-wallets, bank transfers, prepaid cards, and cash options'
+ ];
+ $installer->createOrUpdate($context->getPlugin(), $options);
+ }
+
+ public function uninstall(UninstallContext $context)
+ {
+ $this->setActiveFlag($context->getPlugin()->getPayments(), false);
+ $context->scheduleClearCache(UninstallContext::CACHE_LIST_ALL);
+ }
+
+ /**
+ * @param DeactivateContext $context
+ */
+ public function deactivate(DeactivateContext $context)
+ {
+ $this->setActiveFlag($context->getPlugin()->getPayments(), false);
+ $context->scheduleClearCache(DeactivateContext::CACHE_LIST_ALL);
+ }
+
+ /**
+ * @param ActivateContext $context
+ */
+ public function activate(ActivateContext $context)
+ {
+ $this->setActiveFlag($context->getPlugin()->getPayments(), true);
+ $context->scheduleClearCache(ActivateContext::CACHE_LIST_ALL);
+ }
+
+ private function setActiveFlag($payments, $active)
+ {
+ $em = $this->container->get('models');
+
+ foreach ($payments as $payment) {
+ $payment->setActive($active);
+ }
+ $em->flush();
+ }
+}
diff --git a/src/Paymentwall/Resources/config.xml b/src/Paymentwall/Resources/config.xml
new file mode 100644
index 0000000..f706e1f
--- /dev/null
+++ b/src/Paymentwall/Resources/config.xml
@@ -0,0 +1,37 @@
+
+
+
+
+ pwProjectKey
+
+ Your Paymentwall Project Key
+
+
+ pwSecretKey
+
+ Your Paymentwall Secret Key
+
+
+ pwWidget
+
+ Enter your preferred widget code
+
+
+ pwRefundState
+
+ false
+
+
+ pwTestMode
+
+ false
+
+
+ pwRedirectPayment
+
+ false
+ Choose yes to redirect customer to checkout on Paymentwall website
+
+
+
\ No newline at end of file
diff --git a/src/Paymentwall/Resources/services.xml b/src/Paymentwall/Resources/services.xml
new file mode 100644
index 0000000..e531f6e
--- /dev/null
+++ b/src/Paymentwall/Resources/services.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Paymentwall/Resources/services/components.xml b/src/Paymentwall/Resources/services/components.xml
new file mode 100644
index 0000000..c96b1f2
--- /dev/null
+++ b/src/Paymentwall/Resources/services/components.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Paymentwall/Resources/services/subscribers.xml b/src/Paymentwall/Resources/services/subscribers.xml
new file mode 100644
index 0000000..f8e6220
--- /dev/null
+++ b/src/Paymentwall/Resources/services/subscribers.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %paymentwall.plugin_dir%
+
+
+
+
+
+ %paymentwall.plugin_dir%
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Paymentwall/Resources/views/frontend/_public/src/js/jquery.paymentwall.custom-shipping-payment.js b/src/Paymentwall/Resources/views/frontend/_public/src/js/jquery.paymentwall.custom-shipping-payment.js
new file mode 100644
index 0000000..cc68690
--- /dev/null
+++ b/src/Paymentwall/Resources/views/frontend/_public/src/js/jquery.paymentwall.custom-shipping-payment.js
@@ -0,0 +1,50 @@
+;(function($) {
+ 'use strict';
+ var defaults = {
+ paymentSelectionSelector: '.paymentwall-ps-selection',
+ paymentMethodSelector: '.paymentwall-ps',
+ restylePaymentSelectionAttribute: 'data-restylePaymentSelection'
+ };
+
+ $.overridePlugin('swShippingPayment', {
+ registerEvents: function() {
+ var me = this;
+ me.$el.on('click', defaults.paymentMethodSelector, $.proxy(me.onClick, me));
+ me.$el.on('change', me.opts.radioSelector, $.proxy(me.onInputChanged, me));
+
+ $.publish('plugin/swShippingPayment/onRegisterEvents', [me]);
+ },
+
+ onClick: function(event) {
+ var me = this,
+ target = $(event.currentTarget),
+ radio = target.find('input.pw-ps'),
+ url = window.controller.home + 'PaymentwallPaymentSystem/savePaymentsystem',
+ data = {
+ 'psId': radio.data('ps-id'),
+ 'psName': radio.data('ps-name')
+ };
+ let paymentId = radio.val();
+ if (target.hasClass(defaults.activeCls) || target.hasClass(defaults.staticActiveCls)) {
+ return;
+ }
+
+ $('#payment_mean' + paymentId).prop('checked', true).trigger('change');
+ $.subscribe('plugin/swShippingPayment/onInputChanged', function(event, shippingPayment) {
+ var paymentMethodSelected = shippingPayment.$el.find('input[name="payment"]:checked').val();
+ if (paymentMethodSelected == window.paymentwallId) {
+ $.ajax({
+ type: 'POST',
+ url: url,
+ data: data,
+ success: function(res) {
+ $('#payment_method_' + res).prop('checked', true);
+
+ $.publish('plugin/pwShippingPaymentCustom/onSelectedPs', [ me ]);
+ }
+ });
+ }
+ });
+ }
+ });
+})(jQuery);
diff --git a/src/Paymentwall/Resources/views/frontend/_public/src/less/_modules/shipping_payment/shipping-payment.less b/src/Paymentwall/Resources/views/frontend/_public/src/less/_modules/shipping_payment/shipping-payment.less
new file mode 100644
index 0000000..d730c01
--- /dev/null
+++ b/src/Paymentwall/Resources/views/frontend/_public/src/less/_modules/shipping_payment/shipping-payment.less
@@ -0,0 +1,19 @@
+.payment--method-list {
+ .default-payment-method {
+ .panel--body {
+ padding-top: 0;
+ .payment--method:first-child {
+ display: none;
+ }
+ }
+ }
+}
+
+.pw-payment-method-wrapper {
+ .payment--method-info {
+ display: none;
+ }
+ .pw-payment--method-info{
+ margin-bottom: 5px;
+ }
+}
\ No newline at end of file
diff --git a/src/Paymentwall/Resources/views/frontend/_public/src/less/all.less b/src/Paymentwall/Resources/views/frontend/_public/src/less/all.less
new file mode 100644
index 0000000..5367d93
--- /dev/null
+++ b/src/Paymentwall/Resources/views/frontend/_public/src/less/all.less
@@ -0,0 +1 @@
+@import "modules";
\ No newline at end of file
diff --git a/src/Paymentwall/Resources/views/frontend/_public/src/less/modules.less b/src/Paymentwall/Resources/views/frontend/_public/src/less/modules.less
new file mode 100644
index 0000000..943b71d
--- /dev/null
+++ b/src/Paymentwall/Resources/views/frontend/_public/src/less/modules.less
@@ -0,0 +1 @@
+@import "_modules/shipping_payment/shipping-payment";
diff --git a/src/Paymentwall/Resources/views/frontend/paymentwall/checkout/change_payment.tpl b/src/Paymentwall/Resources/views/frontend/paymentwall/checkout/change_payment.tpl
new file mode 100644
index 0000000..be186df
--- /dev/null
+++ b/src/Paymentwall/Resources/views/frontend/paymentwall/checkout/change_payment.tpl
@@ -0,0 +1,37 @@
+{extends file='frontend/checkout/change_payment.tpl'}
+
+{block name='frontend_checkout_payment_content'}
+
+ {foreach $localPaymentMethods as $payment}
+
+
+ {* Radio Button *}
+ {block name='frontend_checkout_payment_fieldset_input_radio_pw'}
+
+
+
+ {/block}
+
+ {* Method Name *}
+ {block name='frontend_checkout_payment_fieldset_input_label_pw'}
+
+
+
+ {/block}
+
+ {* Method Logo *}
+ {block name='frontend_checkout_payment_fieldset_template_pw'}
+
+
+
+ {/block}
+
+ {/foreach}
+
+
+ {$smarty.block.parent}
+
+
+{/block}
diff --git a/src/Paymentwall/Resources/views/frontend/paymentwall/checkout/confirm.tpl b/src/Paymentwall/Resources/views/frontend/paymentwall/checkout/confirm.tpl
new file mode 100644
index 0000000..e2480d0
--- /dev/null
+++ b/src/Paymentwall/Resources/views/frontend/paymentwall/checkout/confirm.tpl
@@ -0,0 +1,13 @@
+{extends file='frontend/checkout/confirm.tpl'}
+
+{block name='frontend_checkout_confirm_left_payment_method'}
+
+ {if !empty($localPaymentSelected) }
+
+ {s name="ConfirmInfoPaymentMethod" namespace="frontend/checkout/confirm"}{/s}
+ {$localPaymentSelected}
+
+ {/if}
+ {$smarty.block.parent}
+
+{/block}
\ No newline at end of file
diff --git a/src/Paymentwall/Resources/views/frontend/paymentwall/gateway.tpl b/src/Paymentwall/Resources/views/frontend/paymentwall/gateway.tpl
new file mode 100644
index 0000000..b1f4257
--- /dev/null
+++ b/src/Paymentwall/Resources/views/frontend/paymentwall/gateway.tpl
@@ -0,0 +1,30 @@
+{extends file="frontend/index/index.tpl"}
+{block name='frontend_index_content_left'}{/block}
+{block name='frontend_index_top_bar_container'}{/block}
+{block name='frontend_index_navigation_categories_top'}{/block}
+{block name='frontend_index_shop_navigation'}{/block}
+{block name='frontend_index_breadcrumb'}{/block}
+
+{block name='frontend_index_logo_trusted_shops'}
+ {$smarty.block.parent}
+ {s name="FinishButtonBackToShop" namespace="frontend/checkout/finish" assign="snippetFinishButtonBackToShop"}{/s}
+
+
+ {s name="FinishButtonBackToShop" namespace="frontend/checkout/finish"}{/s}
+
+{/block}
+
+{block name="frontend_index_content"}
+
+
+
+{/block}
diff --git a/src/Paymentwall/Subscriber/ActivatePlugin.php b/src/Paymentwall/Subscriber/ActivatePlugin.php
new file mode 100644
index 0000000..d8d54e3
--- /dev/null
+++ b/src/Paymentwall/Subscriber/ActivatePlugin.php
@@ -0,0 +1,47 @@
+connection = $connection;
+ }
+ /**
+ * {@inheritdoc}
+ */
+ public static function getSubscribedEvents()
+ {
+ return [
+ 'Enlight_Controller_Action_PostDispatchSecure_Backend_PluginInstaller' => 'ActivatePaymentMethod',
+ ];
+ }
+
+ public function ActivatePaymentMethod(\Enlight_Controller_ActionEventArgs $args)
+ {
+ if ($args->getRequest()->getActionName() !== 'activatePlugin') {
+ return;
+ }
+
+ $request = $args->getSubject()->Request();
+ $requestData = $request->getParams();
+
+ if (strtolower($requestData['technicalName']) == Paymentwall::PAYMENT_NAME) {
+ $paymentwallId = UtilService::getPaymentwallPaymentId();
+
+ $this->connection->createQueryBuilder()
+ ->update('s_core_paymentmeans')
+ ->set('active', 1)
+ ->where('id = ' . $paymentwallId)
+ ->execute();
+ }
+ }
+}
diff --git a/src/Paymentwall/Subscriber/DeliveryConfirmationSubscriber.php b/src/Paymentwall/Subscriber/DeliveryConfirmationSubscriber.php
new file mode 100644
index 0000000..bae80e2
--- /dev/null
+++ b/src/Paymentwall/Subscriber/DeliveryConfirmationSubscriber.php
@@ -0,0 +1,92 @@
+deliveryConfirmationService = $deliveryConfirmationService;
+ $this->orderService = $orderService;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getSubscribedEvents()
+ {
+ return [
+ 'Enlight_Controller_Action_PreDispatch_Backend_Order' => 'sendDelivery',
+ ];
+ }
+
+ public function sendDelivery(\Enlight_Controller_ActionEventArgs $args)
+ {
+ if ($args->getRequest()->getActionName() !== 'save') {
+ return;
+ }
+
+ $request = $args->getSubject()->Request();
+ $requestData = $request->getParams();
+
+ $id = $requestData['id'];
+ if (
+ empty($id)
+ || $requestData['payment'][0]['name'] != Paymentwall::PAYMENT_NAME
+ ) {
+ return;
+ }
+
+ $order = $this->orderService->loadOrderRepositoryById($id);
+
+ if (!($order instanceof Order)) {
+ return;
+ }
+
+ $oldTrackingCode = $order->getTrackingCode();
+ $newTrackingCode = $requestData['trackingCode'];
+ $deliveryDataPrepared = [];
+
+ if (empty($oldTrackingCode) && !empty($newTrackingCode) || ($oldTrackingCode != $newTrackingCode)) {
+
+ $trackingData = [
+ 'carrier_tracking_id' => $newTrackingCode,
+ 'carrier_type' =>$order->getDispatch()->getName()
+ ];
+
+ $deliveryDataPrepared = $this->deliveryConfirmationService->prepareDeliveryData(
+ $order,
+ DeliveryConfirmationService::STATUS_ORDER_SHIPPED,
+ $trackingData
+ );
+ }
+
+ $paymentStatus = $requestData['status'];
+ $currentStatus = $this->orderService->getOrderStatus($id);
+
+ if ($paymentStatus == Status::ORDER_STATE_COMPLETELY_DELIVERED
+ && $currentStatus != Status::ORDER_STATE_COMPLETELY_DELIVERED
+ ) {
+ $deliveryDataPrepared = $this->deliveryConfirmationService->prepareDeliveryData(
+ $order,
+ DeliveryConfirmationService::STATUS_DELIVERED
+ );
+ }
+
+ if (!empty($deliveryDataPrepared)) {
+ $this->deliveryConfirmationService->sendDeliveryData($deliveryDataPrepared);
+ }
+ }
+}
diff --git a/src/Paymentwall/Subscriber/FrontendCheckout.php b/src/Paymentwall/Subscriber/FrontendCheckout.php
new file mode 100644
index 0000000..53fa91c
--- /dev/null
+++ b/src/Paymentwall/Subscriber/FrontendCheckout.php
@@ -0,0 +1,90 @@
+pluginDir = $pluginDir;
+ $this->template = $template;
+ $this->paymentSystemService = $paymentSystemService;
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return [
+ 'Theme_Compiler_Collect_Plugin_Javascript' => 'onCollectJavascript',
+ 'Enlight_Controller_Action_PostDispatchSecure_Frontend_Checkout' => 'onPostDispatchSecure',
+ ];
+ }
+
+ public function onPostDispatchSecure(ActionEventArgs $args)
+ {
+ $paymentwallActive = UtilService::getPaymentMethodActiveFlag();
+ if (!$paymentwallActive) {
+ return;
+ }
+
+ if ($args->getRequest()->getActionName() == 'shippingPayment') {
+
+ $localPaymentMethods = $this->paymentSystemService->getLocalPaymentMethods();
+
+ if (!empty($localPaymentMethods)) {
+ $paymentwallId = UtilService::getPaymentwallPaymentId();
+ $view = $args->getSubject()->View();
+ $view->addTemplateDir($this->pluginDir . '/Resources/views/');
+ $view->extendsTemplate('frontend/paymentwall/checkout/change_payment.tpl');
+ $view->assign('localPaymentMethods', $localPaymentMethods);
+ $view->assign('paymentwallId', $paymentwallId);
+ } else {
+ $session = Shopware()->Container()->get('session');
+ $session->offsetUnset('paymentwall-localpayment');
+ }
+ }
+
+ if ($args->getRequest()->getActionName() == 'confirm') {
+
+ $view = $args->getSubject()->View();
+ $user = $view->getAssign('sUserData');
+ $payment = $user['additional']['payment'];
+
+ if ($payment['name'] == Paymentwall::PAYMENT_NAME) {
+ $session = Shopware()->Container()->get('session');
+ $selectedPaymentMethod = $session->offsetGet('paymentwall-localpayment');
+
+ if (!empty($selectedPaymentMethod['id'])) {
+ $view->addTemplateDir($this->pluginDir . '/Resources/views/');
+ $view->extendsTemplate('frontend/paymentwall/checkout/confirm.tpl');
+ $paymentMethodName = $selectedPaymentMethod['name'];
+ $view->assign('localPaymentSelected', $paymentMethodName);
+ }
+ }
+ }
+ }
+
+ public function onCollectJavascript()
+ {
+ $jsPath = [
+ $this->pluginDir . '/Resources/views/frontend/_public/src/js/jquery.paymentwall.custom-shipping-payment.js',
+ ];
+
+ return new ArrayCollection($jsPath);
+ }
+}
diff --git a/src/Paymentwall/Subscriber/Less.php b/src/Paymentwall/Subscriber/Less.php
new file mode 100644
index 0000000..a03a39c
--- /dev/null
+++ b/src/Paymentwall/Subscriber/Less.php
@@ -0,0 +1,35 @@
+pluginDir = $pluginDir;
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return [
+ 'Theme_Compiler_Collect_Plugin_Less' => 'onCollectLessFiles',
+ ];
+ }
+
+ public function onCollectLessFiles()
+ {
+ $less = new LessDefinition(
+ [],
+ [$this->pluginDir . '/Resources/views/frontend/_public/src/less/all.less'],
+ $this->pluginDir
+ );
+
+ return new ArrayCollection([$less]);
+ }
+}
diff --git a/src/Paymentwall/Subscriber/PaymentwallInit.php b/src/Paymentwall/Subscriber/PaymentwallInit.php
new file mode 100644
index 0000000..6a01ca4
--- /dev/null
+++ b/src/Paymentwall/Subscriber/PaymentwallInit.php
@@ -0,0 +1,34 @@
+ 'onInitPwSetting',
+ ];
+ }
+
+ public function onInitPwSetting(ActionEventArgs $args)
+ {
+ $controller = strtolower($args->getRequest()->getControllerName());
+ if (!in_array(strtolower($controller), self::$allowedController)) {
+ return;
+ }
+
+ $config = Shopware()->Container()->get('shopware.plugin.cached_config_reader')->getByPluginName('paymentwall');
+ Paymentwall_Config::getInstance()->set(array(
+ 'api_type' => Paymentwall_Config::API_GOODS,
+ 'public_key' => $config['pwProjectKey'],
+ 'private_key' => $config['pwSecretKey']
+ ));
+ }
+}
diff --git a/src/Paymentwall/Subscriber/RefundSubsciber.php b/src/Paymentwall/Subscriber/RefundSubsciber.php
new file mode 100644
index 0000000..6be4f73
--- /dev/null
+++ b/src/Paymentwall/Subscriber/RefundSubsciber.php
@@ -0,0 +1,65 @@
+refundService = $refundService;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getSubscribedEvents()
+ {
+ return [
+ 'Enlight_Controller_Action_PostDispatchSecure_Backend_Order' => 'refundOrder',
+ ];
+ }
+
+ public function refundOrder(\Enlight_Controller_ActionEventArgs $args)
+ {
+ if ($args->getRequest()->getActionName() !== 'save') {
+ return;
+ }
+
+ $requestParam = $args->getSubject()->Request()->getParams();
+
+ $isRefundEnabled = PaymentwallSettings::getRefundState();
+
+ if ($requestParam['status'] == Status::ORDER_STATE_CANCELLED_REJECTED
+ && $requestParam['payment'][0]['name'] == Paymentwall::PAYMENT_NAME
+ && !empty($requestParam['transactionId'])
+ && $isRefundEnabled
+ ) {
+ $shop = '';
+ if (Shopware()->Container()->initialized('shop')) {
+ $shop = Shopware()->Container()->get('shop');
+ }
+
+ if (!$shop) {
+ $shop = Shopware()->Container()->get('models')->getRepository(\Shopware\Models\Shop\Shop::class)->getActiveDefault();
+ }
+
+ $uid = !empty($requestParam['customerId']) ? $requestParam['customerId'] : $requestParam['customerEmail'];
+
+ Paymentwall_Config::getInstance()->set(array(
+ 'api_base_url' => 'https://api.paymentwall.com/developers/api',
+ 'private_key' => PaymentwallSettings::getSecretKey()
+ ));
+ $preparedData = $this->refundService->prepareData($requestParam['transactionId'], $uid, $shop->getHost());
+ $this->refundService->sendCancellation($preparedData);
+ }
+ }
+}
diff --git a/src/Paymentwall/assest/img/logo.gif b/src/Paymentwall/assest/img/logo.gif
new file mode 100644
index 0000000..2054c88
Binary files /dev/null and b/src/Paymentwall/assest/img/logo.gif differ
diff --git a/src/Paymentwall/plugin.png b/src/Paymentwall/plugin.png
new file mode 100644
index 0000000..ef93335
Binary files /dev/null and b/src/Paymentwall/plugin.png differ
diff --git a/src/Paymentwall/plugin.xml b/src/Paymentwall/plugin.xml
new file mode 100644
index 0000000..33cb19b
--- /dev/null
+++ b/src/Paymentwall/plugin.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+ 1.0.0
+ (c) by Paymentwall
+ MIT
+ https://paymentwall.com
+ Paymentwall
+
+
+ Accept payments from all over the world using many local and global credit cards, bank transfers, ewallets, sms, prepaid cards such as Paysafecard, Ukash and more via Paymentwall
+
+
+ Erstveröffentlichung;
+ First release;
+
+
diff --git a/src/engine/Library/paymentwall b/src/engine/Library/paymentwall
deleted file mode 160000
index d740d41..0000000
--- a/src/engine/Library/paymentwall
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit d740d41ea698f17b4ea18c77fb2297308ed3e182
diff --git a/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Bootstrap.php b/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Bootstrap.php
deleted file mode 100644
index e7e4f45..0000000
--- a/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Bootstrap.php
+++ /dev/null
@@ -1,306 +0,0 @@
- $this->getVersion(),
- 'author' => 'The Paymentwall Team',
- 'source' => $this->getSource(),
- 'supplier' => 'Paymentwall',
- 'support' => 'support@paymentwall.com',
- 'link' => 'https://www.paymentwall.com',
- 'copyright' => 'Copyright (c) 2017, Paymentwall',
- 'label' => 'Paymentwall',
- 'description' => 'Payment plugin for Shopware Community Edition Version 5.3
'
- );
- }
-
- /**
- * Fixes a known issue.
- *
- * @throws Exception
- */
- private function solveKnownIssue()
- {
- try {
- //Deleting translation for mainshop which causes in not be able to change it via backend
- Shopware()->Db()->delete('s_core_translations', Shopware()->Db()->quoteInto('objecttype = ?', 'config_payment')
- . ' AND ' . Shopware()->Db()->quoteInto('objectkey = ?', 1)
- . ' AND ' . Shopware()->Db()->quoteInto('objectlanguage = ?', '1')
- );
- } catch (Exception $exception) {
- throw new Exception($exception->getMessage());
- }
- }
-
- /**
- * Performs the necessary installation steps
- *
- * @throws Exception
- * @return boolean
- */
- public function install()
- {
- try {
- $this->createPaymentMeans();
- $this->_createForm();
- $this->_registerController();
- $this->_applyBackendViewModifications();
- $this->_translatePaymentNames();
- $this->solveKnownIssue();
- $this->Plugin()->setActive(true);
- } catch (Exception $exception) {
- $this->uninstall();
- throw new Exception($exception->getMessage());
- }
-
- return array('success' => parent::install(), 'invalidateCache' => $this->clearCache);
- }
-
- /**
- * Performs the necessary uninstall steps
- *
- * @return boolean
- */
- public function uninstall()
- {
- $this->removeSnippets();
- return parent::uninstall();
- }
-
- /**
- * Updates the Plugin and its components
- *
- * @param string $oldVersion
- *
- * @throws Exception
- * @return boolean
- */
- public function update($oldVersion)
- {
- try {
- switch ($oldVersion) {
- case "1.0.0":
- $sql = "DELETE FROM s_core_config_element_translations
- WHERE element_id IN (SELECT s_core_config_elements.id FROM s_core_config_elements
- WHERE s_core_config_elements.form_id = (SELECT s_core_config_forms.id FROM s_core_config_forms
- WHERE s_core_config_forms.plugin_id = ?));
- DELETE FROM s_core_config_elements
- WHERE form_id = (SELECT id FROM s_core_config_forms WHERE plugin_id = ?);";
- Shopware()->Db()->query($sql, array($this->getId(), $this->getId()));
- }
- return true;
- } catch (Exception $exception) {
- throw new Exception($exception->getMessage());
- }
- }
-
- /**
- * Translates the payment names
- *
- * @throws Exception
- * @return void
- */
- private function _translatePaymentNames()
- {
- try {
- $paymentwall = $this->Payments()->findOneBy(array('name' => 'pwlocal'));
- $brick = $this->Payments()->findOneBy(array('name' => 'brick'));
-
- $sortedSnippets = parse_ini_file(dirname(__FILE__) . '/Snippets/frontend/paymentwall/checkout/payments.ini', true);
- $shops = Shopware()->Db()->select()
- ->from('s_core_shops', array('id', 'default'))
- ->joinInner('s_core_locales', '`s_core_shops`.`locale_id`=`s_core_locales`.`id`', 'locale')
- ->query()
- ->fetchAll();
-
- foreach ($shops as $shop) {
- $shopId = $shop['id'];
- $locale = $shop['locale'];
- $this->updatePaymentTranslation($shopId, $brick->getID(), $sortedSnippets[$locale]['creditcard'], $shop['default']);
- $this->updatePaymentTranslation($shopId, $paymentwall->getID(), $sortedSnippets[$locale]['directdebit'], $shop['default']);
- }
-
- } catch (Exception $exception) {
- throw new Exception('Can not create translation for payment names. ' . $exception->getMessage());
- }
- }
-
- /**
- * Update the translation of a payment
- *
- * @param integer $shopId
- * @param integer $paymentId
- * @param string $description
- * @param integer $default
- */
- private function updatePaymentTranslation($shopId, $paymentId, $description, $default)
- {
- if ($default) {
- Shopware()->Db()->update('s_core_paymentmeans', array(
- 'description' => $description
- ), 'id=' . $paymentId
- );
- } else {
- $translationObject = new Shopware_Components_Translation();
- $translationObject->write(
- $shopId, 'config_payment', $paymentId, array('description' => $description), true
- );
- }
- }
-
- /**
- * Disables the plugin
- *
- * @throws Exception
- * @return boolean
- */
- public function disable()
- {
- try {
- $payment = array('pwlocal', 'brick');
-
- foreach ($payment as $key) {
- $currentPayment = $this->Payments()->findOneBy(array('name' => $key));
- if ($currentPayment) {
- $currentPayment->setActive(false);
- }
- }
- } catch (Exception $exception) {
- throw new Exception('Cannot disable payment: ' . $exception->getMessage());
- }
-
- return array('success' => true, 'invalidateCache' => $this->clearCache);
- }
-
- public function enable()
- {
- return array('success' => true, 'invalidateCache' => $this->clearCache);
- }
-
- /**
- * Creates the payment method
- *
- * @throws Exception
- * @return void
- */
- protected function createPaymentMeans()
- {
- try {
- $this->createPayment(
- array(
- 'active' => 1,
- 'name' => 'brick',
- 'action' => 'brick',
- 'template' => 'brick.tpl',
- 'description' => 'Createdit Card',
- 'additionalDescription' => ''
- )
- );
- $this->createPayment(
- array(
- 'active' => 1,
- 'name' => 'pwlocal',
- 'action' => 'paymentwall',
- 'template' => 'pwlocal.tpl',
- 'description' => 'Paymentwall',
- 'additionalDescription' => ''
- )
- );
- } catch (Exception $exception) {
- throw new Exception('There was an error creating the payment means. ' . $exception->getMessage());
- }
- }
-
- /**
- * Creates the configuration fields
- *
- * @throws Exception
- * @return void
- */
- private function _createForm()
- {
- try {
- $form = $this->Form();
- $form->setElement('text', 'merchantName', array('label' => 'Merchant name', 'required' => true, 'position' => 0, 'description' => 'Name of merchant'));
- $form->setElement('text', 'projectKey', array('label' => 'Project key', 'required' => true, 'position' => 5, 'description' => 'Project key for payment method: Paymentwall'));
- $form->setElement('text', 'secretKey', array('label' => 'Secret key', 'required' => true, 'position' => 10, 'description' => 'Secret key for payment method: Paymentwall'));
- $form->setElement('text', 'publicKey', array('label' => 'Public key', 'required' => true, 'position' => 20, 'description' => 'Public key for payment method: Brick'));
- $form->setElement('text', 'privateKey', array('label' => 'Private key', 'required' => true, 'position' => 30, 'description' => 'Private key for payment method: Brick'));
- $form->setElement('text', 'widgetCode', array('label' => 'Widget code', 'required' => true, 'position' => 40, 'description' => 'Widget for payment method: Paymentwall'));
- $form->setElement('select', 'testMode', array('label' => 'Test mode', 'store' => array(
- array(1, 'Yes'),
- array(0, 'No'),
- ),
- 'value' => 0,
- 'position' => 50,
- 'description' => 'Enable Test method for payment method: Paymentwall'
- )
- );
- } catch (Exception $exception) {
- throw new Exception('There was an error creating the plugin configuration. ' . $exception->getMessage());
- }
- }
-
- /**
- * Registers all Controllers
- */
- private function _registerController()
- {
- $this->registerController('Frontend', 'Paymentwall');
- $this->registerController('Frontend', 'Brick');
- }
-
-
- /**
- * Modifies the Backend menu by adding a Paymentwall Label as a child element of the shopware logging
- *
- * @throws Exception
- * @return void
- */
- private function _applyBackendViewModifications()
- {
- try {
- $parent = $this->Menu()->findOneBy(['label' => 'Logfile']);
- $this->createMenuItem(
- array(
- 'label' => 'Paymentwall',
- 'class' => 'paymentwall',
- 'active' => 1,
- 'controller' => 'Paymentwall',
- 'action' => 'index',
- 'parent' => $parent
- )
- );
- } catch (Exception $exception) {
- throw new Exception('Can not create menu entry.' . $exception->getMessage());
- }
- }
-
-}
diff --git a/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Controllers/Frontend/Brick.php b/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Controllers/Frontend/Brick.php
deleted file mode 100644
index 4e3286d..0000000
--- a/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Controllers/Frontend/Brick.php
+++ /dev/null
@@ -1,142 +0,0 @@
-OldPath() . "engine/Library/paymentwall/lib/paymentwall.php");
-
-define('PW_BASE_URL', Shopware()->Shop()->getBaseUrl());
-
-class Shopware_Controllers_Frontend_Brick extends Shopware_Controllers_Frontend_Payment
-{
- private $config;
- const ORDER_OPEN = 0;
- const ORDER_PROCESS = 1;
- const ORDER_COMPLETED = 2;
- const ORDER_CANCELED = 4;
- const PAYMENT_COMPLETELY_PAID = 12;
- const PAYMENT_CANCELED = 35;
- const PAYMENT_NO_CREDIT_APPROVED = 30;
- const PAYMENT_REVIEW_NECESSARY = 21;
-
- public function init()
- {
- $this->config = Shopware()->Plugins()->Frontend()->Paymentwall()->Config();
-
- Paymentwall_Config::getInstance()->set(array(
- 'api_type' => Paymentwall_Config::API_GOODS,
- 'public_key' => trim($this->config->get("publicKey")), // available in your Paymentwall merchant area
- 'private_key' => trim($this->config->get("privateKey"))// available in your Paymentwall merchant area
- ));
- }
-
- public function indexAction()
- {
- if (!empty(Shopware()->Session()->brick)) {
- unset(Shopware()->Session()->brick);
- $this->redirect(PW_BASE_URL);
- } else {
- try {
- $customerDetails = $this->getUser();
- $customerFirstname = $customerDetails['billingaddress']['firstname'];
- $customerLastname = $customerDetails['billingaddress']['lastname'];
- $customerID = $customerDetails['additional']['user']['id'];
- $orderNumber = $this->saveOrder(
- $this->createPaymentUniqueId(),
- md5($this->createPaymentUniqueId()),
- self::ORDER_OPEN
- );
-
- $orderId = $this->getOrderIdByOrderNumber($orderNumber);
- $order = array(
- 'orderId' => $orderId,
- 'orderNumber' => $orderNumber,
- 'amount' => $this->getAmount(),
- 'currency' => $this->getCurrencyShortName(),
- 'customerLastname' => $customerLastname,
- 'customerFirstname' => $customerFirstname,
- 'customerId' => $customerID
- );
-
- Shopware()->Session()->brick = $order;
- $this->View()->order = $order;
- $this->View()->public_key = trim($this->config->get("publicKey"));
- $this->View()->merchant_name = trim($this->config->get("merchantName"));
- } catch (Exception $e) {
- $this->redirect(PW_BASE_URL);
- }
- }
- }
-
- public function payAction()
- {
- if (empty(Shopware()->Session()->brick)) {
- $result = array(
- 'success' => 0,
- 'error' => array(
- 'code' => '404',
- 'message' => 'Order data not found',
- )
- );
- echo json_encode($result);
- die;
- }
-
- $orderData = Shopware()->Session()->brick;
- $parameters = $_POST;
-
- $cardInfo = array(
- 'uid' => $orderData['customerId'],
- 'email' => $parameters['email'],
- 'plan' => $orderData['orderId'],
- 'amount' => $orderData['amount'],
- 'currency' => $orderData['currency'],
- 'token' => $parameters['brick_token'],
- 'fingerprint' => $parameters['brick_fingerprint'],
- 'description' => 'Order #' . $orderData['orderNumber'],
- 'customer[lastname]' => $orderData['customerLastname'],
- 'customer[firstname]' => $orderData['customerFirstname']
- );
-
- if (isset($parameters['brick_charge_id']) AND isset($parameters['brick_secure_token'])) {
- $cardInfo['charge_id'] = $parameters['brick_charge_id'];
- $cardInfo['secure_token'] = $parameters['brick_secure_token'];
- }
-
- $charge = new Paymentwall_Charge();
- $charge->create($cardInfo);
- $responseData = json_decode($charge->getRawResponseData(),true);
- $response = $charge->getPublicData();
-
- if ($charge->isSuccessful() AND empty($responseData['secure'])) {
- $order = Shopware()->Modules()->Order();
- $orderId = $orderData['orderId'];
- $sendMail = true;
-
- if ($charge->isCaptured()) {
- $order->setOrderStatus($orderId, self::ORDER_PROCESS);
- $order->setPaymentStatus($orderId, self::PAYMENT_COMPLETELY_PAID, $sendMail);
- } elseif ($charge->isUnderReview()) {
- $order->setOrderStatus($orderId, self::ORDER_OPEN);
- $order->setPaymentStatus($orderId, self::PAYMENT_REVIEW_NECESSARY, $sendMail);
- }
- $this->updateOrderReferer($orderId, $charge->getId());
- unset(Shopware()->Session()->brick);
- } elseif (!empty($responseData['secure'])) {
- $response = json_encode(array('secure' => $responseData['secure']));
- } else {
- $errors = json_decode($response, true);
- }
-
- echo $response;
- die;
- }
-
- private function getOrderIdByOrderNumber($orderNumber)
- {
- return Shopware()->Db()->fetchOne("SELECT id FROM s_order WHERE ordernumber = ?", array($orderNumber));
- }
-
- private function updateOrderReferer($orderId, $referer)
- {
- Shopware()->Db()->update('s_order', array('referer' => $referer), array('id='.$orderId));
- }
-
-}
\ No newline at end of file
diff --git a/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Controllers/Frontend/Paymentwall.php b/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Controllers/Frontend/Paymentwall.php
deleted file mode 100644
index a93e5e1..0000000
--- a/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Controllers/Frontend/Paymentwall.php
+++ /dev/null
@@ -1,226 +0,0 @@
-OldPath() . "engine/Library/paymentwall/lib/paymentwall.php");
-
-define('PW_BASE_URL', Shopware()->Shop()->getBaseUrl());
-
-class Shopware_Controllers_Frontend_Paymentwall extends Shopware_Controllers_Frontend_Payment
-{
- private $config;
- const ORDER_OPEN = 0;
- const ORDER_PROCESS = 1;
- const ORDER_COMPLETED = 2;
- const ORDER_CANCELED = 4;
- const PAYMENT_COMPLETELY_PAID = 12;
- const PAYMENT_CANCELED = 35;
- const PAYMENT_NO_CREDIT_APPROVED = 30;
- const PAYMENT_REVIEW_NECESSARY = 21;
- const PAYMENT_BRICK = 'brick';
-
- public $_unsetParams = array();
-
- public function init()
- {
- $this->config = Shopware()->Plugins()->Frontend()->Paymentwall()->Config();
-
- Paymentwall_Config::getInstance()->set(array(
- 'api_type' => Paymentwall_Config::API_GOODS,
- 'public_key' => trim($this->config->get("projectKey")), // available in your Paymentwall merchant area
- 'private_key' => trim($this->config->get("secretKey")) // available in your Paymentwall merchant area
- ));
-
- $this->_unsetParams = array(
- 'controller',
- 'action',
- 'module'
- );
- }
-
- /**
- * Load payment method of Paymentwall
- *
- */
- public function indexAction()
- {
- if (!empty(Shopware()->Session()->pwLocal)) {
- unset(Shopware()->Session()->pwLocal);
- $this->redirect(PW_BASE_URL);
- } else {
- try {
- $orderNumber = $this->saveOrder(
- $this->createPaymentUniqueId(),
- md5($this->createPaymentUniqueId()),
- self::ORDER_OPEN
- );
- $orderId = $this->getOrderIdByOrderNumber($orderNumber);
- $params = array(
- 'orderId' => $orderId,
- 'orderNumber' => $orderNumber,
- 'amount' => $this->getAmount(),
- 'currency' => $this->getCurrencyShortName(),
- 'user' => $this->getUser(),
- );
- Shopware()->Session()->pwLocal = $params;
- $this->View()->orderId = $orderId;
- $this->View()->iframe = $this->getWidget($params);
- } catch (Exception $e) {
- $this->redirect(PW_BASE_URL);
- }
- }
- }
-
- /**
- * Get iframe widget pwlocal
- *
- * @param array $params
- */
- private function getWidget($params)
- {
- $widget = new Paymentwall_Widget(
- !empty($params['user']['additional']['user']['email']) ?
- $params['user']['additional']['user']['email'] :
- $params['user']['additional']['user']['id'],
- trim($this->config->get("widgetCode")),
- array(
- new Paymentwall_Product(
- $params['orderId'],
- $params['amount'],
- $params['currency'],
- 'Order #' . $params['orderNumber'],
- Paymentwall_Product::TYPE_FIXED,
- 0,
- null,
- false
- )
- ),
- // additional parameters
- array_merge(
- array(
- 'email' => $params['user']['additional']['user']['email'],
- 'integration_module' => 'shopware',
- 'test_mode' => trim($this->config->get("testMode")),
- 'success_url' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . PW_BASE_URL . '/checkout/finish'
- ),
- $this->getUserProfileData($params['user'])
- )
- );
-
- return $widget->getHtmlCode(array(
- 'height' => 600,
- 'width' => '100%',
- 'frameborder' => 0
- ));
- }
-
- /**
- * Build User Profile Data
- *
- * @param array $params
- */
- protected function getUserProfileData($params)
- {
- $billing = $params['billingaddress'];
-
- return array(
- 'customer[city]' => $billing['city'],
- 'customer[state]' => $billing['stateID'],
- 'customer[address]' => $billing['street'],
- 'customer[country]' => $billing['country'],
- 'customer[zip]' => $billing['zipcode'],
- 'customer[firstname]' => $billing['firstname'],
- 'customer[lastname]' => $billing['lastname'],
- 'email' => $params['additional']['user']['email']
- );
- }
-
- public function getRequestParams()
- {
- $params = $this->Request()->getParams();
- foreach ($this->_unsetParams AS $un) {
- unset($params[$un]);
- }
- return $params;
- }
-
- /**
- * Pingback update Order, Payment status
- *
- * @param array $_GET
- */
- public function pingbackAction()
- {
- $getData = $this->getRequestParams();
- $orderId = $getData['goodsid'];
- $paymentId = $this->getPaymentIdByOrderId($orderId);
- $paymentName = $this->getPaymentNameByPaymentId($paymentId);
-
- Paymentwall_Config::getInstance()->set(array(
- 'api_type' => Paymentwall_Config::API_GOODS,
- 'public_key' => trim($this->config->get("publicKey")), // available in your Paymentwall merchant area
- 'private_key' => ($this->config->get("testMode") && $paymentName == self::PAYMENT_BRICK) ? trim($this->config->get("privateKey")) : trim($this->config->get("secretKey"))// available in your Paymentwall merchant area
- ));
-
- $pingback = new Paymentwall_Pingback($getData, $_SERVER['REMOTE_ADDR']);
- $order = Shopware()->Modules()->Order();
- $sendMail = true;
-
- if ($pingback->validate()) {
- if ($pingback->isDeliverable()) {
- $order->setOrderStatus($orderId, self::ORDER_PROCESS);
- $order->setPaymentStatus($orderId, self::PAYMENT_COMPLETELY_PAID, $sendMail);
- $this->updateOrderReferer($orderId, $pingback->getReferenceId());
- } elseif ($pingback->isCancelable()) {
- $order->setOrderStatus($orderId, self::ORDER_CANCELED);
- $order->setPaymentStatus($orderId, self::PAYMENT_CANCELED, $sendMail);
- } elseif ($pingback->isUnderReview()) {
- $order->setOrderStatus($orderId, self::ORDER_OPEN);
- $order->setPaymentStatus($orderId, self::PAYMENT_REVIEW_NECESSARY, $sendMail);
- }
- die("OK");
- } else {
- die($pingback->getErrorSummary());
- }
- }
-
- private function getOrderIdByOrderNumber($orderNumber)
- {
- return Shopware()->Db()->fetchOne("SELECT id FROM s_order WHERE ordernumber = ?", array($orderNumber));
- }
-
- private function getOrderStatusByOrderId($orderId)
- {
- return Shopware()->Db()->fetchOne("SELECT status FROM s_order WHERE id = ?", array($orderId));
- }
-
- private function updateOrderReferer($orderId, $referer)
- {
- Shopware()->Db()->update('s_order', array('referer' => $referer), array('id='.$orderId));
- }
-
- private function getPaymentIdByOrderId($orderId)
- {
- return Shopware()->Db()->fetchOne("SELECT paymentID FROM s_order WHERE id = ?", array($orderId));
- }
-
- private function getPaymentNameByPaymentId($paymentId)
- {
- return Shopware()->Db()->fetchOne("SELECT name FROM s_core_paymentmeans WHERE id = ?", array($paymentId));
- }
-
- /**
- *
- * Check order status, redirect to thank you page
- *
- * @param integer $orderId
- */
- public function redirectAction()
- {
- $orderId = $this->Request()->getParam("orderId");
- $status = 0;
- if (!empty($orderId)) {
- $status = $this->getOrderStatusByOrderId($orderId);
- }
- echo $status;
- die;
- }
-}
diff --git a/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Snippets/frontend/paymentwall/checkout/payments.ini b/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Snippets/frontend/paymentwall/checkout/payments.ini
deleted file mode 100644
index 8e0e0e2..0000000
--- a/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/Snippets/frontend/paymentwall/checkout/payments.ini
+++ /dev/null
@@ -1,23 +0,0 @@
-[de_DE]
-creditcard = "Brick"
-directdebit = "Paymentwall"
-
-[en_GB]
-creditcard = "Brick"
-directdebit = "Paymentwall"
-
-[es_ES]
-creditcard = "Brick"
-directdebit = "Paymentwall"
-
-[fr_FR]
-creditcard = "Brick"
-directdebit = "Paymentwall"
-
-[it_IT]
-creditcard = "Brick"
-directdebit = "Paymentwall"
-
-[pt_PT]
-creditcard = "Brick"
-directdebit = "Paymentwall"
\ No newline at end of file
diff --git a/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/plugin.png b/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/plugin.png
deleted file mode 100644
index 349c3b4..0000000
Binary files a/src/engine/Shopware/Plugins/Community/Frontend/Paymentwall/plugin.png and /dev/null differ
diff --git a/src/themes/Frontend/Bare/frontend/brick/index.tpl b/src/themes/Frontend/Bare/frontend/brick/index.tpl
deleted file mode 100644
index cd7d1ba..0000000
--- a/src/themes/Frontend/Bare/frontend/brick/index.tpl
+++ /dev/null
@@ -1,60 +0,0 @@
-{extends file='frontend/index/index.tpl'}
-
-{* Main content *}
-{block name='frontend_index_content_left'}{/block}
-{block name='frontend_index_content'}
-
-
-{/block}
diff --git a/src/themes/Frontend/Bare/frontend/paymentwall/index.tpl b/src/themes/Frontend/Bare/frontend/paymentwall/index.tpl
deleted file mode 100644
index 0ad5436..0000000
--- a/src/themes/Frontend/Bare/frontend/paymentwall/index.tpl
+++ /dev/null
@@ -1,26 +0,0 @@
-{extends file='frontend/index/index.tpl'}
-
-{* Main content *}
-{block name='frontend_index_content_left'}{/block}
-{block name='frontend_index_content'}
-
-
- {$iframe}
-
-
-{/block}
-
-
\ No newline at end of file