Skip to content

Commit

Permalink
Created version 1.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinder committed Mar 23, 2020
1 parent 1953819 commit b4ab804
Show file tree
Hide file tree
Showing 412 changed files with 5,575 additions and 26,834 deletions.
439 changes: 439 additions & 0 deletions Client/composer.lock

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Client/vendor/mollie/mollie-api-php/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
level: 1
paths:
- %currentWorkingDirectory%/src
- %currentWorkingDirectory%/tests
- %currentWorkingDirectory%/examples
excludes_analyse:
- %currentWorkingDirectory%/vendor
includes:
- .phpstan.ignoreErrors.neon
36 changes: 0 additions & 36 deletions Commands/GetIdealBanksCommand.php

This file was deleted.

36 changes: 0 additions & 36 deletions Commands/GetPaymentMethodsCommand.php

This file was deleted.

2 changes: 1 addition & 1 deletion Components/MollieApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function create()

// add plugin name and version
$this->apiClient->addVersionString(
'MollieShopware/1.5.6'
'MollieShopware/1.5.8'
);
}
catch (\Exception $ex) {
Expand Down
7 changes: 5 additions & 2 deletions Components/Services/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ class PaymentMethodService
const PAYMENT_METHOD_ACTIVE = 'active';
const PAYMENT_METHOD_ADDITIONAL_DESCRIPTION = 'additionalDescription';
const PAYMENT_METHOD_DESCRIPTION = 'description';
const PAYMENT_METHOD_COUNTRIES = 'countries';
const PAYMENT_METHOD_NAME = 'name';
const PAYMENT_METHOD_POSITION = 'position';
const PAYMENT_METHOD_SURCHARGE = 'surcharge';
const PAYMENT_METHOD_TEMPLATE_DIR = __DIR__ . '/../../Resources/views/frontend/plugins/payment';

/** @var ModelManager */
Expand Down Expand Up @@ -135,16 +137,17 @@ public function installPaymentMethod($pluginName, array $methods)
// Retrieve existing information so it doesn't get overwritten
if (isset($method[self::PAYMENT_METHOD_NAME], $method[self::PAYMENT_METHOD_ACTION])) {
$existingMethod = $this->getPaymentMethod([
'name' => $method[self::PAYMENT_METHOD_NAME],
'action' => $method[self::PAYMENT_METHOD_ACTION]
self::PAYMENT_METHOD_NAME => $method[self::PAYMENT_METHOD_NAME],
]);
}

// Set existing data on method
if ($existingMethod !== null) {
$method[self::PAYMENT_METHOD_ADDITIONAL_DESCRIPTION] = (string) $existingMethod->getAdditionalDescription();
$method[self::PAYMENT_METHOD_COUNTRIES] = $existingMethod->getCountries();
$method[self::PAYMENT_METHOD_DESCRIPTION] = (string) $existingMethod->getDescription();
$method[self::PAYMENT_METHOD_POSITION] = $existingMethod->getPosition();
$method[self::PAYMENT_METHOD_SURCHARGE] = $existingMethod->getSurcharge();
}

// Install the payment method in Shopware
Expand Down
67 changes: 45 additions & 22 deletions Controllers/Frontend/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,40 +499,63 @@ private function updateTransactionId(Order $order, $transaction = null)
}

