Marketplace Dummy Payment

Edit on GitHub

This document describes how to integrate the Marketplace Dummy Payment feature into a Spryker project.

Install feature core

Follow the steps below to install the Marketplace Dummy Payment feature core.

Prerequisites

To start feature integration, integrate the required features:

NAME VERSION INTEGRATION GUIDE
Spryker Core 202108.0 Spryker Core feature integration
Payments 202108.0 Payments feature integration
Checkout 202108.0 Checkout feature integration
Marketplace Merchant 202108.0 Marketplace Merchant feature integration
Marketplace Order Management 202108.0 Marketplace Order Management feature integration

1) Install required modules using Сomposer

Install the required modules:

composer require spryker/dummy-marketplace-payment:^0.2.2 --update-with-dependencies
Verification

Make sure that the following modules have been installed:

MODULE EXPECTED DIRECTORY
DummyMarketplacePayment vendor/spryker/dummy-marketplace-payment

2) Set up configuration

Add the following configuration:

CONFIGURATION SPECIFICATION NAMESPACE
config_default-docker.php Default docker specific configuration of entire application config/Shared/config_default-docker.php
config_default.php Default configuration of entire application config/Shared/config_default.php

config/Shared/config_default-docker.php

use Spryker\Shared\DummyMarketplacePayment\DummyMarketplacePaymentConfig;


$config[OmsConstants::ACTIVE_PROCESSES] = [
    'MarketplacePayment01',
];
$config[SalesConstants::PAYMENT_METHOD_STATEMACHINE_MAPPING] = [
    DummyMarketplacePaymentConfig::PAYMENT_METHOD_DUMMY_MARKETPLACE_PAYMENT_INVOICE => 'MarketplacePayment01',
];

config/Shared/config_default.php

use Spryker\Shared\DummyMarketplacePayment\DummyMarketplacePaymentConfig;

$config[OmsConstants::ACTIVE_PROCESSES] = [
    'MarketplacePayment01',
];
$config[SalesConstants::PAYMENT_METHOD_STATEMACHINE_MAPPING] = [
    DummyMarketplacePaymentConfig::PAYMENT_METHOD_DUMMY_MARKETPLACE_PAYMENT_INVOICE => 'MarketplacePayment01',
];

3) Set up transfer objects

Run the following command:

console transfer:generate
Verification

Make sure that the following transfer objects are generated:

TRANSFER TYPE EVENT PATH
DummyMarketplacePayment class created src/Generated/Shared/Transfer/DummyMarketplacePayment
Payment.dummyMarketplacePaymentInvoice property created src/Generated/Shared/Transfer/Payment
Order.dummyMarketplacePaymentInvoice property created src/Generated/Shared/Transfer/Order

4) Set up behavior

Enable the following behaviors by registering the plugins:

PLUGIN DESCRIPTION PREREQUISITES NAMESPACE
MerchantProductItemPaymentMethodFilterPlugin If not all order items contain of product reference, then filters dummy marketplace payment methods out. Spryker\Zed\DummyMarketplacePayment\Communication\Plugin\Payment\MerchantProductItemPaymentMethodFilterPlugin

Pyz\Zed\Payment\PaymentDependencyProvider.php

<?php

namespace Pyz\Zed\Payment;

use Spryker\Zed\DummyMarketplacePayment\Communication\Plugin\Payment\MerchantProductItemPaymentMethodFilterPlugin;
use Spryker\Zed\Payment\PaymentDependencyProvider as SprykerPaymentDependencyProvider;


class PaymentDependencyProvider extends SprykerPaymentDependencyProvider
{
    /**
     * @return \Spryker\Zed\PaymentExtension\Dependency\Plugin\PaymentMethodFilterPluginInterface[]
     */
    protected function getPaymentMethodFilterPlugins(): array
    {
        return [
            new MerchantProductItemPaymentMethodFilterPlugin(),
        ];
    }
}

5) Import data

  1. Extend and import payment method data:

data/import/payment_method.csv

>payment_method_key,payment_method_name,payment_provider_key,payment_provider_name,is_active
dummyMarketplacePaymentInvoice,Invoice,DummyMarketplacePayment,Dummy Marketplace Payment,1
COLUMN REQUIRED? DATA TYPE DATA EXAMPLE DATA EXPLANATION
payment_method_key string dummyMarketplacePaymentInvoice Payment method key.
payment_method_name string Invoice Payment method name.
payment_provider_key string DummyMarketplacePayment Payment provider key.
payment_provider_name string Dummy Marketplace Payment Payment provider name.
is_active boolean 1 Is payment method active.
  1. Extend and import payment store data:

