From ae69372d1a56f57a6f533b5387363050df90b846 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Wed, 13 May 2020 16:30:02 -0300 Subject: [PATCH] :bug: now get saved card config from each payment method --- .../Payments/NewDebitCardPayment.php | 29 +++++++++++++++++++ .../Aggregates/Payments/NewVoucherPayment.php | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Payment/Aggregates/Payments/NewDebitCardPayment.php b/src/Payment/Aggregates/Payments/NewDebitCardPayment.php index f360b4b..88d3db1 100644 --- a/src/Payment/Aggregates/Payments/NewDebitCardPayment.php +++ b/src/Payment/Aggregates/Payments/NewDebitCardPayment.php @@ -11,6 +11,15 @@ class NewDebitCardPayment extends NewCreditCardPayment { + /** @var bool */ + private $saveOnSuccess; + + public function __construct() + { + $this->saveOnSuccess = false; + parent::__construct(); + } + static public function getBaseCode() { return PaymentMethod::debitCard()->getMethod(); @@ -30,4 +39,24 @@ public function setInstallments(int $installments) $this->installments = $installments; } + + public function isSaveOnSuccess() + { + $order = $this->getOrder(); + if ($order === null) { + return false; + } + + if (!MPSetup::getModuleConfiguration()->getDebitConfig()->isSaveCards()) { + return false; + } + + $customer = $this->getCustomer(); + + if ($customer === null) { + return false; + } + + return $this->saveOnSuccess; + } } \ No newline at end of file diff --git a/src/Payment/Aggregates/Payments/NewVoucherPayment.php b/src/Payment/Aggregates/Payments/NewVoucherPayment.php index 73a7b64..fa16d7a 100644 --- a/src/Payment/Aggregates/Payments/NewVoucherPayment.php +++ b/src/Payment/Aggregates/Payments/NewVoucherPayment.php @@ -30,7 +30,7 @@ public function isSaveOnSuccess() return false; } - if (!MPSetup::getModuleConfiguration()->isSaveCards()) { + if (!MPSetup::getModuleConfiguration()->getVoucherConfig()->isSaveCards()) { return false; }