Skip to content

Commit

Permalink
Added Apple pay and a switch to choose between Shopware standard fail…
Browse files Browse the repository at this point in the history
…ed payments or Mollie failed payments.
  • Loading branch information
milan-kiener committed Sep 23, 2020
1 parent a6a88f0 commit ba4438d
Show file tree
Hide file tree
Showing 99 changed files with 8,452 additions and 378 deletions.
27 changes: 25 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kiener/mollie-payments-plugin",
"description": "Mollie Payments",
"version": "v1.0.3",
"version": "v1.2.1",
"type": "shopware-platform-plugin",
"license": "MIT",
"authors": [
Expand All @@ -11,6 +11,8 @@
],
"require": {
"shopware/core": "*",
"shopware/administration": "*",
"shopware/storefront": "*",
"mollie/mollie-api-php": "^2.0"
},
"extra": {
Expand All @@ -25,12 +27,33 @@
"de-DE": "Mit Mollie integrieren Sie alle wichtigen internationalen und lokalen Zahlungsmethoden in nur einem Schritt in Ihren Shopware-Webshop. Starten Sie noch heute!",
"en-GB": "With Mollie you integrate every major global and local payment method in your Shopware webshop in one go. Start growing your business with effortless payments today!",
"nl-NL": "Met Mollie integreer je alle belangrijke internationale en lokale betaalmethoden in één keer in je Shopware webshop. Start vandaag nog!"
},
"manufacturerLink": {
"de-DE": "https://store.shopware.com/mollie.html",
"en-GB": "https://store.shopware.com/mollie.html",
"nl-NL": "https://store.shopware.com/mollie.html"
},
"supportLink": {
"de-DE": "https://www.mollie.com/contact",
"en-GB": "https://www.mollie.com/contact",
"nl-NL": "https://www.mollie.com/contact"
}
},
"config": {
"optimize-autoloader": true
},
"autoload": {
"psr-4": {
"Kiener\\MolliePayments\\": "src/",
"Mollie\\Api\\": "vendor/mollie/mollie-api-php/src/"
}
},
"suggest": {
"shopware/storefront": "Require '*'. Enables features like Creditcard Components and iDeal issuer selector.",
"shopware/administration": "Require '*'. Enables features like partial shipping and refunding."
},
"conflict": {
"shopware/storefront": "<6,>=7",
"shopware/administration": "<6,>=7"
}
}
}
33 changes: 0 additions & 33 deletions src/Config/Config.php

This file was deleted.

78 changes: 78 additions & 0 deletions src/Event/PaymentPageFailEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace Kiener\MolliePayments\Event;

use Mollie\Api\Resources\Order;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Framework\Context;
use Symfony\Contracts\EventDispatcher\Event;

class PaymentPageFailEvent extends Event
{
public const EVENT_NAME = 'mollie.payment.page.fail';

/**
* @var Context
*/
private $context;

/**
* @var OrderEntity|null
*/
private $shopwareOrder;

/**
* @var Order|null
*/
private $mollieOrder;

/**
* @var string|null
*/
private $salesChannelId;

/**
* @var string|null
*/
private $redirectUrl;

public function __construct(
Context $context,
?OrderEntity $shopwareOrder = null,
?Order $mollieOrder = null,
?string $salesChannelId = null,
?string $redirectUrl = null
)
{
$this->context = $context;
$this->shopwareOrder = $shopwareOrder;
$this->mollieOrder = $mollieOrder;
$this->salesChannelId = $salesChannelId;
$this->redirectUrl = $redirectUrl;
}

public function getContext(): Context
{
return $this->context;
}

public function getShopwareOrder(): ?OrderEntity
{
return $this->shopwareOrder;
}

public function getMollieOrder(): ?Order
{
return $this->mollieOrder;
}

public function getSalesChannelId(): ?string
{
return $this->salesChannelId;
}

public function getRedirectUrl(): ?string
{
return $this->redirectUrl;
}
}
78 changes: 78 additions & 0 deletions src/Event/PaymentPageRedirectEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace Kiener\MolliePayments\Event;

use Mollie\Api\Resources\Order;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Framework\Context;
use Symfony\Contracts\EventDispatcher\Event;

