From c270055237d06d3018e342107f47f9540f97ed1f Mon Sep 17 00:00:00 2001 From: heidelpay-sp Date: Mon, 29 Jun 2020 10:15:56 +0200 Subject: [PATCH 1/4] * added informations and links to plugin manual --- README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cfd7c07..bae4e22 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,21 @@ # HeidelPayment -Heidelpay payment integration for Shopware 6 including the following payment methods: +Heidelpay payment integration for Shopware 6.2 including the following payment methods: * Credit Card +* SEPA direct debit +* Flexipay direct debit (secured) +* Prepayment * Invoice +* FlexiPay® Invoice B2C / B2B (secured, factoring) +* FlexiPay® Direct * SOFORT +* giropay * EPS +* iDEAL * PayPal -* Flexipay +* Alipay +* WeChat Pay + ## Installation ### For production @@ -27,8 +36,13 @@ This will automatically generate all files required for the plugin to work corre After the actual plugin installation it is necessary to add the new payment methods to the desired sales channel. Currently the only sales channel that is supported is the Storefront. +Further informations and configuration you can find in the manual at https://dev.heidelpay.de/handbuch-shopware-ab-6-2-version-0-0-1/ + ## Troubleshooting +#### Known Issues +> This plugin is a beta-release. For all known issues please have a look at https://dev.heidelpay.de/handbuch-shopware-ab-6-2-version-0-0-1/#Known_issues + #### JavaScript does not load correctly in the storefront > In this case it's required to run the command `./psh.phar storefront:build` manually in the shopware directory From 94ac257f4777e7e88fa2d23077f8ebd852b43e37 Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Mon, 29 Jun 2020 13:08:21 +0200 Subject: [PATCH 2/4] [HEIDELPAY-238] Adjust device collection - Add integration branch to package building - Fix PayPal output --- .gitlab-ci.yml | 1 + .../HeidelpayPaymentDeviceRepository.php | 9 ++-- ...delpayPaymentDeviceRepositoryInterface.php | 2 +- .../PaymentMethodPageEventListener.php | 4 +- .../Checkout/ConfirmPageEventListener.php | 8 ++-- .../heidelpay/frames/paypal.html.twig | 42 +++++++++---------- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b7f2dbc..4225ee6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -63,6 +63,7 @@ package: only: - tags - master + - integration* services: - mysql:5.7 script: diff --git a/src/DataAbstractionLayer/Repository/PaymentDevice/HeidelpayPaymentDeviceRepository.php b/src/DataAbstractionLayer/Repository/PaymentDevice/HeidelpayPaymentDeviceRepository.php index b0153ed..15fbe77 100644 --- a/src/DataAbstractionLayer/Repository/PaymentDevice/HeidelpayPaymentDeviceRepository.php +++ b/src/DataAbstractionLayer/Repository/PaymentDevice/HeidelpayPaymentDeviceRepository.php @@ -32,17 +32,20 @@ public function __construct(EntityRepositoryInterface $entityRepository, Address /** * {@inheritdoc} */ - public function getCollectionByCustomer(CustomerEntity $customer, string $deviceType, Context $context): EntitySearchResult + public function getCollectionByCustomer(CustomerEntity $customer, Context $context, string $deviceType = null): EntitySearchResult { $addressHash = $this->addressHashService->generateHash($customer->getActiveBillingAddress(), $customer->getActiveShippingAddress()); $criteria = new Criteria(); $criteria->addFilter( new EqualsFilter('heidelpay_payment_device.customerId', $customer->getId()), - new EqualsFilter('heidelpay_payment_device.addressHash', $addressHash), - new EqualsFilter('heidelpay_payment_device.deviceType', $deviceType) + new EqualsFilter('heidelpay_payment_device.addressHash', $addressHash) ); + if ($deviceType) { + $criteria->addFilter(new EqualsFilter('heidelpay_payment_device.deviceType', $deviceType)); + } + return $this->entityRepository->search($criteria, $context); } diff --git a/src/DataAbstractionLayer/Repository/PaymentDevice/HeidelpayPaymentDeviceRepositoryInterface.php b/src/DataAbstractionLayer/Repository/PaymentDevice/HeidelpayPaymentDeviceRepositoryInterface.php index d30bfae..a04b1da 100644 --- a/src/DataAbstractionLayer/Repository/PaymentDevice/HeidelpayPaymentDeviceRepositoryInterface.php +++ b/src/DataAbstractionLayer/Repository/PaymentDevice/HeidelpayPaymentDeviceRepositoryInterface.php @@ -12,7 +12,7 @@ interface HeidelpayPaymentDeviceRepositoryInterface { - public function getCollectionByCustomer(CustomerEntity $customer, string $deviceType, Context $context): EntitySearchResult; + public function getCollectionByCustomer(CustomerEntity $customer, Context $context, string $deviceType = null): EntitySearchResult; public function create(CustomerEntity $customer, string $deviceType, string $typeId, array $data, Context $context): EntityWrittenContainerEvent; diff --git a/src/EventListeners/Account/PaymentMethodPageEventListener.php b/src/EventListeners/Account/PaymentMethodPageEventListener.php index 0747629..9703b14 100644 --- a/src/EventListeners/Account/PaymentMethodPageEventListener.php +++ b/src/EventListeners/Account/PaymentMethodPageEventListener.php @@ -50,24 +50,22 @@ public function onLoadAccountPaymentMethod(AccountPaymentMethodPageLoadedEvent $ $registerPayPal = $this->configReader->read($salesChannelId)->get(ConfigReader::CONFIG_KEY_REGISTER_PAYPAL, false); $registerDirectDebit = $this->configReader->read($salesChannelId)->get(ConfigReader::CONFIG_KEY_REGISTER_DIRECT_DEBIT, false); $extension = new PaymentMethodPageExtension(); + $devices = $this->deviceRepository->getCollectionByCustomer($salesChannelContext->getCustomer(), $salesChannelContext->getContext()); $extension->setDeviceRemoved((bool) $event->getRequest()->get('deviceRemoved')); if ($registerCreditCards && $salesChannelContext->getCustomer() !== null) { - $devices = $this->deviceRepository->getCollectionByCustomer($salesChannelContext->getCustomer(), HeidelpayPaymentDeviceEntity::DEVICE_TYPE_CREDIT_CARD, $salesChannelContext->getContext()); $creditCards = $devices->filterByProperty('deviceType', HeidelpayPaymentDeviceEntity::DEVICE_TYPE_CREDIT_CARD)->getElements(); $extension->addPaymentDevices($creditCards); } if ($registerPayPal && $salesChannelContext->getCustomer() !== null) { - $devices = $this->deviceRepository->getCollectionByCustomer($salesChannelContext->getCustomer(), HeidelpayPaymentDeviceEntity::DEVICE_TYPE_PAYPAL, $salesChannelContext->getContext()); $payPalAccounts = $devices->filterByProperty('deviceType', HeidelpayPaymentDeviceEntity::DEVICE_TYPE_PAYPAL)->getElements(); $extension->addPaymentDevices($payPalAccounts); } if ($registerDirectDebit && $salesChannelContext->getCustomer() !== null) { - $devices = $this->deviceRepository->getCollectionByCustomer($salesChannelContext->getCustomer(), HeidelpayPaymentDeviceEntity::DEVICE_TYPE_DIRECT_DEBIT, $salesChannelContext->getContext()); $directDebitDevices = $devices->filterByProperty('deviceType', HeidelpayPaymentDeviceEntity::DEVICE_TYPE_DIRECT_DEBIT)->getElements(); $directDebitGuaranteedDevices = $devices->filterByProperty('deviceType', HeidelpayPaymentDeviceEntity::DEVICE_TYPE_DIRECT_DEBIT_GUARANTEED)->getElements(); diff --git a/src/EventListeners/Checkout/ConfirmPageEventListener.php b/src/EventListeners/Checkout/ConfirmPageEventListener.php index 148ecf4..1a0ba34 100644 --- a/src/EventListeners/Checkout/ConfirmPageEventListener.php +++ b/src/EventListeners/Checkout/ConfirmPageEventListener.php @@ -119,7 +119,7 @@ private function addCreditCardExtension(PageLoadedEvent $event): void return; } - $creditCards = $this->deviceRepository->getCollectionByCustomer($customer, HeidelpayPaymentDeviceEntity::DEVICE_TYPE_CREDIT_CARD, $event->getContext()); + $creditCards = $this->deviceRepository->getCollectionByCustomer($customer, $event->getContext(), HeidelpayPaymentDeviceEntity::DEVICE_TYPE_CREDIT_CARD); $extension = (new CreditCardPageExtension())->setDisplayCreditCardSelection(true); /** @var HeidelpayPaymentDeviceEntity $creditCard */ @@ -138,7 +138,7 @@ private function addPayPalExtension(PageLoadedEvent $event): void return; } - $payPalAccounts = $this->deviceRepository->getCollectionByCustomer($customer, HeidelpayPaymentDeviceEntity::DEVICE_TYPE_PAYPAL, $event->getContext()); + $payPalAccounts = $this->deviceRepository->getCollectionByCustomer($customer, $event->getContext(), HeidelpayPaymentDeviceEntity::DEVICE_TYPE_PAYPAL); $extension = (new PayPalPageExtension())->setDisplaypayPalAccountselection(true); /** @var HeidelpayPaymentDeviceEntity $payPalAccount */ @@ -157,7 +157,7 @@ private function addDirectDebitExtension(PageLoadedEvent $event): void return; } - $directDebitDevices = $this->deviceRepository->getCollectionByCustomer($customer, HeidelpayPaymentDeviceEntity::DEVICE_TYPE_DIRECT_DEBIT, $event->getContext()); + $directDebitDevices = $this->deviceRepository->getCollectionByCustomer($customer, $event->getContext(), HeidelpayPaymentDeviceEntity::DEVICE_TYPE_DIRECT_DEBIT); $extension = (new DirectDebitPageExtension())->setDisplayDirectDebitDeviceSelection(true); /** @var HeidelpayPaymentDeviceEntity $directDebitDevice */ @@ -176,7 +176,7 @@ private function addDirectDebitGuaranteedExtension(PageLoadedEvent $event): void return; } - $directDebitDevices = $this->deviceRepository->getCollectionByCustomer($customer, HeidelpayPaymentDeviceEntity::DEVICE_TYPE_DIRECT_DEBIT_GUARANTEED, $event->getContext()); + $directDebitDevices = $this->deviceRepository->getCollectionByCustomer($customer, $event->getContext(), HeidelpayPaymentDeviceEntity::DEVICE_TYPE_DIRECT_DEBIT_GUARANTEED); $extension = (new DirectDebitGuaranteedPageExtension())->setDisplayDirectDebitDeviceSelection(true); /** @var HeidelpayPaymentDeviceEntity $directDebitDevice */ diff --git a/src/Resources/views/storefront/component/heidelpay/frames/paypal.html.twig b/src/Resources/views/storefront/component/heidelpay/frames/paypal.html.twig index 6d8e283..08b1ebd 100644 --- a/src/Resources/views/storefront/component/heidelpay/frames/paypal.html.twig +++ b/src/Resources/views/storefront/component/heidelpay/frames/paypal.html.twig @@ -1,11 +1,11 @@ {% block heidelpay_frame_paypal_account %} - {% block heidelpay_checkout_confirm_frame_card_body_title %} -
- {{ context.paymentMethod.translated.name }} -
- {% endblock %} + {% if page.extensions.heidelpayPayPal.displayPayPalAccountSelection and page.extensions.heidelpayPayPal.payPalAccounts|length > 0 %} + {% block heidelpay_checkout_confirm_frame_card_body_title %} +
+ {{ context.paymentMethod.translated.name }} +
+ {% endblock %} - {% if page.extensions.heidelpayPayPal.displayPayPalAccountSelection %} - {% endfor %} - {% endblock %} - {% endif %} + {% block heidelpay_frame_paypal_account_saved_device %} + {# @var payPalAccount \HeidelPayment6\DataAbstractionLayer\Entity\PaymentDevice\HeidelpayPaymentDeviceEntity #} + {% for payPalAccount in page.extensions.heidelpayPayPal.payPalAccounts %} +
+ + +
+ {% endfor %} + {% endblock %} {% block heidelpay_frame_paypal_account_saved_device_new %}
From c46559e641ee1f24ea566e90040fb31c13db70b6 Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Mon, 29 Jun 2020 14:40:41 +0200 Subject: [PATCH 3/4] [HEIDELPAY-239] Add temporary quickfix for paid_partially -> paid transition --- .../AbstractTransitionMapper.php | 4 ++-- .../CreditCardTransitionMapper.php | 2 +- .../TransactionStateHandler.php | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Components/PaymentTransitionMapper/AbstractTransitionMapper.php b/src/Components/PaymentTransitionMapper/AbstractTransitionMapper.php index 0e4de28..a7042cc 100644 --- a/src/Components/PaymentTransitionMapper/AbstractTransitionMapper.php +++ b/src/Components/PaymentTransitionMapper/AbstractTransitionMapper.php @@ -55,7 +55,7 @@ protected function mapPaymentStatus(Payment $paymentObject): string } elseif ($paymentObject->isPartlyPaid()) { $status = StateMachineTransitionActions::ACTION_PAID_PARTIALLY; } elseif ($paymentObject->isPaymentReview() || $paymentObject->isCompleted()) { - $status = StateMachineTransitionActions::ACTION_PAID; + $status = StateMachineTransitionActions::ACTION_DO_PAY; } if ($this->isShipmentAllowed) { @@ -100,7 +100,7 @@ protected function checkForShipment(Payment $paymentObject, string $currentStatu } if ($shippedAmount === ($totalAmount - $cancelledAmount)) { - return StateMachineTransitionActions::ACTION_PAID; + return StateMachineTransitionActions::ACTION_DO_PAY; } if ($shippedAmount < ($totalAmount - $cancelledAmount)) { diff --git a/src/Components/PaymentTransitionMapper/CreditCardTransitionMapper.php b/src/Components/PaymentTransitionMapper/CreditCardTransitionMapper.php index 00a216c..527fc48 100644 --- a/src/Components/PaymentTransitionMapper/CreditCardTransitionMapper.php +++ b/src/Components/PaymentTransitionMapper/CreditCardTransitionMapper.php @@ -72,7 +72,7 @@ protected function mapForAuthorizeMode(Payment $paymentObject): string } if (count($paymentObject->getCharges()) > 0) { - return StateMachineTransitionActions::ACTION_PAID; + return StateMachineTransitionActions::ACTION_DO_PAY; } return $this->checkForRefund($paymentObject, $this->mapPaymentStatus($paymentObject)); diff --git a/src/Components/TransactionStateHandler/TransactionStateHandler.php b/src/Components/TransactionStateHandler/TransactionStateHandler.php index 4e79718..418d60f 100755 --- a/src/Components/TransactionStateHandler/TransactionStateHandler.php +++ b/src/Components/TransactionStateHandler/TransactionStateHandler.php @@ -90,6 +90,19 @@ protected function executeTransition(string $transactionId, string $transition, ), $context ); + + // If the previous state is "paid_partially", "paid" is currently not allowed as direct transition + if ($transition === StateMachineTransitionActions::ACTION_DO_PAY) { + $this->stateMachineRegistry->transition( + new Transition( + OrderTransactionDefinition::ENTITY_NAME, + $transactionId, + StateMachineTransitionActions::ACTION_PAID, + 'stateId' + ), + $context + ); + } } catch (IllegalTransitionException $exception) { // false positive handling (state to state) like open -> open, paid -> paid, etc. } From 9a4e6307e9ee9204b0c2f036f21f8158b95aea15 Mon Sep 17 00:00:00 2001 From: heidelpay-sp Date: Tue, 30 Jun 2020 07:57:41 +0200 Subject: [PATCH 4/4] * corrected a typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bae4e22..ff7b3a0 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ This will automatically generate all files required for the plugin to work corre After the actual plugin installation it is necessary to add the new payment methods to the desired sales channel. Currently the only sales channel that is supported is the Storefront. -Further informations and configuration you can find in the manual at https://dev.heidelpay.de/handbuch-shopware-ab-6-2-version-0-0-1/ +Further information and configuration you can find in the manual at https://dev.heidelpay.de/handbuch-shopware-ab-6-2-version-0-0-1/ ## Troubleshooting