data/import/payment_method_store.csv

>payment_method_key,store
dummyMarketplacePaymentInvoice,DE
dummyMarketplacePaymentInvoice,AT
dummyMarketplacePaymentInvoice,US
COLUMN REQUIRED? DATA TYPE DATA EXAMPLE DATA EXPLANATION
payment_method_key string dummyMarketplacePaymentInvoice Payment method key.
store string DE Store identifier.
  1. Import data:
console data:import payment-method
console data:import payment-method-store
Verification

Make sure that the new payment method is added to the spy_payment_method and spy_payment_method_store tables in the database.

Install feature front end

Follow the steps below to install the Dummy Payment feature front end.

1) Add translations

Append glossary according to your configuration:

data/import/glossary.csv

DummyMarketplacePaymentInvoice,Invoice,en_US
DummyMarketplacePaymentInvoice,Auf Rechnung,de_DE
dummyMarketplacePaymentInvoice.invoice,Pay with invoice:,en_US
dummyMarketplacePaymentInvoice.invoice,Auf Rechnung bezahlen:,de_DE
checkout.payment.provider.DummyMarketplacePayment,Dummy Marketplace Payment,en_US
checkout.payment.provider.DummyMarketplacePayment,Beispiel Marktplatz Zahlungsmethode,de_DE

Import data:

console data:import glossary
Verification

Make sure that the configured data is added to the spy_glossary table in the database.

2) Set up behavior

Enable the following behaviors by registering the plugins:

PLUGIN DESCRIPTION PREREQUISITES NAMESPACE
DummyMarketplacePaymentHandlerPlugin Expands Payment transfer with payment provider and payment selection. Spryker\Yves\DummyMarketplacePayment\Plugin\StepEngine\DummyMarketplacePaymentHandlerPlugin
DummyMarketplacePaymentInvoiceSubFormPlugin Creates sub form for Invoice payment method. Spryker\Yves\DummyMarketplacePayment\Plugin\StepEngine\SubForm\DummyMarketplacePaymentInvoiceSubFormPlugin

Pyz\Yves\CheckoutPage\CheckoutPageDependencyProvider.php

<?php

namespace Pyz\Yves\CheckoutPage;

use Spryker\Shared\DummyMarketplacePayment\DummyMarketplacePaymentConfig;
use Spryker\Yves\DummyMarketplacePayment\Plugin\StepEngine\DummyMarketplacePaymentHandlerPlugin;
use Spryker\Yves\Kernel\Container;
use Spryker\Yves\StepEngine\Dependency\Plugin\Handler\StepHandlerPluginCollection;
use SprykerShop\Yves\CheckoutPage\CheckoutPageDependencyProvider as SprykerShopCheckoutPageDependencyProvider;

class CheckoutPageDependencyProvider extends SprykerShopCheckoutPageDependencyProvider
{
    /**
     * @param \Spryker\Yves\Kernel\Container $container
     *
     * @return \Spryker\Yves\Kernel\Container
     */
    protected function extendPaymentMethodHandler(Container $container): Container
    {
        $container->extend(static::PAYMENT_METHOD_HANDLER, function (StepHandlerPluginCollection $paymentMethodHandler) {
            $paymentMethodHandler->add(
                new DummyMarketplacePaymentHandlerPlugin(),
                DummyMarketplacePaymentConfig::PAYMENT_METHOD_DUMMY_MARKETPLACE_PAYMENT_INVOICE
            );

            return $paymentMethodHandler;
        });

        return $container;
    }

    /**
     * @param \Spryker\Yves\Kernel\Container $container
     *
     * @return \Spryker\Yves\Kernel\Container
     */
    protected function extendSubFormPluginCollection(Container $container): Container
    {
        $container->extend(static::PAYMENT_SUB_FORMS, function (SubFormPluginCollection $paymentSubFormPluginCollection) {
            $paymentSubFormPluginCollection->add(new DummyMarketplacePaymentInvoiceSubFormPlugin());

            return $paymentSubFormPluginCollection;
        });

        return $container;
    }
}
Verification

Add a merchant product to a shopping cart, go to checkout and make sure that Dummy Payment Invoice payment method is available.