Skip to content

Commit

Permalink
Merge pull request #36 in DEV-MO/shopware5-module from feature/SHPWR-…
Browse files Browse the repository at this point in the history
…368_configurable-payment-states to release/5.3.0

* commit '59535c871bbe5790570c62ae8d0f7e0cc60dd1e4':
  [SHPWR-368] Make payment status configurable
  • Loading branch information
eiriarte-mendez committed Nov 6, 2018
2 parents 7067e11 + 59535c8 commit c50302b
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 14 deletions.
5 changes: 1 addition & 4 deletions Bootstrapping/Events/BackendOrderControllerSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ private function doPostProcessing($orderId, $answer, $paymentRequestData, $payme
//insert ratepay positions
$paymentProcessor->insertRatepayPositions($order);

if ($paymentMethod != 'PREPAYMENT') {
//payment status closed
$paymentProcessor->setPaymentStatusPaid($order);
}
$paymentProcessor->setPaymentStatus($order);

//insert positions
if (\Shopware_Plugins_Frontend_RpayRatePay_Bootstrap::getPCConfig() == true) {
Expand Down
62 changes: 61 additions & 1 deletion Bootstrapping/form_elements.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,65 @@
"value": false,
"scope":1
}
},
{
"type":"select",
"name":"RatePayPrepaidPaymentStatus",
"config":{
"label": "Status nach Zahlung mit Vorkasse:",
"value": 17,
"store":"base.PaymentStatus",
"displayField":"description",
"valueField":"id",
"scope":1
}
},
{
"type":"select",
"name":"RatePayInvoicePaymentStatus",
"config":{
"label": "Status nach Zahlung mit Rechnung:",
"value": 12,
"store":"base.PaymentStatus",
"displayField":"description",
"valueField":"id",
"scope":1
}
},
{
"type":"select",
"name":"RatePayDebitPaymentStatus",
"config":{
"label": "Status nach Zahlung mit Lastschrift:",
"value": 12,
"store":"base.PaymentStatus",
"displayField":"description",
"valueField":"id",
"scope":1
}
},
{
"type":"select",
"name":"RatePayInstallmentPaymentStatus",
"config":{
"label": "Status nach Zahlung mit Rate:",
"value": 12,
"store":"base.PaymentStatus",
"displayField":"description",
"valueField":"id",
"scope":1
}
},
{
"type":"select",
"name":"RatePayInstallment0PaymentStatus",
"config":{
"label": "Status nach Zahlung mit Nullprozent-Finanzierung:",
"value": 12,
"store":"base.PaymentStatus",
"displayField":"description",
"valueField":"id",
"scope":1
}
}
]
]
7 changes: 3 additions & 4 deletions Component/Service/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace RpayRatePay\Component\Service;

use RpayRatePay\Component\Mapper\PaymentRequestData;
use RpayRatePay\Component\Service\ShopwareUtil;

class PaymentProcessor
{
const PAYMENT_STATUS_COMPLETELY_PAID = 12;
private $db;

public function __construct($db)
Expand Down Expand Up @@ -79,19 +79,18 @@ public function setOrderTransactionId($order, $transactionId)
/**
* @param \Shopware\Models\Order\Order $order
*/
public function setPaymentStatusPaid($order)
public function setPaymentStatus($order)
{
//set cleared date
$dateTime = new \DateTime();

$order->setClearedDate($dateTime);

Shopware()->Models()->flush($order);

Shopware()->Modules()->Order()
->setPaymentStatus(
$order->getId(),
self::PAYMENT_STATUS_COMPLETELY_PAID,
ShopwareUtil::getStatusAfterRatePayPayment($order->getPayment()),
false
);
}
Expand Down
28 changes: 28 additions & 0 deletions Component/Service/ShopwareUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,32 @@ public static function customerCreatesNetOrders(Shopware\Models\Customer\Custome
{
return $customer->getGroup()->getTax() === false;
}

/**
* @param \Shopware\Models\Payment\Payment $payment
* @return int
*/
public static function getStatusAfterRatePayPayment($payment)
{
$config = Shopware()->Plugins()->Frontend()->RpayRatePay()->Config();

switch ($payment->getName()) {
case 'rpayratepayinvoice':
return (int)$config->get('RatePayInvoicePaymentStatus');
case 'rpayratepayrate':
return (int)$config->get('RatePayInstallmentPaymentStatus');
case 'rpayratepaydebit':
return (int)$config->get('RatePayDebitPaymentStatus');
case 'rpayratepayrate0':
return (int)$config->get('RatePayInstallment0PaymentStatus');
case 'rpayratepayprepayment':
return (int)$config->get('RatePayPrepaidPaymentStatus');
default:
Logger::singleton()->error(
'Unable to define status for unknown method: ' . $payment->getName()
);
return 17;
}

}
}
1 change: 0 additions & 1 deletion Controller/backend/RpayRatepayOrderDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public function deliverItemsAction()
{
$orderId = $this->Request()->getParam('orderId');
$items = json_decode($this->Request()->getParam('items'));
$orderModel = Shopware()->Models()->getRepository('Shopware\Models\Order\Order');
$order = Shopware()->Models()
->getRepository('Shopware\Models\Order\Order')
->findOneBy(['id' => $orderId]);
Expand Down
5 changes: 1 addition & 4 deletions Controller/frontend/RpayRatepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,7 @@ private function _proceedPayment()
Logger::singleton()->error($exception->getMessage());
}

if ($this->getPaymentShortName() != 'rpayratepayprepayment') {
//payment status closed
$paymentProcessor->setPaymentStatusPaid($order);
}
$paymentProcessor->setPaymentStatus($order);

if (Shopware_Plugins_Frontend_RpayRatePay_Bootstrap::getPCConfig() == true) {
$paymentProcessor->sendPaymentConfirm($resultRequest->getTransactionId(), $order);
Expand Down

0 comments on commit c50302b

Please sign in to comment.