Skip to content

Commit

Permalink
Release 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vttn committed Jun 20, 2020
1 parent 2d0438e commit e838ab2
Show file tree
Hide file tree
Showing 14 changed files with 267 additions and 232 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.1.1
- Stop default emails being sent
- Prettify payment page

# 1.1.0
- Handle empty/default Settings values
- Save refunds to db, and reload order tab on changes
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@
"wallee/sdk": "2.1.*"
},
"type": "shopware-platform-plugin",
"version": "1.1.0"
"version": "1.1.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class PaymentMethodConfigurationService {
*/
private $mediaSerializer;

private $languages;

/**
* PaymentMethodConfigurationService constructor.
*
Expand Down Expand Up @@ -366,13 +368,59 @@ function ($language) {
);
foreach ($locales as $locale) {
$translations[$locale] = [
'name' => $paymentMethodConfiguration->getResolvedTitle()[$locale] ?? $paymentMethodConfiguration->getName(),
'description' => $paymentMethodConfiguration->getResolvedDescription()[$locale] ?? $paymentMethodConfiguration->getName(),
'name' => $this->translate($paymentMethodConfiguration->getResolvedTitle(), $locale) ?? $paymentMethodConfiguration->getName(),
'description' => $this->translate($paymentMethodConfiguration->getResolvedDescription(), $locale) ?? '',
];
}
return $translations;
}

protected function translate($translatedString, $locale)
{
if (isset($translatedString[$locale])) {
return $translatedString[$locale];
}

$primaryLanguage = $this->findPrimaryLanguage($locale);
if ($primaryLanguage !== false && isset($translatedString[$primaryLanguage->getIetfCode()])) {
return $translatedString[$primaryLanguage->getIetfCode()];
}

if (isset($translatedString['en-US'])) {
return $translatedString['en-US'];
}

return null;
}

/**
* Returns the primary language in the given group.
*
* @param string $code
* @return \Wallee\Sdk\Model\RestLanguage
*/
protected function findPrimaryLanguage($code)
{
$code = substr($code, 0, 2);
foreach ($this->getLanguages() as $language) {
if ($language->getIso2Code() == $code && $language->getPrimaryOfGroup()) {
return $language;
}
}
return false;
}

protected function getLanguages()
{
if ($this->languages == null) {
$this->languages = $this
->apiClient
->getLanguageService()
->all();
}
return $this->languages;
}

/**
* @param \Shopware\Core\Framework\Context $context
* @return \Shopware\Core\System\Language\LanguageCollection
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Settings/Service/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getSettings(?string $salesChannelId = null): Settings
if ($property === '') {
continue;
}
if (empty($value)) {
if (!is_numeric($value) && empty($value)) {
$this->logger->warning(strtr('Empty value :value for settings :property.', [':property' => $property, ':value' => $value]));
}
$propertyValuePairs[$property] = $value;
Expand Down
17 changes: 15 additions & 2 deletions src/Core/Storefront/Checkout/Subscriber/CheckoutSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
use Psr\Log\LoggerInterface;
use Shopware\Core\{
Checkout\Order\OrderEntity,
Content\MailTemplate\Service\Event\MailBeforeValidateEvent};
Content\MailTemplate\Service\Event\MailBeforeSentEvent,
Content\MailTemplate\Service\Event\MailBeforeValidateEvent,
Framework\Struct\ArrayStruct};
use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use WalleePayment\Core\{
Expand Down Expand Up @@ -62,6 +64,7 @@ public static function getSubscribedEvents(): array
return [
CheckoutConfirmPageLoadedEvent::class => ['onConfirmPageLoaded', 1],
MailBeforeValidateEvent::class => ['onMailBeforeValidate', 1],
MailBeforeSentEvent::class => ['onMailBeforeSent', 1],
];
}

Expand All @@ -86,12 +89,22 @@ public function onMailBeforeValidate(MailBeforeValidateEvent $event): void
!$emailOriginIsWalleePayment &&
WalleePaymentHandler::class == $order->getTransactions()->first()->getPaymentMethod()->getHandlerIdentifier()
) {

$event->getContext()->addExtension('wallee-disable', new ArrayStruct());
$event->stopPropagation();
}
}
}

/**
* @param \Shopware\Core\Content\MailTemplate\Service\Event\MailBeforeSentEvent $event
*/
public function onMailBeforeSent(MailBeforeSentEvent $event): void
{
if ($event->getContext()->hasExtension('wallee-disable')) {
$event->stopPropagation();
}
}

/**
* @param \Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent $event
*/
Expand Down
135 changes: 50 additions & 85 deletions src/Resources/app/storefront/src/scss/base.scss
Original file line number Diff line number Diff line change
@@ -1,100 +1,65 @@
.wallee-payment {
ul.wallee-payment-panel {

display: none;
list-style-type: none;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
padding-inline-start: 0px;

li {
box-sizing: border-box;
font-weight: bold;
cursor: pointer;
list-style-position: outside;
border: 1px solid #f5f5f5;
padding: 5px;
margin: 5px 0;
.wallee-payment-panel {
position: relative;
}

> label {
display: block;
cursor: pointer;
margin-bottom: .5rem;
margin-top: .5rem;
margin-left: .25rem;
/* Center the loader */
#walleeLoader {
margin: 3em 0;

> img {
height: 1rem;
float: right;
div {
left: 50%;
top: 50%;
width: 7.5em;
height: 7.5em;
margin: 0 auto;
border: 0.5em solid #f3f3f3;
border-radius: 50%;
border-top: 0.5em solid #008490;
animation: spin 2s linear infinite;
-moz-animation: spin 2s linear infinite;
-webkit-animation: spin 2s linear infinite;
-o-animation: spin 2s linear infinite;
}
}
}
}

.wallee-payment-panel {
input[type="radio"][name="wallee_payment_handler"] {
box-sizing: border-box;
padding: 0;
position: fixed;
opacity: 0;
#confirmOrderForm {
overflow: hidden;
}
}

/* Center the loader */
#walleeLoader {
left: 50%;
top: 50%;
width: 7.5em;
height: 7.5em;
margin: 0 auto;
border: 0.5em solid #f3f3f3;
border-radius: 50%;
border-top: 0.5em solid #3eb0eb;
animation: spin 2s linear infinite;
-moz-animation: spin 2s linear infinite;
-webkit-animation: spin 2s linear infinite;
-o-animation: spin 2s linear infinite;
}

#confirmOrderForm {
overflow: hidden;
}

@-moz-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
@-moz-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
}

@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
}

@-o-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
@-o-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
}

@-webkit-keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
@-webkit-keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"wallee": {
"payHeader": "Bestellung bezahlen",
"payButton": "Zahlen"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"wallee": {
"payHeader": "Pay order",
"payButton": "Pay"
}
}

0 comments on commit e838ab2

Please sign in to comment.