Skip to content

Commit

Permalink
Merge pull request #112 from logeecom/4.5-4.x
Browse files Browse the repository at this point in the history
Release version 3.0.24
  • Loading branch information
ivan-logeecom authored Oct 30, 2024
2 parents 58b4d77 + 4333e9f commit f8c5819
Show file tree
Hide file tree
Showing 26 changed files with 637 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Mollie\Gambio\CustomFields\Factory;

use Mollie\Gambio\CustomFields\Providers\AlmaCustomFieldsProvider;
use Mollie\Gambio\CustomFields\Providers\CreditCardCustomFieldsProvider;
use Mollie\Gambio\CustomFields\Providers\CustomFieldsProvider;
use Mollie\Gambio\CustomFields\Providers\IssuerListSupportedCustomFieldsProvider;
Expand Down Expand Up @@ -29,6 +30,10 @@ public static function getProvider($methodKey)
return new KlarnaCustomFieldsProvider($methodKey);
}

if (strpos($methodKey, 'mollie_alma') !== false) {
return new AlmaCustomFieldsProvider($methodKey);
}

if (strpos($methodKey, 'mollie_billie') !== false) {
return new BillieCustomFieldsProvider($methodKey);
}
Expand All @@ -41,7 +46,7 @@ public static function getProvider($methodKey)
return new CreditCardCustomFieldsProvider($methodKey);
}

