Skip to content

Commit f57013c

Browse files
authored
Merge pull request #30 from logeecom/4.0
Release version 4.0.10
2 parents 64959d9 + d3b028a commit f57013c

File tree

46 files changed

+2783
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2783
-198
lines changed

Entity/PaymentMethodSettings.php

Lines changed: 222 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,45 @@ class PaymentMethodSettings
128128
* @ORM\Column(name="mollie_method_description", type="string", length=255, nullable=false)
129129
*/
130130
protected $mollieMethodDescription;
131+
/**
132+
* @var Collection|LocalizedFallbackValue[]
133+
*
134+
* @ORM\ManyToMany(
135+
* targetEntity="Oro\Bundle\LocaleBundle\Entity\LocalizedFallbackValue",
136+
* cascade={"ALL"},
137+
* orphanRemoval=true
138+
* )
139+
* @ORM\JoinTable(
140+
* name="mollie_single_click_appr_text",
141+
* joinColumns={
142+
* @ORM\JoinColumn(name="payment_setting_id", referencedColumnName="id", onDelete="CASCADE")
143+
* },
144+
* inverseJoinColumns={
145+
* @ORM\JoinColumn(name="localized_value_id", referencedColumnName="id", onDelete="CASCADE", unique=true)
146+
* }
147+
* )
148+
*/
131149

150+
protected $singleClickPaymentApprovalText;
151+
/**
152+
* @var Collection|LocalizedFallbackValue[]
153+
*
154+
* @ORM\ManyToMany(
155+
* targetEntity="Oro\Bundle\LocaleBundle\Entity\LocalizedFallbackValue",
156+
* cascade={"ALL"},
157+
* orphanRemoval=true
158+
* )
159+
* @ORM\JoinTable(
160+
* name="mollie_single_click_desc",
161+
* joinColumns={
162+
* @ORM\JoinColumn(name="payment_setting_id", referencedColumnName="id", onDelete="CASCADE")
163+
* },
164+
* inverseJoinColumns={
165+
* @ORM\JoinColumn(name="localized_value_id", referencedColumnName="id", onDelete="CASCADE", unique=true)
166+
* }
167+
* )
168+
*/
169+
protected $singleClickPaymentDescription;
132170
/**
133171
* @var \Mollie\Bundle\PaymentBundle\IntegrationCore\BusinessLogic\PaymentMethod\Model\PaymentMethodConfig
134172
*/
@@ -157,18 +195,35 @@ class PaymentMethodSettings
157195
/**
158196
* @var string
159197
*/
160-
private $method;
198+
private $surchargeType;
199+
200+
/**
201+
* @var string
202+
*/
203+
private $surchargeFixedAmount;
161204

162205
/**
163206
* @var string
164207
*/
165-
private $surcharge;
208+
private $surchargePercentage;
166209

210+
/**
211+
* @var string
212+
*/
213+
private $surchargeLimit;
214+
/**
215+
* @var string
216+
*/
217+
private $method;
167218
/**
168219
* @var boolean
169220
*/
170221
private $mollieComponents;
171222

223+
/**
224+
* @var boolean
225+
*/
226+
private $singleClickPayment;
172227
/**
173228
* @var string
174229
*/
@@ -203,6 +258,8 @@ public function __construct()
203258
$this->descriptions = new ArrayCollection();
204259
$this->paymentDescriptions = new ArrayCollection();
205260
$this->transactionDescriptions = new ArrayCollection();
261+
$this->singleClickPaymentApprovalText = new ArrayCollection();
262+
$this->singleClickPaymentDescription = new ArrayCollection();
206263
}
207264

208265
/**
@@ -450,6 +507,70 @@ public function setEnabled($enabled)
450507
$this->enabled = $enabled;
451508
}
452509

510+
/**
511+
* @return string
512+
*/
513+
public function getSurchargeType()
514+
{
515+
return $this->surchargeType;
516+
}
517+
518+
/**
519+
* @param string $surchargeType
520+
*/
521+
public function setSurchargeType($surchargeType)
522+
{
523+
$this->surchargeType = $surchargeType;
524+
}
525+
526+
/**
527+
* @return string
528+
*/
529+
public function getSurchargeFixedAmount()
530+
{
531+
return $this->surchargeFixedAmount;
532+
}
533+
534+
/**
535+
* @param string $surchargeFixedAmount
536+
*/
537+
public function setSurchargeFixedAmount($surchargeFixedAmount)
538+
{
539+
$this->surchargeFixedAmount = $surchargeFixedAmount;
540+
}
541+
542+
/**
543+
* @return string
544+
*/
545+
public function getSurchargePercentage()
546+
{
547+
return $this->surchargePercentage;
548+
}
549+
550+
/**
551+
* @param string $surchargePercentage
552+
*/
553+
public function setSurchargePercentage($surchargePercentage)
554+
{
555+
$this->surchargePercentage = $surchargePercentage;
556+
}
557+
558+
/**
559+
* @return string
560+
*/
561+
public function getSurchargeLimit()
562+
{
563+
return $this->surchargeLimit;
564+
}
565+
566+
/**
567+
* @param string $surchargeLimit
568+
*/
569+
public function setSurchargeLimit($surchargeLimit)
570+
{
571+
$this->surchargeLimit = $surchargeLimit;
572+
}
573+
453574
/**
454575
* @return string
455576
*/
@@ -499,35 +620,123 @@ public function setOriginalImagePath($originalImagePath)
499620
}
500621