if ($transaction !== null) {
$transactionId = null;
$config = $this->getConfig();
$mollieApi = $this->getMollieApi();
$molliePayment = null;
$paymentTransactionNumber = null;
$transactionNumber = null;

if ((string) $transaction->getMolliePaymentId() !== '') {
$order->setTransactionId($transaction->getMolliePaymentId());
$transactionNumber = $transaction->getMolliePaymentId();

$config = $this->getConfig();

if (
$config !== null
&& $config->getTransactionNumberType() === $config::TRANSACTION_NUMBER_TYPE_PAYMENT_METHOD
) {
$mollieApi = $this->getMollieApi();

if ($mollieApi !== null) {
$molliePayment = $mollieApi->payments->get($transaction->getMolliePaymentId());
$transactionNumber = $transaction->getMolliePaymentId();
if ($mollieApi !== null) {
$molliePayment = $mollieApi->payments->get($transactionNumber);
}
}

if (isset($molliePayment->details->paypalReference)) {
$transactionNumber = $molliePayment->details->paypalReference;
}
if ((string) $transaction->getMollieId() !== '') {
$transactionNumber = $transaction->getMollieId();

if (isset($molliePayment->details->transferReference)) {
$transactionNumber = $molliePayment->details->transferReference;
}
if ($mollieApi !== null) {
$mollieOrder = $mollieApi->orders->get($transaction->getMollieId(), [
'embed' => 'payments'
]);

$order->setTransactionId($transactionNumber);
if (
$mollieOrder !== null
&& $mollieOrder->payments() !== null
&& $mollieOrder->payments()->count()
) {
$molliePayment = $mollieOrder->payments()[0];
}
}
}

if ((string) $transaction->getMollieId() !== '') {
$order->setTransactionId($transaction->getMollieId());
$paymentTransactionNumber = $transactionNumber;

if (
$molliePayment !== null
&& isset($molliePayment->details, $molliePayment->details->paypalReference)
) {
$paymentTransactionNumber = $molliePayment->details->paypalReference;
}

if (
$molliePayment !== null
&& isset($molliePayment->details, $molliePayment->details->transferReference)
) {
$paymentTransactionNumber = $molliePayment->details->transferReference;
}

if (
$config !== null
&& $config->getTransactionNumberType() === $config::TRANSACTION_NUMBER_TYPE_PAYMENT_METHOD
) {
$transactionNumber = $paymentTransactionNumber;
}

$order->setTransactionId($transactionNumber);

try {
/** @var \Shopware\Components\Model\ModelManager $modelManager */
$modelManager = Shopware()->Models();
Expand Down
34 changes: 34 additions & 0 deletions Resources/views/frontend/_public/src/js/applepay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function ($) {
"use strict";

$(document).ready(function() {
manageApplePay();
});

$(document).ajaxComplete(function() {
manageApplePay();
});

function manageApplePay() {
// Find the hidden Apple Pay element
var applePayInput = document.getElementsByClassName('payment-mean-mollie-applepay');
var applePayLabel = document.getElementsByClassName('payment-mean-mollie-applepay-label');

if (!window.ApplePaySession || !ApplePaySession.canMakePayments()) {
// Apple Pay is not available
if (typeof applePayInput !== 'undefined' && applePayInput.length) {
applePayInput[0].parentNode.parentNode.classList.add('is--hidden');
}
} else {
// Show Apple Pay option
if (typeof applePayInput !== 'undefined' && applePayInput.length) {
applePayInput[0].attributes.removeNamedItem('disabled');
}

if (typeof applePayLabel !== 'undefined' && applePayLabel.length) {
applePayLabel[0].classList.remove('is--soft');
applePayLabel[0].classList.remove('is--hidden');
}
}
}
}(jQuery));
24 changes: 2 additions & 22 deletions Resources/views/frontend/checkout/change_payment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,8 @@
{block name='frontend_checkout_payment_fieldset_input_radio'}
{if $payment_mean.name|lower == 'mollie_applepay'}
<div class="method--input">
<input type="radio" name="payment" class="radio auto_submit" disabled="disabled" value="{$payment_mean.id}" id="payment_mean{$payment_mean.id}" />
<input type="radio" name="payment" class="radio auto_submit payment-mean-{$payment_mean.name|lower|replace:"_":"-"}" disabled="disabled" value="{$payment_mean.id}" id="payment_mean{$payment_mean.id}" />
</div>

<script>
// Find the hidden Apple Pay element
const applePayInput = document.getElementById('payment_mean{$payment_mean.id}');
const applePayLabel = document.getElementById('payment_mean{$payment_mean.id}_label');
if (!window.ApplePaySession || !ApplePaySession.canMakePayments()) {
// Apple Pay is not available
if (typeof applePayInput !== 'undefined') {
applePayInput.parentNode.parentNode.classList.add('is--hidden');
}
} else {
// Show Apple Pay option
if (typeof applePayInput !== 'undefined')
applePayInput.attributes.removeNamedItem('disabled');
if (typeof applePayLabel !== 'undefined')
applePayLabel.classList.remove('is--soft');
}
</script>
{else}
{$smarty.block.parent}
{/if}
Expand All @@ -35,7 +15,7 @@
{block name='frontend_checkout_payment_fieldset_input_label'}
{if $payment_mean.name|lower == 'mollie_applepay'}
<div class="method--label is--first">
<label class="method--name is--strong is--soft" for="payment_mean{$payment_mean.id}" id="payment_mean{$payment_mean.id}_label">{$payment_mean.description}</label>
<label class="method--name is--strong is--soft payment-mean-{$payment_mean.name|lower|replace:"_":"-"}-label" for="payment_mean{$payment_mean.id}" id="payment_mean{$payment_mean.id}_label">{$payment_mean.description}</label>
</div>
{else}
{$smarty.block.parent}
Expand Down
24 changes: 21 additions & 3 deletions Subscriber/FrontendViewSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public static function getSubscribedEvents()
'Enlight_Controller_Action_PreDispatch' => 'addComponentsVariables',
'Enlight_Controller_Action_PreDispatch_Frontend' => 'addViewDirectory',
'Enlight_Controller_Action_PreDispatch_Frontend_Checkout'=>'getController',
'Theme_Compiler_Collect_Plugin_Less' => 'addLessFiles'
'Theme_Compiler_Collect_Plugin_Javascript' => 'onCollectJavascript',
'Theme_Compiler_Collect_Plugin_Less' => 'onCollectLess',
];
}

Expand Down Expand Up @@ -108,12 +109,29 @@ public function getController(Enlight_Event_EventArgs $args)
}

/**
* Provides the needed Less files
* Collects javascript files.
*
* @param Enlight_Event_EventArgs $args
* @return ArrayCollection
*/
public function addLessFiles(Enlight_Event_EventArgs $args)
public function onCollectJavascript(Enlight_Event_EventArgs $args)
{
// Create new array collection to add src files
$collection = new ArrayCollection();

// Add the javascript files to the collection
$collection->add(__DIR__ . '/../Resources/views/frontend/_public/src/js/applepay.js');

return $collection;
}

/**
* Collects Less files
*
* @param Enlight_Event_EventArgs $args
* @return ArrayCollection
*/
public function onCollectLess(Enlight_Event_EventArgs $args)
{
$lessFiles = [];
$lessFiles[] = __DIR__ . '/../Resources/views/frontend/_public/src/less/checkout.less';
Expand Down
56 changes: 0 additions & 56 deletions Subscribers/FrontendViewSubscriber.php

This file was deleted.

Loading

0 comments on commit b4ab804

Please sign in to comment.