if (in_array($methodKey, ['mollie_ideal', 'mollie_kbc', 'mollie_giftcard'], true)) {
if (in_array($methodKey, ['mollie_kbc', 'mollie_giftcard'], true)) {
return new IssuerListSupportedCustomFieldsProvider($methodKey);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Mollie\Gambio\CustomFields\Providers;

class AlmaCustomFieldsProvider extends CustomFieldsProvider
{
/**
* Renders all custom fields inputs (used for edit value)
*
* @return string
* @throws \Exception
*/
public function renderAllCustomFields()
{
return $this->renderLogoEdit() .
$this->renderMultiLangEdit() .
$this->renderApiEdit() .
$this->renderCountryZonesEdit() .
$this->renderSurchargeTypeSelection() .
$this->renderSurchargeEditFields();
}

/**
* @inheritDoc
*
* @return string
* @throws \Exception
*/
public function renderCustomOverviewFields()
{
return $this->renderLogoOverview() .
$this->renderMultiLangFieldsOverview() .
$this->renderApiOverview() .
$this->renderCountryZonesOverview().
$this->renderSurchargeTypeOverview() .
$this->renderSurchargeFieldsOverview();
}

/**
* @return string
*/
protected function renderApiEdit()
{
return '';
}

/**
* @return string
*/
protected function renderDaysToExpireOverview()
{
return '';
}
}
1 change: 1 addition & 0 deletions GXModules/Mollie/Mollie/Components/Mappers/OrderMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function getPayment($orderId)
$email = $sourceOrder->getCustomerEmail();
$phone = $sourceOrder->getCustomerTelephone();
$payment->setShippingAddress($this->getAddressData($sourceOrder->getDeliveryAddress(), $email, $phone));
$payment->setBillingAddress($this->getAddressData($sourceOrder->getBillingAddress(), $email, $phone));

$daysToExpire = $this->getDaysToExpirePayment($sourceOrder->getPaymentType()->getPaymentClass());
if (!empty($daysToExpire)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,17 @@ private function displayIssuers()
private function renderIssuerList()
{
$template = PathProvider::getShopTemplatePath('mollie_issuer_list.html');
$issuers = $this->_formatIssuers();

if ($this->paymentMethod->getId() === 'ideal') {
$issuers = array();
}

return mollie_render_template(
$template,
[
'payment_method' => $this->code,
'issuers' => $this->_formatIssuers(),
'issuers' => $issuers,
'list_type' => $this->issuerListType,
]
);
Expand Down
39 changes: 37 additions & 2 deletions GXModules/Mollie/Mollie/Shop/Javascripts/mollie-issuers.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
(function() {
(function () {
document.addEventListener("DOMContentLoaded", function () {
let issuerListWrappers = document.querySelectorAll('.mollie-issuer-list-wrapper');
const paymentMethods = document.querySelectorAll('input[type="radio"]');

//switch to iDeal 2.0 without issuers
paymentMethods.forEach(function (method) {
if (method.value.includes('mollie_')) {
if (method.value === 'mollie_ideal') {
if (method.checked) {
hideIdealCheckoutPaymentForm();
}
method.addEventListener('click', function () {
hideIdealCheckoutPaymentForm();
});
}
}
});

//in case if ideal is the only available payment method, it won't be shown as radio button but as li element
const issuerMethod = document.querySelector('li.mollie_ideal');
if (issuerMethod) {
hideIdealCheckoutPaymentForm();
}

for (let i = 0; i < issuerListWrappers.length; i++) {
addIssuerListListeners(issuerListWrappers[i]);
}

let checkoutForm = document.querySelector('#checkout_payment');
checkoutForm.addEventListener('submit', async event => {
//skip checking issuer selection for iDeal 2.0 payment method
let activeMethod = getActiveMethod();
if (activeMethod.classList.contains('mollie_ideal')) {
return;
}

if (!isIssuersSelected()) {
showIssuerErrorMessage();
event.preventDefault();
Expand Down Expand Up @@ -96,5 +124,12 @@
return document.querySelector('.list-group-item.active');
}

function hideIdealCheckoutPaymentForm() {
let checkoutPaymentForm = document.querySelector('.checkout-payment-form');
if (checkoutPaymentForm) {
checkoutPaymentForm.style.display = 'none';
}
}

});
})();
})();
4 changes: 2 additions & 2 deletions GXModules/Mollie/Mollie/composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "mollie/gambio",
"version": "3.0.23",
"version": "3.0.24",
"require": {
"php": ">=5.4",
"mollie/integration-core": "1.3.9"
"mollie/integration-core": "1.3.10"
},
"repositories": [
{
Expand Down
12 changes: 6 additions & 6 deletions GXModules/Mollie/Mollie/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions GXModules/Mollie/Mollie/vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"packages": [
{
"name": "mollie/integration-core",
"version": "1.3.9",
"version_normalized": "1.3.9.0",
"version": "1.3.10",
"version_normalized": "1.3.10.0",
"source": {
"type": "git",
"url": "[email protected]:mollie/orocore.git",
"reference": "8a07e5e317dfbffeaa552820ee843701a24a8fd5"
"reference": "c651e7ca353219121dbe13cca34fc02393a9cb2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mollie/orocore/zipball/8a07e5e317dfbffeaa552820ee843701a24a8fd5",
"reference": "8a07e5e317dfbffeaa552820ee843701a24a8fd5",
"url": "https://api.github.com/repos/mollie/orocore/zipball/c651e7ca353219121dbe13cca34fc02393a9cb2c",
"reference": "c651e7ca353219121dbe13cca34fc02393a9cb2c",
"shasum": ""
},
"require": {
Expand All @@ -24,7 +24,7 @@
"phpunit/phpunit": "^4.8.35",
"symfony/console": "^5.1"
},
"time": "2024-09-16T12:55:55+00:00",
"time": "2024-09-27T09:30:33+00:00",
"type": "library",
"installation-source": "source",
"autoload": {
Expand Down
14 changes: 7 additions & 7 deletions GXModules/Mollie/Mollie/vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php return array(
'root' => array(
'pretty_version' => '3.0.23',
'version' => '3.0.23.0',
'pretty_version' => '3.0.24',
'version' => '3.0.24.0',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -11,21 +11,21 @@
),
'versions' => array(
'mollie/gambio' => array(
'pretty_version' => '3.0.23',
'version' => '3.0.23.0',
'pretty_version' => '3.0.24',
'version' => '3.0.24.0',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => null,
'dev_requirement' => false,
),
'mollie/integration-core' => array(
'pretty_version' => '1.3.9',
'version' => '1.3.9.0',
'pretty_version' => '1.3.10',
'version' => '1.3.10.0',
'type' => 'library',
'install_path' => __DIR__ . '/../mollie/integration-core',
'aliases' => array(),
'reference' => '8a07e5e317dfbffeaa552820ee843701a24a8fd5',
'reference' => 'c651e7ca353219121dbe13cca34fc02393a9cb2c',
'dev_requirement' => false,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class Payment extends BaseDto
* @var Address
*/
protected $shippingAddress;
/**
* @var Address
*/
protected $billingAddress;
/**
* @var array
*/
Expand Down Expand Up @@ -134,10 +138,15 @@ public static function fromArray(array $raw)
$result->expiresAt = \DateTime::createFromFormat(DATE_ATOM, static::getValue($raw, 'expiresAt'));

$shippingAddress = static::getValue($raw, 'shippingAddress', array());
$billingAddress = static::getValue($raw, 'billingAddress', array());
if (!empty($shippingAddress)) {
$result->shippingAddress = Address::fromArray($shippingAddress);
}

if (!empty($billingAddress)) {
$result->billingAddress = Address::fromArray($billingAddress);
}

foreach ((array)static::getValue($raw, '_links', array()) as $linkKey => $linkData) {
$result->links[$linkKey] = Link::fromArray((array)$linkData);
}
Expand Down Expand Up @@ -200,6 +209,10 @@ public function toArray()
$result['shippingAddress'] = $this->shippingAddress->toArray();
}

if ($this->billingAddress) {
$result['billingAddress'] = $this->billingAddress->toArray();
}

return $result;
}

Expand Down Expand Up @@ -428,6 +441,22 @@ public function setShippingAddress($shippingAddress)
$this->shippingAddress = $shippingAddress;
}

/**
* @return Address
*/
public function getBillingAddress()
{
return $this->billingAddress;
}

/**
* @param Address $billingAddress
*/
public function setBillingAddress($billingAddress)
{
$this->billingAddress = $billingAddress;
}

/**
* @return array
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public function transformPayment(Payment $payment)
);

$shippingAddress = $payment->getShippingAddress();
$billingAddress = $payment->getBillingAddress();

if ($shippingAddress && $method === PaymentMethods::PayPal) {
$result['shippingAddress'] = array(
'streetAndNumber' => $shippingAddress->getStreetAndNumber(),
Expand All @@ -69,6 +71,20 @@ public function transformPayment(Payment $payment)
);
}

if ($billingAddress && $method === PaymentMethods::Alma) {
$result['billingAddress'] = array(
'streetAndNumber' => $billingAddress->getStreetAndNumber(),
'streetAdditional' => $billingAddress->getStreetAdditional(),
'city' => $billingAddress->getCity(),
'region' => $billingAddress->getRegion(),
'postalCode' => $billingAddress->getPostalCode(),
'country' => $billingAddress->getCountry(),
'givenName' => $billingAddress->getGivenName(),
'familyName' => $billingAddress->getFamilyName(),
'email' => $billingAddress->getEmail() ?: null
);
}

$result = array_merge($result, $this->getCommonPaymentParameters($payment));

return $result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class PaymentMethodConfig extends Entity
PaymentMethods::Klarna => self::API_METHOD_ORDERS,
PaymentMethods::Vouchers => self::API_METHOD_ORDERS,
PaymentMethods::Billie => self::API_METHOD_ORDERS,
PaymentMethods::Riverty => self::API_METHOD_ORDERS
PaymentMethods::Riverty => self::API_METHOD_ORDERS,
PaymentMethods::Alma => self::API_METHOD_PAYMENT
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ class PaymentMethods
const Klarna = 'klarna';
const Riverty = 'riverty';
const Trustly = 'trustly';
const Twint = 'twint';
const Alma = 'alma';
}
Loading

0 comments on commit f8c5819

Please sign in to comment.