Skip to content

Commit

Permalink
rebase main
Browse files Browse the repository at this point in the history
  • Loading branch information
hasanzade-hasan committed Aug 23, 2023
1 parent f0023d7 commit 1804548
Show file tree
Hide file tree
Showing 33 changed files with 278 additions and 105 deletions.
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
This changelog follows the specifications of https://keepachangelog.com. Please, follow the specs when adding a new entry

## [2.0.0] - 2023-08-22

### Added

- Support for Shopware 6.5.*

### Changed

- Refund and Capture cards on administration moved under Payment card in Details tab of the Order page

### Removed

- Removed support for Shopware 6.4.\*. Bug fixes for our plugin's 1.3.\* release will still be available for 6 months.

## [1.3.0] - 2023-08-09

### Added

- Feature to notify the existing customers when date of birth or gender fields are made required by the shop owner, while their account is missing this information. In such cases, customer will be redirected to the profile page to update their information and then proceed to checkout. This feature is not compatible with 3-step-checkout plugin in Shopware store, due to that plugin replacing the standard checkout page with a custom one.

### Fixed

- Fixed an issue in invoice payments where customer had no VAT IDs

## [1.2.0] - 2023-07-31

### Fixed

- Removal of trailing `/` character in APP_URL environment variable, in order to general webhook and return URLs correctly, when shop owner included a trailing `/` character in their domain in APP_URL.

## [1.1.0] - 2023-06-19

### Added

- Passing customer_id in payment requests to Better Payment API
- Captures
- Configuration option to automatically capture a transaction when an invoice document is created

## [1.0.0] - 2023-04-17

### Added

- Support Shopware 6.4.*
- Credit Card Payments
- SEPA Direct Debit B2C and B2B payments
- Invoice B2C and B2B Payments
- PayPal Payments
- Sofort Payments
- Paydirekt Payments
- Refunds for all payment methods
- Multi whitelabel(partner company) support
- Risk checks, including collection and configuration of DOB and Gender fields
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@

This repository contains the codebase for the official Better Payment API2 plugin for Shopware 6 platform.

## Wiki