501622
/**
502-
* @return string
623+
* @return mixed
503624
*/
504-
public function getSurcharge()
625+
public function getMollieComponents()
505626
{
506-
return $this->surcharge;
627+
return $this->mollieComponents;
507628
}
508629

509630
/**
510-
* @param string $surcharge
631+
* @param bool $mollieComponents
511632
*/
512-
public function setSurcharge($surcharge)
633+
public function setMollieComponents($mollieComponents)
513634
{
514-
$this->surcharge = $surcharge;
635+
$this->mollieComponents = $mollieComponents;
515636
}
516637

517638
/**
518639
* @return mixed
519640
*/
520-
public function getMollieComponents()
641+
public function getSingleClickPayment()
521642
{
522-
return $this->mollieComponents;
643+
return $this->singleClickPayment;
523644
}
524645

525646
/**
526-
* @param bool $mollieComponents
647+
* @param bool $singleClickPayment
527648
*/
528-
public function setMollieComponents($mollieComponents)
649+
public function setSingleClickPayment($singleClickPayment)
529650
{
530-
$this->mollieComponents = $mollieComponents;
651+
$this->singleClickPayment = $singleClickPayment;
652+
}
653+
654+
/**
655+
* @return Collection|LocalizedFallbackValue[]
656+
*/
657+
public function getSingleClickPaymentApprovalText()
658+
{
659+
return $this->singleClickPaymentApprovalText;
660+
}
661+
662+
/**
663+
* @param Collection|LocalizedFallbackValue[] $singleClickPaymentApprovalText
664+
*/
665+
public function setSingleClickPaymentApprovalText($singleClickPaymentApprovalText)
666+
{
667+
$this->singleClickPaymentApprovalText = $singleClickPaymentApprovalText;
668+
}
669+
670+
/**
671+
* @param LocalizedFallbackValue $singleClickPaymentApprovalText
672+
*
673+
* @return $this
674+
*/
675+
public function addSingleClickPaymentApprovalText(LocalizedFallbackValue $singleClickPaymentApprovalText)
676+
{
677+
if (!$this->singleClickPaymentApprovalText->contains($singleClickPaymentApprovalText)) {
678+
$this->singleClickPaymentApprovalText->add($singleClickPaymentApprovalText);
679+
}
680+
681+
return $this;
682+
}
683+
684+
/**
685+
* @param LocalizedFallbackValue $singleClickPaymentApprovalText
686+
*
687+
* @return $this
688+
*/
689+
public function removeSingleClickPaymentApprovalText(LocalizedFallbackValue $singleClickPaymentApprovalText)
690+
{
691+
if ($this->singleClickPaymentApprovalText->contains($singleClickPaymentApprovalText)) {
692+
$this->singleClickPaymentApprovalText->removeElement($singleClickPaymentApprovalText);
693+
}
694+
695+
return $this;
696+
}
697+
698+
/**
699+
* @return Collection|LocalizedFallbackValue[]
700+
*/
701+
public function getSingleClickPaymentDescription()
702+
{
703+
return $this->singleClickPaymentDescription;
704+
}
705+
706+
/**
707+
* @param Collection|LocalizedFallbackValue[] $singleClickPaymentDescription
708+
*/
709+
public function setSingleClickPaymentDescription($singleClickPaymentDescription)
710+
{
711+
$this->singleClickPaymentDescription = $singleClickPaymentDescription;
712+
}
713+
714+
/**
715+
* @param LocalizedFallbackValue $singleClickPaymentDescription
716+
*
717+
* @return $this
718+
*/
719+
public function addSingleClickPaymentDescription(LocalizedFallbackValue $singleClickPaymentDescription)
720+
{
721+
if (!$this->singleClickPaymentDescription->contains($singleClickPaymentDescription)) {
722+
$this->singleClickPaymentDescription->add($singleClickPaymentDescription);
723+
}
724+
725+
return $this;
726+
}
727+
728+
/**
729+
* @param LocalizedFallbackValue $singleClickPaymentDescription
730+
*
731+
* @return $this
732+
*/
733+
public function removeSingleClickPaymentDescription(LocalizedFallbackValue $singleClickPaymentDescription)
734+
{
735+
if ($this->singleClickPaymentDescription->contains($singleClickPaymentDescription)) {
736+
$this->singleClickPaymentDescription->removeElement($singleClickPaymentDescription);
737+
}
738+
739+
return $this;
531740
}
532741

