diff --git a/202001.0/de30702d-5a59-46d8-ada4-54cd2a9a55f4.md b/202001.0/de30702d-5a59-46d8-ada4-54cd2a9a55f4.md index 1c5aa0773..bc64f72f3 100644 --- a/202001.0/de30702d-5a59-46d8-ada4-54cd2a9a55f4.md +++ b/202001.0/de30702d-5a59-46d8-ada4-54cd2a9a55f4.md @@ -290,4 +290,68 @@ return $quoteTransfer; } ``` +13. Add checkout plugins of Payone in `Pyz\Zed\Checkout\CheckoutDependencyProvider`: + +```php +extend(static::CHECKOUT_PLUGINS, function (CheckoutPluginCollection $pluginCollection) { - $pluginCollection->add(new PayonePreCheckPlugin(), PayoneConfig::PROVIDER_NAME, static::CHECKOUT_PRE_CHECK_PLUGINS); - $pluginCollection->add(new PayoneSaveOrderPlugin(), PayoneConfig::PROVIDER_NAME, static::CHECKOUT_ORDER_SAVER_PLUGINS); - $pluginCollection->add(new PayonePostSaveHookPlugin(), PayoneConfig::PROVIDER_NAME, static::CHECKOUT_POST_SAVE_PLUGINS); - return $pluginCollection; - }); +/** + * This file is part of the Spryker Suite. + * For full license information, please view the LICENSE file that was distributed with this source code. + */ + +namespace Pyz\Zed\Checkout; + +//... +use SprykerEco\Zed\Payone\Communication\Plugin\Checkout\PayoneCheckoutDoSaveOrderPlugin; +use SprykerEco\Zed\Payone\Communication\Plugin\Checkout\PayoneCheckoutPostSavePlugin; +use SprykerEco\Zed\Payone\Communication\Plugin\Checkout\PayoneCheckoutPreConditionPlugin; + +class CheckoutDependencyProvider extends SprykerCheckoutDependencyProvider +{ + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutPreConditionPluginInterface[] + */ + protected function getCheckoutPreConditions(Container $container) + { + return [ + //... + new PayoneCheckoutPreConditionPlugin(), + //... + ]; + } + + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\Checkout\Dependency\Plugin\CheckoutSaveOrderInterface[]|\Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutDoSaveOrderInterface[] + */ + protected function getCheckoutOrderSavers(Container $container) + { + return [ + //... + new PayoneCheckoutDoSaveOrderPlugin(), + //... + ]; + } + + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutPostSaveInterface[] + */ + protected function getCheckoutPostHooks(Container $container) + { + return [ + //... + new PayoneCheckoutPostSavePlugin(), + //... + ]; + } + + //... +} ``` ## Integration with OMS module (OmsDependencyProvider) @@ -358,4 +411,4 @@ See [Disclaimer](https://github.com/spryker/spryker-documentation). --- For further information on this partner and integration into Spryker, please contact us. -
\ No newline at end of file +
diff --git a/202009.0/11393c45-b1f7-43b4-ba21-4e8334b88bab.md b/202009.0/11393c45-b1f7-43b4-ba21-4e8334b88bab.md index 4943b3f65..abd7c8ee2 100644 --- a/202009.0/11393c45-b1f7-43b4-ba21-4e8334b88bab.md +++ b/202009.0/11393c45-b1f7-43b4-ba21-4e8334b88bab.md @@ -6,43 +6,9 @@ Each payment method must provide payment amount it shares from order grand total ## Payment Hydration for Order The [Sales](https://documentation.spryker.com/v4/docs/sales) module provides plugins to hydrate OrderTransfer which is called when `SalesFacade::getOrderByIdSalesOrder` invoked. -One of those plugins are `\Spryker\Zed\Payment\Communication\Plugin\Sales\PaymentOrderHydratePlugin` which must be added to `\Pyz\Zed\Sales\SalesDependencyProvider::getOrderHydrationPlugins` plugin stack. +One of those plugins is `\Spryker\Zed\SalesPayment\Communication\Plugin\Sales\SalesPaymentOrderExpanderPlugin` which must be added to `\Pyz\Zed\Sales\SalesDependencyProvider::getOrderHydrationPlugins` plugin stack. -This plugin invokes the payment hydration plugin stack which must be injected to ` \Spryker\Zed\Payment\PaymentDependencyProvider::PAYMENT_HYDRATION_PLUGINS`, for example: - -```php -injectPaymentPlugin($container); - return $container; - } - /** - * @param \Spryker\Zed\Kernel\Container $container - * - * @return \Spryker\Zed\Kernel\Container - */ - protected function injectPaymentPlugin(Container $container) - { - $container->extend(PaymentDependencyProvider::PAYMENT_HYDRATION_PLUGINS, function (PaymentHydratorPluginCollectionInterface $pluginCollection) { - $pluginCollection->add(‘PaymentProvider’, new PaymentProviderSalesOrderPaymentHydrationPlugin()) // this plugin must implement \Spryker\Zed\Payment\Dependency\Plugin\Sales\PaymentHydratorPluginInterface - return $pluginCollection; - }); - return $container; - } -} -?> -``` - -The plugin will receive `OrderTransfer` and `PaymentTransfer` which is the payment you need to hydrate with additional data. +The plugin will receive `OrderTransfer` which is the payment you need to hydrate with additional data. Plugins have to populate the `PaymentTransfer` object and return it back. After this step you should be able to get payment information when calling `SalesFacade::getOrderByIdSalesOrder`. We also included simple Zed UI twig block for payments so it can display a little more information about payment methods used on the Order Detail page. diff --git a/202009.0/37595603-a37d-4550-a107-b58a0949e0b9.md b/202009.0/37595603-a37d-4550-a107-b58a0949e0b9.md index 00113d792..79bacb776 100644 --- a/202009.0/37595603-a37d-4550-a107-b58a0949e0b9.md +++ b/202009.0/37595603-a37d-4550-a107-b58a0949e0b9.md @@ -405,4 +405,68 @@ return $quoteTransfer; } ``` +13. Add checkout plugins of Payone in `Pyz\Zed\Checkout\CheckoutDependencyProvider`: + +```php +setIsSuccess(true); - - return true; - } - + /** + * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer + * @param \Generated\Shared\Transfer\CheckoutResponseTransfer $checkoutResponseTransfer + * + * @return bool + */ + public function checkCondition(QuoteTransfer $quoteTransfer, CheckoutResponseTransfer $checkoutResponseTransfer) + { + $checkoutResponseTransfer->setIsSuccess(true); + + return true; + } } ``` -**DirectDebitSaveOrderPlugin** +**PaymentMethodsDirectDebitCheckoutDoSaveOrderPlugin** ```php getFacade()->saveOrderPayment($quoteTransfer, $checkoutResponseTransfer); + $this->getFacade()->saveOrderPayment($quoteTransfer, $saveOrderTransfer); } - } - +} ``` -**DirectDebitPostCheckPlugin** +**PaymentMethodsDirectDebitCheckoutPostSavePlugin** ```php getFacade()->orderPostSave($quoteTransfer, $checkoutResponseTransfer); + } } ``` -2. Inject these 3 plugins in the `PaymentMethods` module by creating a `PaymentDependencyInjector` under the `Dependency/Injector/` folder: +2. Inject these 3 plugins in the `Checkout` module in the `CheckoutDependencyProvider` in the related stacks: **Code sample:** ```php injectPaymentPlugins($container); - - return $container; - } - - /** - * @param \Spryker\Zed\Kernel\Container $container - * - * @return \Spryker\Zed\Kernel\Container - */ - protected function injectPaymentPlugins(Container $container) - { - $container->extend(PaymentDependencyProvider::CHECKOUT_PLUGINS, function (CheckoutPluginCollection $pluginCollection) { - $pluginCollection->add(new DirectDebitPreCheckPlugin(), PaymentMethodsConstants::PROVIDER, PaymentDependencyProvider::CHECKOUT_PRE_CHECK_PLUGINS); - $pluginCollection->add(new DirectDebitSaveOrderPlugin(), PaymentMethodsConstants::PROVIDER, PaymentDependencyProvider::CHECKOUT_ORDER_SAVER_PLUGINS); - $pluginCollection->add(new DirectDebitPostCheckPlugin(), PaymentMethodsConstants::PROVIDER, PaymentDependencyProvider::CHECKOUT_POST_SAVE_PLUGINS); - - return $pluginCollection; - }); - - return $container; - } + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\Checkout\Dependency\Plugin\CheckoutSaveOrderInterface[]|\Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutDoSaveOrderInterface[] + */ + protected function getCheckoutOrderSavers(Container $container) + { + return [ + ... + new PaymentMethodsDirectDebitCheckoutDoSaveOrderPlugin(), + ]; + } + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutPostSaveInterface[] + */ + protected function getCheckoutPostHooks(Container $container) + { + return [ + ... + new PaymentMethodsDirectDebitCheckoutPostSavePlugin(), + ]; + } } ``` @@ -550,9 +546,6 @@ $config[KernelConstants::DEPENDENCY_INJECTOR_YVES] = [ ], ]; $config[KernelConstants::DEPENDENCY_INJECTOR_ZED] = [ - 'Payment' => [ - PaymentMethodsConstants::PROVIDER, - ], 'Oms' => [ PaymentMethodsConstants::PROVIDER, ], diff --git a/202009.0/ec995017-b790-46e4-ba14-2a072d8fc20d.md b/202009.0/ec995017-b790-46e4-ba14-2a072d8fc20d.md index 76c5a9f95..eb45a4901 100644 --- a/202009.0/ec995017-b790-46e4-ba14-2a072d8fc20d.md +++ b/202009.0/ec995017-b790-46e4-ba14-2a072d8fc20d.md @@ -30,10 +30,9 @@ spryker/product-management:"^0.12.0" | `GiftCardDiscountableItemFilterPlugin` |Restricts using a Gift Card for another Gift Cards in a cart. The plugin filters out Gift Cards from discountable items. |`DiscountDependencyProvider::getDiscountableItemFilterPlugins` | - | | `GiftCardIsUsedDecisionRulePlugin` | As a part of the replacement strategy, this plugin does not allow using a Gift Card twice. |`GiftCardDependencyProvider::getDecisionRulePlugins` | Replacement | | `GiftCardMetadataExpanderPlugin` | Populates Gift Card information when it is in the cart. | `CartDependencyProvider::getExpanderPlugins` | - | -| `GiftCardOrderItemSaverPlugin` | Saves a Gift Card with populated data when an order is placed. | `CheckoutDependencyProvider::getCheckoutOrderSavers` | - | -| `GiftCardOrderSaverPlugin` | Keeps Gift Card as an order payment method. | `PaymentDependencyProvider::extendPaymentPlugin` with a key `PaymentDependencyProvider::CHECKOUT_ORDER_SAVER_PLUGINS`| - | +| `GiftCardCheckoutDoSaveOrderPlugin` | Saves a Gift Card with populated data when an order is placed. Keeps Gift Card as an order payment method. | `CheckoutDependencyProvider::getCheckoutOrderSavers` | - | | `GiftCardPaymentMethodFilterPlugin` | Now, every payment method is compatible with a Gift Card in the cart. The plugin filters out all incompatible payment methods from available ones during checkout payment methods step. | `PaymentDependencyProvider::getPaymentMethodFilterPlugins` | - | -| `GiftCardPreCheckPlugin` | Confirms that a Gift Card is not used at the moment and that payment method amount assigned to the Gift Card is no more than the Gift Card amount itself. | `PaymentDependencyProvider::extendPaymentPlugin` with a key `PaymentDependencyProvider::CHECKOUT_PRE_CHECK_PLUGINS` | - | +| `GiftCardCheckoutPreConditionPlugin` | Confirms that a Gift Card is not used at the moment and that payment method amount assigned to the Gift Card is no more than the Gift Card amount itself.. | `CheckoutDependencyProvider::getCheckoutPreConditions` | - | | `GiftCardRecreateValueProviderPlugin` |For replacement: defines a Gift Card leftover. It’s simply a Gift Card amount for this strategy. | `GiftCardDependencyProvider::getValueProviderPlugin` | Replacement | | `CreateGiftCardCommandPlugin` | It is an order management system command to create a Gift Card based on a paid order item (a Gift Card item). | `OmsDependencyProvider::extendCommandPlugins` | - | | `ReplaceGiftCardsCommandPlugin` | For placement strategy: creates a new Gift Card based on leftover from the previous one. | `OmsDependencyProvider::extendCommandPlugins` | Replacement | @@ -46,7 +45,7 @@ spryker/product-management:"^0.12.0" | `GiftCardUsageMailTypePlugin` | Sends an e-mail on Gift Card usage to its user. | `MailDependencyProvider::MAIL_TYPE_COLLECTION` | - | | `ShipGiftCardByEmailCommandPlugin` | An order management system command which triggers Gift Card electronic shipment. |`OmsDependencyProvider::extendCommandPlugins` | - | | `NopaymentHandlerPlugin` | A payment method placeholder that is used when an order is paid by only a Gift Card without a real payment method. | `CheckoutDependencyProvider::extendPaymentMethodHandler` | - | -| `NopaymentPreCheckPlugin` | Doesn’t allow placing an order with a price to pay more than 0 with a NoPayment payment method. | `PaymentDependencyProvider::extendPaymentPlugins` with a key `PaymentDependencyProvider::CHECKOUT_ORDER_SAVER_PLUGINS` | - | +| `NopaymentCheckoutPreConditionPlugin` | Doesn’t allow placing an order with a price to pay more than 0 with a NoPayment payment method. | `CheckoutDependencyProvider::getCheckoutPreConditions` | - | | `PriceToPayPaymentMethodFilterPlugin` | Filters payment methods based on cart totals. | `PaymentDependencyProvider::getPaymentMethodFilterPlugins` | - | | `PaymentFormFilterPlugin` | Each payment method provides its subforms. The plugin filters them out based on an available payment method list. | `CheckoutDependencyProvider::getPaymentFormFilterPlugins` | - | | `PaymentCalculatorPlugin` | Distributes total prices to payment methods. Calculates price to pay to quote totals. | `CalculationDependencyProvider::getQuoteCalculatorPluginStack` | - | diff --git a/202009.0/f27f2d37-c023-47be-8b1c-f3f42c09c4cf.md b/202009.0/f27f2d37-c023-47be-8b1c-f3f42c09c4cf.md index eb49727d4..fe9a1e5d9 100644 --- a/202009.0/f27f2d37-c023-47be-8b1c-f3f42c09c4cf.md +++ b/202009.0/f27f2d37-c023-47be-8b1c-f3f42c09c4cf.md @@ -71,10 +71,6 @@ use Spryker\Zed\GiftCard\GiftCardConfig; // ---------- Dependency injector $config[KernelConstants::DEPENDENCY_INJECTOR_ZED] = [ - 'Payment' => [ - GiftCardConfig::PROVIDER_NAME, - NopaymentConfig::PAYMENT_PROVIDER_NAME, - ], 'Oms' => [ GiftCardConfig::PROVIDER_NAME, ], @@ -544,7 +540,9 @@ Add the following plugins to your project: | --- | --- | --- | --- | |`GiftCardCalculatorPlugin` | During quote recalculation, distinguishes applicable and non-applicable gift cards and creates payment methods for applicable gift cards. | - | `Spryker\Zed\GiftCard\Communication\Plugin` | | `GiftCardMetadataExpanderPlugin` | Extends gift card items with gift card configuration metadata to change cart items. | - | `Spryker\Zed\GiftCard\Communication\Plugin` | -| `GiftCardOrderItemSaverPlugin` | Saves gift card order data to the database. |- | `Spryker\Zed\GiftCard\Communication\Plugin` | +| `GiftCardCheckoutDoSaveOrderPlugin` | Saves gift cards items from the quote. Saves gift card payments from the quote. |- | `Spryker\Zed\GiftCard\Communication\Plugin\Checkout` | +| `GiftCardCheckoutPreConditionPlugin` | Returns true if QuoteTransfer.payments don't have GiftCard payments. Returns true if gift card was in use before and amount is valid. Returns false otherwise. |- | `\Spryker\Zed\GiftCard\Communication\Plugin\Checkout` | +| `NopaymentCheckoutPreConditionPlugin` | Returns true if there is no Nopayment payment provider in QuoteTransfer.payments otherwise does additional checks/logic. Returns true if QuoteTransfer.totals.priceToPay greater than 0 otherwise adds an error into CheckoutResponseTransfer and returns false. |- | `\Spryker\Zed\Nopayment\Communication\Plugin\Checkout` | | `GiftCardDiscountableItemFilterPlugin` | Filters gift card items from discountable items.|- | `Spryker\Zed\GiftCard\Communication\Plugin` | | `GiftCardDeliveryMailTypePlugin` | Provides a mail type for sending e-mails about successful gift card orders. |- | `Spryker\Zed\GiftCardMailConnector\Communication\Plugin\Mail` | | `Command\ShipGiftCardByEmailCommandPlugin` | Registers `GiftCardMailConnector/ShipGiftCard` OMS command that is used to deliver a gift card by e-mail. | Use `GiftCardDeliveryMailTypePlugin` above to register the necessary mail type. | `Spryker\Zed\GiftCardMailConnector\Communication\Plugin\Oms` | @@ -613,23 +611,46 @@ class CartDependencyProvider extends SprykerCartDependencyProvider namespace Pyz\Zed\Checkout; +... use Spryker\Zed\Checkout\CheckoutDependencyProvider as SprykerCheckoutDependencyProvider; -use Spryker\Zed\GiftCard\Communication\Plugin\GiftCardOrderItemSaverPlugin; +use Spryker\Zed\GiftCard\Communication\Plugin\Checkout\GiftCardCheckoutDoSaveOrderPlugin; +use Spryker\Zed\GiftCard\Communication\Plugin\Checkout\GiftCardCheckoutPreConditionPlugin; +use Spryker\Zed\Nopayment\Communication\Plugin\Checkout\NopaymentCheckoutPreConditionPlugin; use Spryker\Zed\Kernel\Container; +... class CheckoutDependencyProvider extends SprykerCheckoutDependencyProvider { /** * @param \Spryker\Zed\Kernel\Container $container * - * @return \Spryker\Zed\Checkout\Dependency\Plugin\CheckoutSaveOrderInterface[] + * @return \Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutPreConditionPluginInterface[] + */ + protected function getCheckoutPreConditions(Container $container) + { + return [ + ... + new GiftCardCheckoutPreConditionPlugin(), + new NopaymentCheckoutPreConditionPlugin(), + ... + ]; + } + + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\Checkout\Dependency\Plugin\CheckoutSaveOrderInterface[]|\Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutDoSaveOrderInterface[] */ protected function getCheckoutOrderSavers(Container $container) { return [ - new GiftCardOrderItemSaverPlugin(), + ... + new GiftCardCheckoutDoSaveOrderPlugin(), + ... ]; } + + ... } ``` @@ -803,9 +824,6 @@ Add the following plugins to your project: |`GiftCardUsageMailTypePlugin` | Provides a mail type for sending gift card usage information emails. | - | `Spryker\Zed\GiftCardMailConnector\Communication\Plugin\Mail`| |`PriceToPayPaymentMethodFilterPlugin` | Filters available payment methods based on the price-to-pay value of the quote. | - |`Spryker\Zed\Nopayment\Communication\Plugin\Payment` | | `GiftCardPaymentMethodFilterPlugin` | Filters blacklisted payment methods in case the quote contains a gift card to be purchased. |- | `Spryker\Zed\GiftCard\Communication\Plugin` | -| `GiftCardPreCheckPlugin` | Checks if a gift card payment method value is not bigger than the rest of the gift card value to be used to pay. | - | `Spryker\Zed\GiftCard\Communication\Plugin`| -| `GiftCardOrderSaverPlugin`| Saves a gift card payment to the database when an order is placed. | - | `Spryker\Zed\GiftCard\Communication\Plugin`| -|`NopaymentPreCheckPlugin`| Checks if a "Nopayment" payment method is allowed to be used. | - | `Spryker\Zed\Nopayment\Communication\Plugin\Checkout`| **src/Pyz/Client/CartCode/CartCodeDependencyProvider.php** @@ -844,6 +862,8 @@ use Spryker\Zed\Kernel\Container; class CheckoutDependencyProvider extends SprykerCheckoutDependencyProvider { + ... + /** * @param \Spryker\Zed\Kernel\Container $container * @@ -852,6 +872,7 @@ class CheckoutDependencyProvider extends SprykerCheckoutDependencyProvider protected function getCheckoutPostHooks(Container $container) { return [ + ... new SendEmailToGiftCardUser(), ]; } @@ -942,32 +963,13 @@ class MailDependencyProvider extends SprykerMailDependencyProvider namespace Pyz\Zed\Payment; -use Spryker\Shared\Nopayment\NopaymentConfig as SprykerNopaymentConfig; -use Spryker\Zed\GiftCard\Communication\Plugin\GiftCardOrderSaverPlugin; use Spryker\Zed\GiftCard\Communication\Plugin\GiftCardPaymentMethodFilterPlugin; -use Spryker\Zed\GiftCard\Communication\Plugin\GiftCardPreCheckPlugin; -use Spryker\Zed\GiftCard\GiftCardConfig as SprykerGiftCardConfig; use Spryker\Zed\Kernel\Container; -use Spryker\Zed\Nopayment\Communication\Plugin\Checkout\NopaymentPreCheckPlugin; use Spryker\Zed\Nopayment\Communication\Plugin\Payment\PriceToPayPaymentMethodFilterPlugin; -use Spryker\Zed\Payment\Dependency\Plugin\Checkout\CheckoutPluginCollectionInterface; use Spryker\Zed\Payment\PaymentDependencyProvider as SprykerPaymentDependencyProvider; class PaymentDependencyProvider extends SprykerPaymentDependencyProvider { - /** - * @param \Spryker\Zed\Kernel\Container $container - * - * @return \Spryker\Zed\Kernel\Container - */ - public function provideBusinessLayerDependencies(Container $container) - { - $container = parent::provideBusinessLayerDependencies($container); - $container = $this->extendPaymentPlugins($container); - - return $container; - } - /** * @return \Spryker\Zed\Payment\Dependency\Plugin\Payment\PaymentMethodFilterPluginInterface[] */ @@ -978,41 +980,6 @@ class PaymentDependencyProvider extends SprykerPaymentDependencyProvider new GiftCardPaymentMethodFilterPlugin(), ]; } - - /** - * @param \Spryker\Zed\Kernel\Container $container - * - * @return \Spryker\Zed\Kernel\Container - */ - protected function extendPaymentPlugins(Container $container): Container - { - $container->extend( - PaymentDependencyProvider::CHECKOUT_PLUGINS, - function (CheckoutPluginCollectionInterface $pluginCollection) { - $pluginCollection->add( - new GiftCardPreCheckPlugin(), - SprykerGiftCardConfig::PROVIDER_NAME, - PaymentDependencyProvider::CHECKOUT_PRE_CHECK_PLUGINS - ); - - $pluginCollection->add( - new GiftCardOrderSaverPlugin(), - SprykerGiftCardConfig::PROVIDER_NAME, - PaymentDependencyProvider::CHECKOUT_ORDER_SAVER_PLUGINS - ); - - $pluginCollection->add( - new NopaymentPreCheckPlugin(), - SprykerNopaymentConfig::PAYMENT_PROVIDER_NAME, - PaymentDependencyProvider::CHECKOUT_ORDER_SAVER_PLUGINS - ); - - return $pluginCollection; - } - ); - - return $container; - } } ```