Skip to content

Commit 5eb0701

Browse files
authored
Merge pull request #31 from logeecom/4.1
Release version 4.1.10
2 parents 064e63e + 9d463d3 commit 5eb0701

File tree

46 files changed

+2782
-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

+2782
-198
lines changed

Entity/PaymentMethodSettings.php

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

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

161204
/**
162205
* @var string
163206
*/
164-
private $surcharge;
207+
private $surchargePercentage;
165208

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

222+
/**
223+
* @var boolean
224+
*/
225+
private $singleClickPayment;
171226
/**
172227
* @var string
173228
*/
@@ -202,6 +257,8 @@ public function __construct()
202257
$this->descriptions = new ArrayCollection();
203258
$this->paymentDescriptions = new ArrayCollection();
204259
$this->transactionDescriptions = new ArrayCollection();
260+
$this->singleClickPaymentApprovalText = new ArrayCollection();
261+
$this->singleClickPaymentDescription = new ArrayCollection();
205262
}
206263

207264
/**
@@ -447,6 +504,70 @@ public function setEnabled($enabled)
447504
$this->enabled = $enabled;
448505
}
449506

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

498619
/**
499-
* @return string
620+
* @return mixed
500621
*/
501-
public function getSurcharge()
622+
public function getMollieComponents()
502623
{
503-
return $this->surcharge;
624+
return $this->mollieComponents;
504625
}
505626

506627
/**
507-
* @param string $surcharge
628+
* @param bool $mollieComponents
508629
*/
509-
public function setSurcharge($surcharge)
630+
public function setMollieComponents($mollieComponents)
510631
{
511-
$this->surcharge = $surcharge;
632+
$this->mollieComponents = $mollieComponents;
512633
}
513634

514635
/**
515636
* @return mixed
516637
*/
517-
public function getMollieComponents()
638+
public function getSingleClickPayment()
518639
{
519-
return $this->mollieComponents;
640+
return $this->singleClickPayment;
520641
}
521642

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

530739
/**

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
}

Form/EventListener/ChannelSettingsTypeSubscriber.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,27 @@ protected function setPaymentMethodConfigurations(ChannelSettings $channelSettin
413413
);
414414
}
415415

416+
if (!empty($paymentMethodSetting->getSingleClickPaymentApprovalText()) && $paymentMethodSetting->getSingleClickPaymentApprovalText()->isEmpty()) {
417+
$paymentMethodSetting->addSingleClickPaymentApprovalText(
418+
(new LocalizedFallbackValue())->setString($this->translator->trans('mollie.payment.config.payment_methods.single_click_payment_approval_text.value'))
419+
);
420+
}
421+
422+
if (!empty($paymentMethodSetting->getSingleClickPaymentDescription()) && $paymentMethodSetting->getSingleClickPaymentDescription()->isEmpty()) {
423+
$paymentMethodSetting->addSingleClickPaymentDescription(
424+
(new LocalizedFallbackValue())->setString($this->translator->trans('mollie.payment.config.payment_methods.single_click_payment_description.value'))
425+
);
426+
}
427+
416428
$paymentMethodSetting->setPaymentMethodConfig($paymentMethodConfig);
417429
$paymentMethodSetting->setEnabled($paymentMethodConfig->isEnabled());
418-
$paymentMethodSetting->setSurcharge($paymentMethodConfig->getSurcharge());
430+
$paymentMethodSetting->setSurchargeType($paymentMethodConfig->getSurchargeType());
431+
$paymentMethodSetting->setSurchargeFixedAmount($paymentMethodConfig->getSurchargeFixedAmount());
432+
$paymentMethodSetting->setSurchargePercentage($paymentMethodConfig->getSurchargePercentage());
433+
$paymentMethodSetting->setSurchargeLimit($paymentMethodConfig->getSurchargeLimit());
419434
$paymentMethodSetting->setMethod($paymentMethodConfig->getApiMethod());
420435
$paymentMethodSetting->setMollieComponents($paymentMethodConfig->useMollieComponents());
436+
$paymentMethodSetting->setSingleClickPayment($paymentMethodConfig->useSingleClickPayment());
421437
$paymentMethodSetting->setIssuerListStyle($paymentMethodConfig->getIssuerListStyle());
422438
$paymentMethodSetting->setVoucherCategory($paymentMethodConfig->getVoucherCategory());
423439
$paymentMethodSetting->setProductAttribute($paymentMethodConfig->getProductAttribute());

0 commit comments

Comments
 (0)