Navigate to [our wiki page](https://github.com/better-payment/bp-plugin-shopware6-api2/wiki) for in depth explanation of available features and configurations that our plugin offers.

## Installation

Currently, plugin installation can only be done manually using a ZIP file. To receive the ZIP file, please contact the payment gateway support, as it's not yet published nor planned to be published in Shopware marketplace.
Currently, plugin installation can only be done manually using a ZIP file. You can download the ZIP files by going to [Github Releases](https://github.com/better-payment/bp-plugin-shopware6-api2/releases).

## Shopware and plugin versioning

For each Shopware minor release, we are releasing a major version.

We support Shopware 6.4 and onwards.

**Latest Releases for:**

- Shopware 6.5.* - [Plugin Version 2.0.0](https://github.com/better-payment/bp-plugin-shopware6-api2/releases/tag/2.0.0)

- Shopware 6.4.* - [Plugin Version 1.3.0](https://github.com/better-payment/bp-plugin-shopware6-api2/releases/tag/1.3.0)

If you are accessing the repository through Github, please [click here](https://github.com/better-payment/bp-plugin-shopware6-api2/archive/refs/heads/main.zip) to get the latest version of the plugin.

## Configuration

Expand All @@ -25,4 +40,4 @@ If you are accessing the repository through Github, please [click here](https://

## Support

Regarding any feature requests or bug reports, please contact [email protected].
Regarding any feature requests or bug reports, please contact [email protected] or open an issue in our [issue board](https://github.com/better-payment/bp-plugin-shopware6-api2/issues).
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "better-payment/bp-plugin-shopware6-api2",
"description": "Better Payment plugin to implement payment methods using API2",
"version": "1.1.0",
"version": "2.0.0",
"type": "shopware-platform-plugin",
"license": "proprietary",
"authors": [
Expand All @@ -10,7 +10,7 @@
}
],
"require": {
"shopware/core": "6.4.*"
"shopware/core": "6.5.*"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 11 additions & 9 deletions src/BetterPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use BetterPayment\Installer\PaymentMethodInstaller;
use BetterPayment\Installer\CustomFieldInstaller;
use BetterPayment\Installer\RuleInstaller;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
Expand Down Expand Up @@ -44,29 +44,31 @@ public function deactivate(DeactivateContext $deactivateContext): void
$this->getPaymentMethodInstaller()->deactivate($deactivateContext);
}

private function getRuleInstaller(): RuleInstaller
{
/** @var EntityRepository $ruleRepository */
$ruleRepository = $this->container->get('rule.repository');

return new RuleInstaller($ruleRepository);
}

public function getPaymentMethodInstaller(): PaymentMethodInstaller
{
/** @var PluginIdProvider $pluginIdProvider */
$pluginIdProvider = $this->container->get(PluginIdProvider::class);
/** @var EntityRepositoryInterface $paymentMethodRepository */
/** @var EntityRepository $paymentMethodRepository */
$paymentMethodRepository = $this->container->get('payment_method.repository');

return new PaymentMethodInstaller($pluginIdProvider, $paymentMethodRepository);
}

private function getCustomFieldInstaller(): CustomFieldInstaller
{
/** @var EntityRepositoryInterface $customFieldSetRepository */
/** @var EntityRepository $customFieldSetRepository */
$customFieldSetRepository = $this->container->get('custom_field_set.repository');

return new CustomFieldInstaller($customFieldSetRepository);
}

private function getRuleInstaller(): RuleInstaller
{
/** @var EntityRepositoryInterface $ruleRepository */
$ruleRepository = $this->container->get('rule.repository');

return new RuleInstaller($ruleRepository);
}
}
22 changes: 19 additions & 3 deletions src/EventSubscriber/CheckoutConfirmEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace BetterPayment\EventSubscriber;

use BetterPayment\Installer\CustomFieldInstaller;
use BetterPayment\PaymentHandler\InvoiceB2BHandler;
use BetterPayment\PaymentHandler\InvoiceHandler;
use BetterPayment\PaymentHandler\SEPADirectDebitB2BHandler;
use BetterPayment\PaymentHandler\SEPADirectDebitHandler;
use BetterPayment\Storefront\Struct\CheckoutData;
use BetterPayment\Util\ConfigReader;
use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Storefront\Page\Account\Order\AccountEditOrderPageLoadedEvent;
use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
Expand Down Expand Up @@ -35,7 +37,7 @@ public function addPaymentMethodSpecificFormFields(PageLoadedEvent $event): void
{
$page = $event->getPage();
$paymentMethod = $event->getSalesChannelContext()->getPaymentMethod();

$customer = $event->getSalesChannelContext()->getCustomer();

if ($paymentMethod->getHandlerIdentifier() == SEPADirectDebitHandler::class) {
$data = new CheckoutData();
Expand All @@ -45,6 +47,8 @@ public function addPaymentMethodSpecificFormFields(PageLoadedEvent $event): void
'creditorID' => $this->configReader->getString(ConfigReader::SEPA_DIRECT_DEBIT_CREDITOR_ID),
'companyName' => $this->configReader->getString(ConfigReader::SEPA_DIRECT_DEBIT_COMPANY_NAME),
'mandateReference' => Uuid::randomHex(),
'birthdayIsMissing' => $this->birthdayIsMissing($customer) && $this->configReader->getBool(ConfigReader::SEPA_DIRECT_DEBIT_COLLECT_DATE_OF_BIRTH),
'genderIsMissing' => $this->genderIsMissing($customer) && $this->configReader->getBool(ConfigReader::SEPA_DIRECT_DEBIT_COLLECT_GENDER),
]);

$page->addExtension(CheckoutData::EXTENSION_NAME, $data);
Expand All @@ -64,16 +68,18 @@ public function addPaymentMethodSpecificFormFields(PageLoadedEvent $event): void

// in invoice payment methods (b2c|b2b) only risk check agreement checkbox is added as form field when corresponding config is enabled
// that's why it also needs to check in if condition whether config is enabled before assigning related template view
elseif ($paymentMethod->getHandlerIdentifier() == InvoiceHandler::class && $this->configReader->getBool(ConfigReader::INVOICE_RISK_CHECK_AGREEMENT)) {
elseif ($paymentMethod->getHandlerIdentifier() == InvoiceHandler::class) {
$data = new CheckoutData();

$data->assign([
'template' => '@Storefront/betterpayment/invoice.html.twig',
'birthdayIsMissing' => $this->birthdayIsMissing($customer) && $this->configReader->getBool(ConfigReader::INVOICE_COLLECT_DATE_OF_BIRTH),
'genderIsMissing' => $this->genderIsMissing($customer) && $this->configReader->getBool(ConfigReader::INVOICE_COLLECT_GENDER),
]);

$page->addExtension(CheckoutData::EXTENSION_NAME, $data);
}
elseif ($paymentMethod->getHandlerIdentifier() == InvoiceB2BHandler::class && $this->configReader->getBool(ConfigReader::INVOICE_B2B_RISK_CHECK_AGREEMENT)) {
elseif ($paymentMethod->getHandlerIdentifier() == InvoiceB2BHandler::class) {
$data = new CheckoutData();

$data->assign([
Expand All @@ -83,4 +89,14 @@ public function addPaymentMethodSpecificFormFields(PageLoadedEvent $event): void
$page->addExtension(CheckoutData::EXTENSION_NAME, $data);
}
}

private function birthdayIsMissing(CustomerEntity $customer): bool
{
return !$customer->getBirthday();
}

private function genderIsMissing(CustomerEntity $customer): bool
{
return !$customer->getCustomFields()[CustomFieldInstaller::CUSTOMER_GENDER];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenEvent;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand All @@ -23,17 +23,17 @@
class OrderInvoiceDocumentCreatedEventSubscriber implements EventSubscriberInterface
{
private BetterPaymentClient $betterPaymentClient;
private EntityRepositoryInterface $orderRepository;
private EntityRepository $orderRepository;
private ConfigReader $configReader;

/**
* OrderInvoiceDocumentCreatedEventSubscriber constructor.
*
* @param BetterPaymentClient $betterPaymentClient
* @param EntityRepositoryInterface $orderRepository
* @param EntityRepository $orderRepository
* @param ConfigReader $configReader
*/
public function __construct(BetterPaymentClient $betterPaymentClient, EntityRepositoryInterface $orderRepository, ConfigReader $configReader)
public function __construct(BetterPaymentClient $betterPaymentClient, EntityRepository $orderRepository, ConfigReader $configReader)
{
$this->betterPaymentClient = $betterPaymentClient;
$this->orderRepository = $orderRepository;
Expand Down
6 changes: 3 additions & 3 deletions src/EventSubscriber/PluginConfigChangedEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use BetterPayment\Installer\CustomFieldInstaller;
use BetterPayment\Util\ConfigReader;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\System\CustomField\CustomFieldEntity;
use Shopware\Core\System\SystemConfig\Event\SystemConfigChangedEvent;
Expand All @@ -16,9 +16,9 @@ class PluginConfigChangedEventSubscriber implements EventSubscriberInterface
{
private ConfigReader $configReader;
private SystemConfigService $systemConfigService;
private EntityRepositoryInterface $customFieldRepository;
private EntityRepository $customFieldRepository;

public function __construct(ConfigReader $configReader, SystemConfigService $systemConfigService, EntityRepositoryInterface $customFieldRepository)
public function __construct(ConfigReader $configReader, SystemConfigService $systemConfigService, EntityRepository $customFieldRepository)
{
$this->configReader = $configReader;
$this->systemConfigService = $systemConfigService;
Expand Down
6 changes: 3 additions & 3 deletions src/Installer/CustomFieldInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace BetterPayment\Installer;

use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\System\CustomField\CustomFieldTypes;

Expand Down Expand Up @@ -82,9 +82,9 @@ class CustomFieldInstaller
// You can add more customer fields here
];

private EntityRepositoryInterface $customFieldSetRepository;
private EntityRepository $customFieldSetRepository;

public function __construct(EntityRepositoryInterface $customFieldSetRepository)
public function __construct(EntityRepository $customFieldSetRepository)
{
$this->customFieldSetRepository = $customFieldSetRepository;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Installer/PaymentMethodInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use BetterPayment\PaymentMethod\SEPADirectDebitB2B;
use BetterPayment\PaymentMethod\Sofort;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
Expand All @@ -35,13 +35,13 @@ class PaymentMethodInstaller
];

private PluginIdProvider $pluginIdProvider;
private EntityRepositoryInterface $paymentMethodRepository;
private EntityRepository $paymentMethodRepository;

/**
* @param PluginIdProvider $pluginIdProvider
* @param EntityRepositoryInterface $paymentMethodRepository
* @param EntityRepository $paymentMethodRepository
*/
public function __construct(PluginIdProvider $pluginIdProvider, EntityRepositoryInterface $paymentMethodRepository)
public function __construct(PluginIdProvider $pluginIdProvider, EntityRepository $paymentMethodRepository)
{
$this->pluginIdProvider = $pluginIdProvider;
$this->paymentMethodRepository = $paymentMethodRepository;
Expand Down
6 changes: 3 additions & 3 deletions src/Installer/RuleInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use BetterPayment\PaymentMethod\SEPADirectDebit;
use BetterPayment\PaymentMethod\SEPADirectDebitB2B;
use Shopware\Core\Checkout\Customer\Rule\IsCompanyRule;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Rule\Container\AndRule;

Expand All @@ -18,9 +18,9 @@ class RuleInstaller
private const CUSTOMER_IS_PRIVATE_RULE_ID = 'ea5c01b126ac4cd7861bc6daeff9bc3d';
private const CUSTOMER_IS_COMPANY_RULE_ID = 'fbac3618c6a2477ba079b31c07bb52fa';

private EntityRepositoryInterface $ruleRepository;
private EntityRepository $ruleRepository;

public function __construct(EntityRepositoryInterface $ruleRepository)
public function __construct(EntityRepository $ruleRepository)
{
$this->ruleRepository = $ruleRepository;
}
Expand Down
4 changes: 3 additions & 1 deletion src/PaymentHandler/CreditCardHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public function pay(AsyncPaymentTransactionStruct $transaction, RequestDataBag $
} catch (\Exception $e) {
throw new AsyncPaymentProcessException(
$transaction->getOrderTransaction()->getId(),
'An error occurred during the communication with external payment gateway' . PHP_EOL . $e->getMessage()
'An error occurred during the communication with external payment gateway' . PHP_EOL
. $e->getMessage() . PHP_EOL
. 'TRACE: ' . $e->getTraceAsString()
);
}

Expand Down
4 changes: 3 additions & 1 deletion src/PaymentHandler/InvoiceB2BHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public function pay(SyncPaymentTransactionStruct $transaction, RequestDataBag $d
} catch (\Exception $e) {
throw new SyncPaymentProcessException(
$transaction->getOrderTransaction()->getId(),
'An error occurred during the communication with external payment gateway' . PHP_EOL . $e->getMessage()
'An error occurred during the communication with external payment gateway' . PHP_EOL
. $e->getMessage() . PHP_EOL
. 'TRACE: ' . $e->getTraceAsString()
);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/PaymentHandler/InvoiceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public function pay(SyncPaymentTransactionStruct $transaction, RequestDataBag $d
} catch (\Exception $e) {
throw new SyncPaymentProcessException(
$transaction->getOrderTransaction()->getId(),
'An error occurred during the communication with external payment gateway' . PHP_EOL . $e->getMessage()
'An error occurred during the communication with external payment gateway' . PHP_EOL
. $e->getMessage() . PHP_EOL
. 'TRACE: ' . $e->getTraceAsString()
);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/PaymentHandler/PaydirektHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public function pay(AsyncPaymentTransactionStruct $transaction, RequestDataBag $
} catch (\Exception $e) {
throw new AsyncPaymentProcessException(
$transaction->getOrderTransaction()->getId(),
'An error occurred during the communication with external payment gateway' . PHP_EOL . $e->getMessage()
'An error occurred during the communication with external payment gateway' . PHP_EOL
. $e->getMessage() . PHP_EOL
. 'TRACE: ' . $e->getTraceAsString()
);
}

Expand Down
Loading

0 comments on commit 1804548

Please sign in to comment.