class PaymentPageRedirectEvent extends Event
{
public const EVENT_NAME = 'mollie.payment.page.redirect';

/**
* @var Context
*/
private $context;

/**
* @var OrderEntity|null
*/
private $shopwareOrder;

/**
* @var Order|null
*/
private $mollieOrder;

/**
* @var string|null
*/
private $salesChannelId;

/**
* @var string|null
*/
private $redirectUrl;

public function __construct(
Context $context,
?OrderEntity $shopwareOrder = null,
?Order $mollieOrder = null,
?string $salesChannelId = null,
?string $redirectUrl = null
)
{
$this->context = $context;
$this->shopwareOrder = $shopwareOrder;
$this->mollieOrder = $mollieOrder;
$this->salesChannelId = $salesChannelId;
$this->redirectUrl = $redirectUrl;
}

public function getContext(): Context
{
return $this->context;
}

public function getShopwareOrder(): ?OrderEntity
{
return $this->shopwareOrder;
}

public function getMollieOrder(): ?Order
{
return $this->mollieOrder;
}

public function getSalesChannelId(): ?string
{
return $this->salesChannelId;
}

public function getRedirectUrl(): ?string
{
return $this->redirectUrl;
}
}
94 changes: 57 additions & 37 deletions src/Factory/MollieApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,95 @@
namespace Kiener\MolliePayments\Factory;

use Exception;
use Kiener\MolliePayments\Config\Config;
use Kiener\MolliePayments\Service\ConfigService;
use Kiener\MolliePayments\Service\SettingsService;
use Kiener\MolliePayments\Setting\MollieSettingStruct;
use Mollie\Api\Exceptions\IncompatiblePlatform;
use Mollie\Api\MollieApiClient;
use Psr\Log\LoggerInterface;
use Shopware\Core\Framework\Context;
use Shopware\Core\Kernel;
use Symfony\Component\DependencyInjection\ContainerInterface;

class MollieApiFactory
{
/** @var ContainerInterface $container */
protected $container;
/** @var MollieApiClient */
private $apiClient;

/** @var Config $config */
protected $config;
/** @var SettingsService */
private $settingsService;

/** @var LoggerInterface */
protected $logger;

/** @var MollieApiClient $apiClient */
protected $apiClient;
private $logger;

/**
* Create a new instance of MollieApiFactory.
*
* @param ContainerInterface $container
* @param Config $config
* @param SettingsService $settingsService
* @param LoggerInterface $logger
*/
public function __construct(
ContainerInterface $container,
Config $config,
SettingsService $settingsService,
LoggerInterface $logger
)
{
$this->container = $container;
$this->config = $config;
$this->settingsService = $settingsService;
$this->logger = $logger;
}

/**
* Create a new instance of the Mollie API client.
*
* @throws \Mollie\Api\Exceptions\IncompatiblePlatform
* @param string|null $salesChannelId
*
* @return MollieApiClient
* @throws IncompatiblePlatform
*/
public function createClient()
public function createClient(?string $salesChannelId = null): MollieApiClient
{
if ($this->apiClient === null) {
$this->apiClient = new MollieApiClient();
$this->apiClient = $this->getClient($salesChannelId);
}

return $this->apiClient;
}

/**
* Returns a new instance of the Mollie API client.
*
* @param string|null $salesChannelId
* @param Context|null $context
*
* @return MollieApiClient
* @throws IncompatiblePlatform
*/
public function getClient(?string $salesChannelId = null, ?Context $context = null): MollieApiClient
{
/** @var MollieApiClient apiClient */
$this->apiClient = new MollieApiClient();

/** @var MollieSettingStruct $settings */
$settings = $this->settingsService->getSettings($salesChannelId, $context);

try {
// Set the API key
$this->apiClient->setApiKey(
$this->config::testMode() ? $this->config::testApiKey() : $this->config::liveApiKey()
);
try {
// Set the API key
$this->apiClient->setApiKey(
$settings->isTestMode() ? $settings->getTestApiKey() : $settings->getLiveApiKey()
);

// Add platform data
$this->apiClient->addVersionString(
'Shopware/' .
Kernel::SHOPWARE_FALLBACK_VERSION
);
// Add platform data
$this->apiClient->addVersionString(
'Shopware/' .
Kernel::SHOPWARE_FALLBACK_VERSION
);

// @todo Add plugin version variable
$this->apiClient->addVersionString(
'MollieShopware6/1.0.2'
);
} catch (Exception $e) {
$this->logger->error($e->getMessage(), [$e]);
}
// @todo Add plugin version variable
$this->apiClient->addVersionString(
'MollieShopware6/1.2.1'
);
} catch (Exception $e) {
$this->logger->error($e->getMessage(), [$e]);
}

return $this->apiClient;
}
}
}
Loading

0 comments on commit ba4438d

Please sign in to comment.