533742
/**

EventListener/ChannelSettingsListener.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,13 @@ protected function updatePaymentMethodConfigurations(ChannelSettings $channelSet
227227
);
228228
}
229229

230-
$paymentMethodConfig->setSurcharge($paymentMethodSetting->getSurcharge());
230+
$paymentMethodConfig->setSurchargeType($paymentMethodSetting->getSurchargeType());
231+
$paymentMethodConfig->setSurchargeFixedAmount($paymentMethodSetting->getSurchargeFixedAmount());
232+
$paymentMethodConfig->setSurchargePercentage($paymentMethodSetting->getSurchargePercentage());
233+
$paymentMethodConfig->setSurchargeLimit($paymentMethodSetting->getSurchargeLimit());
231234
$paymentMethodConfig->setApiMethod($paymentMethodSetting->getMethod());
232235
$paymentMethodConfig->setUseMollieComponents($paymentMethodSetting->getMollieComponents());
236+
$paymentMethodConfig->setUseSingleClickPayment($paymentMethodSetting->getSingleClickPayment());
233237
$paymentMethodConfig->setIssuerListStyle($paymentMethodSetting->getIssuerListStyle());
234238
$paymentMethodConfig->setDaysToOrderExpire($paymentMethodSetting->getOrderExpiryDays());
235239
$paymentMethodConfig->setDaysToPaymentExpire($paymentMethodSetting->getPaymentExpiryDays());

EventListener/CheckoutEntityListener.php

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Mollie\Bundle\PaymentBundle\EventListener;
44

55
use Mollie\Bundle\PaymentBundle\Entity\MollieSurchargeAwareInterface;
6+
use Mollie\Bundle\PaymentBundle\IntegrationCore\BusinessLogic\Surcharge\SurchargeService;
7+
use Mollie\Bundle\PaymentBundle\IntegrationCore\Infrastructure\ServiceRegister;
68
use Mollie\Bundle\PaymentBundle\PaymentMethod\Config\Provider\MolliePaymentConfigProviderInterface;
79
use Oro\Bundle\CheckoutBundle\Entity\Checkout;
810

@@ -49,10 +51,45 @@ protected function setSurcharge(Checkout $checkout)
4951
}
5052

5153
$paymentMethodConfig = $this->paymentConfigProvider->getPaymentConfig($checkout->getPaymentMethod());
52-
if ($paymentMethodConfig && $paymentMethodConfig->getSurchargeAmount() > 0) {
53-
$checkout->setMollieSurchargeAmount($paymentMethodConfig->getSurchargeAmount());
54+
55+
if ($paymentMethodConfig) {
56+
$surcharge = $this->getSurchargeService()->calculateSurchargeAmount(
57+
$paymentMethodConfig->getSurchargeType(),
58+
$paymentMethodConfig->getSurchargeFixedAmount(),
59+
$paymentMethodConfig->getSurchargePercentage(),
60+
$paymentMethodConfig->getSurchargeLimit(),
61+
$this->calculateSubtotal($checkout)
62+
);
63+
64+
$checkout->setMollieSurchargeAmount($surcharge);
5465
} else {
5566
$checkout->setMollieSurchargeAmount(null);
5667
}
5768
}
69+
70+
/**
71+
* @return SurchargeService
72+
*/
73+
protected function getSurchargeService()
74+
{
75+
/** @var SurchargeService $surchargeService */
76+
$surchargeService = ServiceRegister::getService(SurchargeService::CLASS_NAME);
77+
78+
return $surchargeService;
79+
}
80+
81+
/**
82+
* @param Checkout $checkout
83+
* @return float|int
84+
*/
85+
protected function calculateSubtotal(Checkout $checkout)
86+
{
87+
$subtotal = 0;
88+
$checkoutSubtotals = $checkout->getSubtotals();
89+
foreach ($checkoutSubtotals as $checkoutSubtotal) {
90+
$subtotal += $checkoutSubtotal->getSubtotal()->getAmount();
91+
}
92+
93+
return $subtotal;
94+
}
5895
}

0 commit comments

Comments
 (0)