Payments feature integration
Edit on GitHubThe current feature integration guide only adds the following functionalities:
- Payment Back Office UI;
- Payment method per store;
- Payment data import.
Install Feature Core
Prerequisites
To start the feature integration, overview and install the necessary features:
Name | Version |
---|---|
Spryker Core | 202001.0 |
1) Install the required modules using Composer
Run the following command(s) to install the required modules:
composer require "spryker-feature/payments:^202001.0" "spryker/checkout-rest-api:^3.0.0" --update-with-dependencies
Module | Expected Directory |
`PaymentDataImport` | `vendor/spryker/payment-data-import` |
`PaymentGui` | `vendor/spryker/payment-gui` |
2) Set up Database Schema and Transfer Objects
Run the following commands to apply database changes and generate entity and transfer changes:
console transfer:generate
console propel:install
console transfer:generate
Database Entity | Type | Event |
`spy_payment_method` | table | created |
`spy_payment_provider` | table | created |
`spy_payment_method_store` | table | created |
Transfer | Type | Event | Path |
`PaymentMethodTransfer` | class | created | `src/Generated/Shared/Transfer/PaymentMethodTransfer` |
`PaymentProviderTransfer` | class | created | `src/Generated/Shared/Transfer/PaymentProviderTransfer` |
`PaymentMethodResponseTransfer` | class | created | `src/Generated/Shared/Transfer/PaymentMethodResponseTransfer` |
`StoreTransfer` | class | created | `src/Generated/Shared/Transfer/StoreTransfer` |
`DataImporterConfigurationTransfer` | class | created | `src/Generated/Shared/Transfer/DataImporterConfigurationTransfer` |
`DataImporterReaderConfigurationTransfer` | class | created | `src/Generated/Shared/Transfer/DataImporterReaderConfigurationTransfer` |
`DataImporterReportTransfer` | class | created | `src/Generated/Shared/Transfer/DataImporterReportTransfer` |
`DataImporterReportMessageTransfer` | class | created | `src/Generated/Shared/Transfer/DataImporterReportMessageTransfer` |
3) Import Data
Import Payment Methods
Prepare your data according to your requirements using our demo data:
data/import/payment_method.csv
payment_method_key,payment_method_name,payment_provider_key,payment_provider_name,is_active
dummyPaymentInvoice,Invoice,dummyPayment,Dummy Payment,1
dummyPaymentCreditCard,Credit Card,dummyPayment,Dummy Payment,1
Column | REQUIRED | Data Type | Data Example | Data Explanation |
---|---|---|---|---|
payment_method_key |
mandatory | string | dummyPaymentInvoice | Key of a payment method. |
payment_method_name |
mandatory | string | Invoice | Name of a payment method. |
payment_provider_key |
mandatory | string | dummyPayment | Key of a payment provider. |
payment_provider_name |
mandatory | string | Dummy Payment | Name of a payment provider. |
is_active |
optional | boolean | 1 | Indicates if this payment method is available. |
data/import/payment_method_store.csv
payment_method_key,store
dummyPaymentInvoice,DE
dummyPaymentInvoice,AT
dummyPaymentInvoice,US
dummyPaymentCreditCard,DE
dummyPaymentCreditCard,AT
dummyPaymentCreditCard,US
Column | REQUIRED | Data Type | Data Example | Data Explanation |
---|---|---|---|---|
payment_method_key |
mandatory | string | dummyPaymentInvoice | Key of the existing payment method. |
store |
mandatory | string | DE | Name of the existing store. |
Register the following plugin data import plugins:
Plugin | Specification | Prerequisites | Namespace |
---|---|---|---|
PaymentMethodDataImportPlugin |
Imports payment method data into the database. | None | \Spryker\Zed\PaymentDataImport\Communication\Plugin |
PaymentMethodStoreDataImportPlugin |
Imports payment method store data into the database. | None | \Spryker\Zed\PaymentDataImport\Communication\Plugin |
src/Pyz/Zed/DataImport/DataImportDependencyProvider.php
<?php
namespace Pyz\Zed\DataImport;
use Spryker\Zed\DataImport\DataImportDependencyProvider as SprykerDataImportDependencyProvider;
use Spryker\Zed\PaymentDataImport\Communication\Plugin\PaymentMethodDataImportPlugin;
use Spryker\Zed\PaymentDataImport\Communication\Plugin\PaymentMethodStoreDataImportPlugin;
class DataImportDependencyProvider extends SprykerDataImportDependencyProvider
{
/**
* @return array
*/
protected function getDataImporterPlugins(): array
{
return [
new PaymentMethodDataImportPlugin(),
new PaymentMethodStoreDataImportPlugin(),
];
}
}
Enable the behaviors by registering the console commands:
src/Pyz/Zed/Console/ConsoleDependencyProvider.php
<?php
namespace Pyz\Zed\Console;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\Console\ConsoleDependencyProvider as SprykerConsoleDependencyProvider;
use Spryker\Zed\DataImport\Communication\Console\DataImportConsole;
use Spryker\Zed\PaymentDataImport\PaymentDataImportConfig;
class ConsoleDependencyProvider extends SprykerConsoleDependencyProvider
{
/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Symfony\Component\Console\Command\Command[]
*/
protected function getConsoleCommands(Container $container)
{
$commands = [
new DataImportConsole(DataImportConsole::DEFAULT_NAME . ':' . PaymentDataImportConfig::IMPORT_TYPE_PAYMENT_METHOD),
new DataImportConsole(DataImportConsole::DEFAULT_NAME . ':' . PaymentDataImportConfig::IMPORT_TYPE_PAYMENT_METHOD_STORE),
];
return $commands;
}
}
Run the following console command to import data:
console data:import:payment-method
console data:import:payment-method-store
4) Set up Behavior
Configure the data import to use your data on the project level.
src/Pyz/Zed/PaymentDataImport/PaymentDataImportConfig
<?php
namespace Pyz\Zed\PaymentDataImport;
use Generated\Shared\Transfer\DataImporterConfigurationTransfer;
use Spryker\Zed\PaymentDataImport\PaymentDataImportConfig as SprykerPaymentDataImportConfig;
class PaymentDataImportConfig extends SprykerPaymentDataImportConfig
{
/**
* @return \Generated\Shared\Transfer\DataImporterConfigurationTransfer
*/
public function getPaymentMethodDataImporterConfiguration(): DataImporterConfigurationTransfer
{
return $this->buildImporterConfiguration('payment_method.csv', static::IMPORT_TYPE_PAYMENT_METHOD);
}
/**
* @return \Generated\Shared\Transfer\DataImporterConfigurationTransfer
*/
public function getPaymentMethodAtoreDataImporterConfiguration(): DataImporterConfigurationTransfer
{
return $this->buildImporterConfiguration('payment_method_store.csv', static::IMPORT_TYPE_PAYMENT_METHOD_STORE);
}
}
Configure the Payment GUI module with money and store plugins.
Plugin | Specification | Prerequisites | Namespace |
---|---|---|---|
StoreRelationToggleFormTypePlugin |
Represents a store relation toggle form based on stores registered in the system. | None | Spryker\Zed\Store\Communication\Plugin\Form |
src/Pyz/Zed/PaymentGui/PaymentGuiDependencyProvider.php
<?php
namespace Pyz\Zed\PaymentGui;
use Spryker\Zed\Kernel\Communication\Form\FormTypeInterface;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\PaymentGui\PaymentGuiDependencyProvider as SprykerPaymentGuiDependencyProvider;
use Spryker\Zed\Store\Communication\Plugin\Form\StoreRelationToggleFormTypePlugin;
class PaymentGuiDependencyProvider extends SprykerPaymentGuiDependencyProvider
{
/**
* @return \Spryker\Zed\Kernel\Communication\Form\FormTypeInterface
*/
protected function getStoreRelationFormTypePlugin(): FormTypeInterface
{
return new StoreRelationToggleFormTypePlugin();
}
}
- You can see the list of payment methods in the **Back Office > Administration > Payment Management > Payment Methods** section.
- You can see information about the payment method in the **Back Office > Administration > Payment Management > Payment Methods > View** section.
- You can edit the payment method in the **Back Office > Administration > Payment Management > Payment Methods > Edit** section.
5) Additional cleanups:
The SalesPaymentMethodTypeInstallerPlugin
plugin was removed, please use the PaymentDataImport module
instead.
The PaymentConfig::getSalesPaymentMethodTypes()
config method was removed, please use the PaymentDataImport
module instead.
Thank you!
For submitting the form