diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000..ec147dc --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,24 @@ +name: SonarQube Analysis + +on: + push: + branches: + - master + - develop + - "releases/**" + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: SonarQube Analysis + runs-on: ubuntu-latest + permissions: read-all + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} diff --git a/Magewire/Payment/Method/Afterpay20.php b/Magewire/Payment/Method/Afterpay20.php index ef8e90a..d0c6e0d 100644 --- a/Magewire/Payment/Method/Afterpay20.php +++ b/Magewire/Payment/Method/Afterpay20.php @@ -30,7 +30,7 @@ class Afterpay20 extends Component\Form implements EvaluationInterface public ?bool $tos = true; - public ?string $dateOfBirth = null; + public string $dateOfBirth = ''; public string $fullName = ''; @@ -93,7 +93,7 @@ public function mount(): void $this->coc = $payment->getAdditionalInformation('customer_coc'); $this->phone = $payment->getAdditionalInformation('customer_telephone'); $this->identificationNumber = $payment->getAdditionalInformation('customer_identificationNumber'); - $this->dateOfBirth = $payment->getAdditionalInformation('customer_DoB'); + $this->dateOfBirth = (string)$payment->getAdditionalInformation('customer_DoB'); $this->fullName = $this->getFullName(); } @@ -136,6 +136,7 @@ public function updatedCoc(string $value): ?string ['coc.digits_between' => 'Invalid COC number'] ); + $this->updatePaymentField('customer_DoB', '', ''); $this->updatePaymentField('customer_coc', $value); return $value; } @@ -194,9 +195,9 @@ private function getPhoneRules(): array * * @return void */ - private function updatePaymentField(string $name, $value): void + private function updatePaymentField(string $name, $value, $default = null): void { - $value = empty($value) ? null : $value; + $value = empty($value) ? $default : $value; try { $quote = $this->sessionCheckout->getQuote(); diff --git a/Magewire/Payment/Method/Giftcards.php b/Magewire/Payment/Method/Giftcards.php index a4cd20d..331620c 100644 --- a/Magewire/Payment/Method/Giftcards.php +++ b/Magewire/Payment/Method/Giftcards.php @@ -67,10 +67,11 @@ public function mount(): void public function evaluateCompletion(EvaluationResultFactory $resultFactory): EvaluationResultInterface { - if ($this->canSubmit === false) { + + if ($this->canSubmit === false && !$this->isRedirect()) { return $resultFactory->createErrorMessageEvent() ->withCustomEvent('payment:method:error') - ->withMessage('Cannot complete payment with voucher'); + ->withMessage('Cannot complete payment with giftcards'); } return $resultFactory->createSuccess(); diff --git a/Magewire/Payment/Method/PayPerEmail.php b/Magewire/Payment/Method/PayPerEmail.php index fa9140a..ac99729 100644 --- a/Magewire/Payment/Method/PayPerEmail.php +++ b/Magewire/Payment/Method/PayPerEmail.php @@ -69,7 +69,8 @@ public function __construct( */ public function mount(): void { - $payment = $this->getPayment(); + $quote = $this->getQuote(); + $payment = $quote->getPayment(); $firstName = $payment->getAdditionalInformation('customer_billingFirstName'); $lastName = $payment->getAdditionalInformation('customer_billingLastName'); @@ -77,7 +78,7 @@ public function mount(): void $email = $payment->getAdditionalInformation('customer_email'); $this->gender = $payment->getAdditionalInformation('customer_gender'); - $billingAddress = $this->getBillingAddress(); + $billingAddress = $quote->getBillingAddress(); if ($firstName === null) { $firstName = $billingAddress->getFirstname(); @@ -103,6 +104,7 @@ public function mount(): void $this->lastName = $lastName; $this->middleName = $middleName; $this->email = $email; + $this->quoteRepository->save($quote); } @@ -139,24 +141,26 @@ public function hydrateEmail() } /** - * Get payment from quote + * Get billing address from quote * - * @return Payment + * @return Address */ - private function getPayment() + private function getBillingAddress(): Address { - return $this->sessionCheckout->getQuote()->getPayment(); + return $this->sessionCheckout->getQuote()->getBillingAddress(); } + /** - * Get billing address from quote + * Get payment from quote * - * @return Address + * @return Payment */ - private function getBillingAddress(): Address + private function getPayment() { - return $this->sessionCheckout->getQuote()->getBillingAddress(); + return $this->sessionCheckout->getQuote()->getPayment(); } + /** * Validate single field with rules * diff --git a/Model/Form/Eav/Customer/Idin.php b/Model/Form/Eav/Customer/Hide.php similarity index 89% rename from Model/Form/Eav/Customer/Idin.php rename to Model/Form/Eav/Customer/Hide.php index 01d54a2..ab72044 100644 --- a/Model/Form/Eav/Customer/Idin.php +++ b/Model/Form/Eav/Customer/Hide.php @@ -6,7 +6,7 @@ use Hyva\Checkout\Model\Form\EntityField\EavAttributeField; -class Idin extends EavAttributeField +class Hide extends EavAttributeField { public function canRender(): bool { diff --git a/Model/Magewire/Payment/PlaceOrderService.php b/Model/Magewire/Payment/PlaceOrderService.php index c63f693..253d43d 100644 --- a/Model/Magewire/Payment/PlaceOrderService.php +++ b/Model/Magewire/Payment/PlaceOrderService.php @@ -49,4 +49,4 @@ private function hasRedirect(): bool $response = $this->getResponse(); return !empty($response->RequiredAction->RedirectURL); } -} \ No newline at end of file +} diff --git a/Model/Validation/Rules/Iban.php b/Model/Validation/Rules/Iban.php index f31d6ae..20cf248 100644 --- a/Model/Validation/Rules/Iban.php +++ b/Model/Validation/Rules/Iban.php @@ -41,7 +41,7 @@ public function check($value): bool $checksum %= 97; } - return ((98 - $checksum) == $check); + return (98 - $checksum) == $check; } else { return false; } diff --git a/README.md b/README.md index fc310e0..763929e 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,11 @@ # Buckaroo Magento Hyva Checkout +## Requirements + +Buckaroo Magento 2 plugin version 1.46 or heigher +Hyvä Checkout version 1.1.3 or heigher + ## Installation ``` mkdir app/code/Buckaroo @@ -11,7 +16,7 @@ cd app/code/Buckaroo git clone https://github.com/buckaroo-it/Magento2_Hyva_Checkout.git mv Magento2_Hyva_Checkout HyvaCheckout cd HyvaCheckout -git checkout 1.0.0-RC1 +git checkout 1.0.0 php bin/magento module:enable Buckaroo_HyvaCheckout php bin/magento setup:upgrade php bin/magento setup:static-content:deploy diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index e2e7895..a0c18c6 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -41,8 +41,9 @@ - \Buckaroo\HyvaCheckout\Model\Form\Eav\Customer\Idin - \Buckaroo\HyvaCheckout\Model\Form\Eav\Customer\Idin + \Buckaroo\HyvaCheckout\Model\Form\Eav\Customer\Hide + \Buckaroo\HyvaCheckout\Model\Form\Eav\Customer\Hide + \Buckaroo\HyvaCheckout\Model\Form\Eav\Customer\Hide diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv new file mode 100644 index 0000000..e69de29 diff --git a/i18n/es_ES.csv b/i18n/es_ES.csv new file mode 100644 index 0000000..e69de29 diff --git a/i18n/fr_FR.csv b/i18n/fr_FR.csv new file mode 100644 index 0000000..b629c34 --- /dev/null +++ b/i18n/fr_FR.csv @@ -0,0 +1,7 @@ +"MM/YY","MM/AA" +"Expiration:","Expiration :" +"Billing Middle Name:","Deuxième prénom (facturation):" +"Select giftcard issuer:","Sélectionner l'émetteur de la carte-cadeau:" +"PIN / Security code:","Code PIN / Code de sécurité:" +"Please select issuer","Veuillez sélectionner l'émetteur:" +"Voucher code:","Code du bon d'achat:" \ No newline at end of file diff --git a/i18n/nl_BE.csv b/i18n/nl_BE.csv new file mode 100644 index 0000000..9c8fa18 --- /dev/null +++ b/i18n/nl_BE.csv @@ -0,0 +1,7 @@ +"MM/YY","MM/JJ" +"Expiration:","Vervaldatum:" +"Billing Middle Name:","Tussenvoegsel voor facturatienaam:" +"Select giftcard issuer:","Selecteer Cadeaukaart:" +"PIN / Security code:","PIN-/beveiligingscode:" +"Please select issuer","Selecteer de uitgever" +"Voucher code:","Voucher code:" \ No newline at end of file diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv new file mode 100644 index 0000000..9c8fa18 --- /dev/null +++ b/i18n/nl_NL.csv @@ -0,0 +1,7 @@ +"MM/YY","MM/JJ" +"Expiration:","Vervaldatum:" +"Billing Middle Name:","Tussenvoegsel voor facturatienaam:" +"Select giftcard issuer:","Selecteer Cadeaukaart:" +"PIN / Security code:","PIN-/beveiligingscode:" +"Please select issuer","Selecteer de uitgever" +"Voucher code:","Voucher code:" \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..4b10ff8 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,9 @@ +# Unique key for the project +sonar.projectKey=Hyva-Checkout + +# Display name and version for the SonarQube UI +sonar.projectName=Hyva Checkout +sonar.projectVersion=1.0 + +# Path to the source code, relative to the sonar-project.properties file +sonar.sources=. \ No newline at end of file diff --git a/view/frontend/layout/hyva_checkout_components.xml b/view/frontend/layout/hyva_checkout_components.xml index 44e7300..69f5457 100644 --- a/view/frontend/layout/hyva_checkout_components.xml +++ b/view/frontend/layout/hyva_checkout_components.xml @@ -3,12 +3,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" > - - - - + + + + + + + + \ No newline at end of file diff --git a/view/frontend/templates/component/payment/before.phtml b/view/frontend/templates/component/payment/after.phtml similarity index 66% rename from view/frontend/templates/component/payment/before.phtml rename to view/frontend/templates/component/payment/after.phtml index af96475..0210427 100644 --- a/view/frontend/templates/component/payment/before.phtml +++ b/view/frontend/templates/component/payment/after.phtml @@ -1,17 +1,106 @@ +
+ +
-
- -
\ No newline at end of file + \ No newline at end of file diff --git a/view/frontend/templates/component/payment/method/afterpay.phtml b/view/frontend/templates/component/payment/method/afterpay.phtml index b91f1e4..34d6062 100644 --- a/view/frontend/templates/component/payment/method/afterpay.phtml +++ b/view/frontend/templates/component/payment/method/afterpay.phtml @@ -21,7 +21,13 @@ use Magento\Framework\Escaper; escapeHtml(__('Date of Birth:')); ?> * - + hasError('dateOfBirth')) : ?>
escapeHtmlAttr($magewire->getError('dateOfBirth')) ?>
@@ -47,8 +53,15 @@ use Magento\Framework\Escaper; showBusinessSelector()) { ?>
- - @@ -59,7 +72,7 @@ use Magento\Framework\Escaper; ?>
@@ -99,10 +112,14 @@ use Magento\Framework\Escaper; hasError('tos')) : ?>
escapeHtmlAttr($magewire->getError('tos')) ?>
-
\ No newline at end of file + diff --git a/view/frontend/templates/component/payment/method/afterpay20.phtml b/view/frontend/templates/component/payment/method/afterpay20.phtml index 85bb73b..793dfd8 100644 --- a/view/frontend/templates/component/payment/method/afterpay20.phtml +++ b/view/frontend/templates/component/payment/method/afterpay20.phtml @@ -11,7 +11,12 @@ use Magento\Framework\Escaper; - + showBirth()) { @@ -21,7 +26,12 @@ use Magento\Framework\Escaper; escapeHtml(__('Date of Birth:')); ?> * - + hasError('dateOfBirth')): ?>
escapeHtmlAttr($magewire->getError('dateOfBirth')) ?>
@@ -80,7 +90,11 @@ use Magento\Framework\Escaper; hasError('tos')): ?>
escapeHtmlAttr($magewire->getError('tos')) ?>
diff --git a/view/frontend/templates/component/payment/method/applepay.phtml b/view/frontend/templates/component/payment/method/applepay.phtml index e3687d3..1e229c8 100644 --- a/view/frontend/templates/component/payment/method/applepay.phtml +++ b/view/frontend/templates/component/payment/method/applepay.phtml @@ -86,16 +86,10 @@ use Magento\Framework\Escaper; this.config = this.$wire.get('config'); this.loadSdk().then(async () => { this.canDisplay = await BuckarooApplePay.checkPaySupport(); - const v = async () => { - if(this.canDisplay) { - await this.beginPayment(); - } + window.buckarooTask = async () => { + if(this.canDisplay) + await this.beginPayment(); }; - window.dispatchEvent(new CustomEvent('buckaroo-add-task', { - detail: { - buckarooTask: v - } - })); }); } }" x-init="register()" novalidate> @@ -104,4 +98,4 @@ use Magento\Framework\Escaper; escapeHtml(__('Place Order')) ?> - \ No newline at end of file + diff --git a/view/frontend/templates/component/payment/method/billink.phtml b/view/frontend/templates/component/payment/method/billink.phtml index eed7c65..c625951 100644 --- a/view/frontend/templates/component/payment/method/billink.phtml +++ b/view/frontend/templates/component/payment/method/billink.phtml @@ -38,7 +38,12 @@ use Magento\Framework\Escaper; escapeHtml(__('Date of Birth:')); ?> * - + hasError('dateOfBirth')) : ?>
escapeHtmlAttr($magewire->getError('dateOfBirth')) ?>
@@ -89,10 +94,15 @@ use Magento\Framework\Escaper; hasError('tos')) : ?>
escapeHtmlAttr($magewire->getError('tos')) ?>
- \ No newline at end of file + diff --git a/view/frontend/templates/component/payment/method/creditcard.phtml b/view/frontend/templates/component/payment/method/creditcard.phtml index 1e0e0f6..aa34d35 100644 --- a/view/frontend/templates/component/payment/method/creditcard.phtml +++ b/view/frontend/templates/component/payment/method/creditcard.phtml @@ -11,13 +11,14 @@ $issuers = $magewire->getIssuers();
displayAsSelect()) { ?> - + +
@@ -126,9 +129,18 @@ use Magento\Framework\Escaper; *
- +
- +
@@ -140,7 +152,14 @@ use Magento\Framework\Escaper; escapeHtml(__('Expiration:')); ?> * - +
@@ -148,7 +167,15 @@ use Magento\Framework\Escaper; escapeHtml(__('CVC / CVV:')); ?> * - +
diff --git a/view/frontend/templates/component/payment/method/giftcards.phtml b/view/frontend/templates/component/payment/method/giftcards.phtml index 330dbb9..20ad199 100644 --- a/view/frontend/templates/component/payment/method/giftcards.phtml +++ b/view/frontend/templates/component/payment/method/giftcards.phtml @@ -55,7 +55,6 @@ if (!$magewire->isRedirect()) { }, listenToSubmit() { this.$wire.on('giftcard_response', async (response) => { - console.log(response); if (response.error) { this.displayError(response.error); } else if(response.remainder_amount === undefined) { @@ -67,27 +66,29 @@ if (!$magewire->isRedirect()) { this.displaySuccess(response); } }) - }, + }, register() { this.listenToSubmit(); - const v = async () => { + window.buckarooTask = async () => { if(!this.canSubmit) { await this.submit(); } }; - window.dispatchEvent(new CustomEvent('buckaroo-add-task', { - detail: { - buckarooTask: v - } - })); - }, })" x-init="register()" novalidate>
- - getGiftcardIssuers() as $issuer) { @@ -107,17 +108,35 @@ if (!$magewire->isRedirect()) { escapeHtml(__('Card number:')); ?> * - +
- +
- + "; } diff --git a/view/frontend/templates/component/payment/method/giropay.phtml b/view/frontend/templates/component/payment/method/giropay.phtml index 238a042..9018652 100644 --- a/view/frontend/templates/component/payment/method/giropay.phtml +++ b/view/frontend/templates/component/payment/method/giropay.phtml @@ -15,9 +15,14 @@ $genders = $magewire->getGenderList(); escapeHtml(__('BIC Number')); ?> * - + hasError('bic')) : ?>
escapeHtmlAttr($magewire->getError('bic')) ?>
- \ No newline at end of file + diff --git a/view/frontend/templates/component/payment/method/ideal.phtml b/view/frontend/templates/component/payment/method/ideal.phtml index 8a0a398..2fff4b8 100644 --- a/view/frontend/templates/component/payment/method/ideal.phtml +++ b/view/frontend/templates/component/payment/method/ideal.phtml @@ -16,8 +16,7 @@ $issuers = $magewire->getIssuers(); - getIssuers(); - + hasError('firstName')) : ?>
escapeHtmlAttr($magewire->getError('firstName')) ?>
@@ -42,7 +47,12 @@ use Magento\Framework\Escaper; - +
@@ -50,7 +60,12 @@ use Magento\Framework\Escaper; escapeHtml(__('Billing Last Name:')); ?> * - + hasError('lastName')) : ?>
escapeHtmlAttr($magewire->getError('lastName')) ?>
@@ -61,9 +76,14 @@ use Magento\Framework\Escaper; escapeHtml(__('Email:')); ?> * - + hasError('email')) : ?>
escapeHtmlAttr($magewire->getError('email')) ?>
- \ No newline at end of file + diff --git a/view/frontend/templates/component/payment/method/sepaDirect.phtml b/view/frontend/templates/component/payment/method/sepaDirect.phtml index 08b8a89..c795244 100644 --- a/view/frontend/templates/component/payment/method/sepaDirect.phtml +++ b/view/frontend/templates/component/payment/method/sepaDirect.phtml @@ -37,7 +37,12 @@ use Magento\Framework\Escaper; escapeHtml(__('BIC Number')); ?> * - + hasError('bic')) : ?>
escapeHtmlAttr($magewire->getError('bic')) ?>
@@ -46,4 +51,4 @@ use Magento\Framework\Escaper; } ?> - \ No newline at end of file + diff --git a/view/frontend/templates/component/payment/method/tinka.phtml b/view/frontend/templates/component/payment/method/tinka.phtml index f1362d2..17bb733 100644 --- a/view/frontend/templates/component/payment/method/tinka.phtml +++ b/view/frontend/templates/component/payment/method/tinka.phtml @@ -11,7 +11,13 @@ use Magento\Framework\Escaper; - + showBirth()) { @@ -21,7 +27,13 @@ use Magento\Framework\Escaper; escapeHtml(__('Date of Birth:')); ?> * - + hasError('dateOfBirth')) : ?>
escapeHtmlAttr($magewire->getError('dateOfBirth')) ?>
@@ -45,4 +57,4 @@ use Magento\Framework\Escaper; } ?> - \ No newline at end of file + diff --git a/view/frontend/templates/component/payment/method/voucher.phtml b/view/frontend/templates/component/payment/method/voucher.phtml index 47b7d40..5cf9d1d 100644 --- a/view/frontend/templates/component/payment/method/voucher.phtml +++ b/view/frontend/templates/component/payment/method/voucher.phtml @@ -72,17 +72,11 @@ use Magento\Framework\Escaper; })); }, register() { - const v = async () => { + window.buckarooTask = async () => { if(!this.canSubmit) { await this.submit(); } }; - window.dispatchEvent(new CustomEvent('buckaroo-add-task', { - detail: { - buckarooTask: v - } - })); - }, })" x-init="register()" novalidate> @@ -91,10 +85,20 @@ use Magento\Framework\Escaper; escapeHtml(__('Voucher code:')); ?> * - + - + - \ No newline at end of file + diff --git a/view/frontend/templates/total-segments/empty.phtml b/view/frontend/templates/total-segments/empty.phtml index 784da93..a766f11 100644 --- a/view/frontend/templates/total-segments/empty.phtml +++ b/view/frontend/templates/total-segments/empty.phtml @@ -1,4 +1,2 @@ \ No newline at end of file