Add paylater-configurator module

This commit is contained in:
Alex P 2023-12-21 09:55:57 +02:00
parent fc1b5e9a1e
commit ace58578a0
No known key found for this signature in database
GPG key ID: 54487A734A204D71
12 changed files with 2427 additions and 0 deletions

View file

@ -6,6 +6,7 @@
*/ */
use WooCommerce\PayPalCommerce\PayLaterBlock\PayLaterBlockModule; use WooCommerce\PayPalCommerce\PayLaterBlock\PayLaterBlockModule;
use WooCommerce\PayPalCommerce\PayLaterConfigurator\PayLaterConfiguratorModule;
use WooCommerce\PayPalCommerce\PluginModule; use WooCommerce\PayPalCommerce\PluginModule;
return function ( string $root_dir ): iterable { return function ( string $root_dir ): iterable {
@ -71,5 +72,9 @@ return function ( string $root_dir ): iterable {
$modules[] = ( require "$modules_dir/ppcp-paylater-block/module.php" )(); $modules[] = ( require "$modules_dir/ppcp-paylater-block/module.php" )();
} }
if ( PayLaterConfiguratorModule::is_enabled() ) {
$modules[] = ( require "$modules_dir/ppcp-paylater-configurator/module.php" )();
}
return $modules; return $modules;
}; };

View file

@ -0,0 +1,14 @@
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": "3.25.0"
}
],
[
"@babel/preset-react"
]
]
}

View file

@ -0,0 +1,3 @@
node_modules
assets/js
assets/css

View file

@ -0,0 +1,17 @@
{
"name": "woocommerce/ppcp-paylater-configurator",
"type": "dhii-mod",
"description": "Pay Later Messaging configurator module for PPCP",
"license": "GPL-2.0",
"require": {
"php": "^7.2 | ^8.0",
"dhii/module-interface": "^0.3.0-alpha1"
},
"autoload": {
"psr-4": {
"WooCommerce\\PayPalCommerce\\PayLaterConfigurator\\": "src"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}

View file

@ -0,0 +1,12 @@
<?php
/**
* The Pay Later configurator module extensions.
*
* @package WooCommerce\PayPalCommerce\PayLaterConfigurator
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\PayLaterConfigurator;
return array();

View file

@ -0,0 +1,16 @@
<?php
/**
* The Pay Later configurator module.
*
* @package WooCommerce\PayPalCommerce\PayLaterConfigurator
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\PayLaterConfigurator;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
return static function (): ModuleInterface {
return new PayLaterConfiguratorModule();
};

View file

@ -0,0 +1,33 @@
{
"name": "ppcp-paylater-configurator",
"version": "1.0.0",
"license": "GPL-3.0-or-later",
"browserslist": [
"> 0.5%",
"Safari >= 8",
"Chrome >= 41",
"Firefox >= 43",
"Edge >= 14"
],
"dependencies": {
"core-js": "^3.25.0"
},
"devDependencies": {
"@babel/core": "^7.19",
"@babel/preset-env": "^7.19",
"@babel/preset-react": "^7.18.6",
"@woocommerce/dependency-extraction-webpack-plugin": "^2.2.0",
"babel-loader": "^8.2",
"cross-env": "^7.0.3",
"file-loader": "^6.2.0",
"sass": "^1.42.1",
"sass-loader": "^12.1.0",
"webpack": "^5.76",
"webpack-cli": "^4.10"
},
"scripts": {
"build": "cross-env BABEL_ENV=default NODE_ENV=production webpack",
"watch": "cross-env BABEL_ENV=default NODE_ENV=production webpack --watch",
"dev": "cross-env BABEL_ENV=default webpack --watch"
}
}

View file

@ -0,0 +1,26 @@
<?php
/**
* The Pay Later configurator module services.
*
* @package WooCommerce\PayPalCommerce\PayLaterConfigurator
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\PayLaterConfigurator;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
return array(
'paylater-configurator.url' => static function ( ContainerInterface $container ): string {
/**
* Cannot return false for this path.
*
* @psalm-suppress PossiblyFalseArgument
*/
return plugins_url(
'/modules/ppcp-paylater-configurator/',
dirname( realpath( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php'
);
},
);

View file

@ -0,0 +1,58 @@
<?php
/**
* The Pay Later configurator module.
*
* @package WooCommerce\PayPalCommerce\PayLaterConfigurator
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\PayLaterConfigurator;
use WooCommerce\PayPalCommerce\Button\Endpoint\CartScriptParamsEndpoint;
use WooCommerce\PayPalCommerce\Button\Helper\MessagesApply;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
/**
* Class PayLaterConfiguratorModule
*/
class PayLaterConfiguratorModule implements ModuleInterface {
/**
* Returns whether the module should be loaded.
*/
public static function is_enabled(): bool {
return apply_filters(
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
'woocommerce.feature-flags.woocommerce_paypal_payments.paylater_configurator_enabled',
getenv( 'PCP_PAYLATER_CONFIGURATOR' ) !== '0'
);
}
/**
* {@inheritDoc}
*/
public function setup(): ServiceProviderInterface {
return new ServiceProvider(
require __DIR__ . '/../services.php',
require __DIR__ . '/../extensions.php'
);
}
/**
* {@inheritDoc}
*/
public function run( ContainerInterface $c ): void {
}
/**
* Returns the key for the module.
*
* @return string|void
*/
public function getKey() {
}
}

View file

@ -0,0 +1,39 @@
const path = require('path');
const isProduction = process.env.NODE_ENV === 'production';
const DependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' );
module.exports = {
devtool: isProduction ? 'source-map' : 'eval-source-map',
mode: isProduction ? 'production' : 'development',
target: 'web',
plugins: [ new DependencyExtractionWebpackPlugin() ],
entry: {
'paylater-configurator': path.resolve('./resources/js/paylater-configurator.js'),
'paylater-configurator-style': path.resolve('./resources/css/paylater-configurator.scss'),
},
output: {
path: path.resolve(__dirname, 'assets/'),
filename: 'js/[name].js',
},
module: {
rules: [{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
{
loader: 'file-loader',
options: {
name: 'css/[name].css',
}
},
{loader:'sass-loader'}
]
}]
}
};

File diff suppressed because it is too large Load diff

View file

@ -10,6 +10,7 @@
"install:modules:ppcp-applepay": "cd modules/ppcp-applepay && yarn install", "install:modules:ppcp-applepay": "cd modules/ppcp-applepay && yarn install",
"install:modules:ppcp-blocks": "cd modules/ppcp-blocks && yarn install", "install:modules:ppcp-blocks": "cd modules/ppcp-blocks && yarn install",
"install:modules:ppcp-paylater-block": "cd modules/ppcp-paylater-block && yarn install", "install:modules:ppcp-paylater-block": "cd modules/ppcp-paylater-block && yarn install",
"install:modules:ppcp-paylater-configurator": "cd modules/ppcp-paylater-configurator && yarn install",
"install:modules:ppcp-button": "cd modules/ppcp-button && yarn install", "install:modules:ppcp-button": "cd modules/ppcp-button && yarn install",
"install:modules:ppcp-googlepay": "cd modules/ppcp-googlepay && yarn install", "install:modules:ppcp-googlepay": "cd modules/ppcp-googlepay && yarn install",
"install:modules:ppcp-wc-gateway": "cd modules/ppcp-wc-gateway && yarn install", "install:modules:ppcp-wc-gateway": "cd modules/ppcp-wc-gateway && yarn install",
@ -23,6 +24,7 @@
"build:modules:ppcp-applepay": "cd modules/ppcp-applepay && yarn run build", "build:modules:ppcp-applepay": "cd modules/ppcp-applepay && yarn run build",
"build:modules:ppcp-blocks": "cd modules/ppcp-blocks && yarn run build", "build:modules:ppcp-blocks": "cd modules/ppcp-blocks && yarn run build",
"build:modules:ppcp-paylater-block": "cd modules/ppcp-paylater-block && yarn run build", "build:modules:ppcp-paylater-block": "cd modules/ppcp-paylater-block && yarn run build",
"build:modules:ppcp-paylater-configurator": "cd modules/ppcp-paylater-configurator && yarn run build",
"build:modules:ppcp-button": "cd modules/ppcp-button && yarn run build", "build:modules:ppcp-button": "cd modules/ppcp-button && yarn run build",
"build:modules:ppcp-googlepay": "cd modules/ppcp-googlepay && yarn run build", "build:modules:ppcp-googlepay": "cd modules/ppcp-googlepay && yarn run build",
"build:modules:ppcp-wc-gateway": "cd modules/ppcp-wc-gateway && yarn run build", "build:modules:ppcp-wc-gateway": "cd modules/ppcp-wc-gateway && yarn run build",
@ -37,6 +39,7 @@
"watch:modules:ppcp-applepay": "cd modules/ppcp-applepay && yarn run watch", "watch:modules:ppcp-applepay": "cd modules/ppcp-applepay && yarn run watch",
"watch:modules:ppcp-blocks": "cd modules/ppcp-blocks && yarn run watch", "watch:modules:ppcp-blocks": "cd modules/ppcp-blocks && yarn run watch",
"watch:modules:ppcp-paylater-block": "cd modules/ppcp-paylater-block && yarn run watch", "watch:modules:ppcp-paylater-block": "cd modules/ppcp-paylater-block && yarn run watch",
"watch:modules:ppcp-paylater-configurator": "cd modules/ppcp-paylater-configurator && yarn run watch",
"watch:modules:ppcp-button": "cd modules/ppcp-button && yarn run watch", "watch:modules:ppcp-button": "cd modules/ppcp-button && yarn run watch",
"watch:modules:ppcp-googlepay": "cd modules/ppcp-googlepay && yarn run watch", "watch:modules:ppcp-googlepay": "cd modules/ppcp-googlepay && yarn run watch",
"watch:modules:ppcp-wc-gateway": "cd modules/ppcp-wc-gateway && yarn run watch", "watch:modules:ppcp-wc-gateway": "cd modules/ppcp-wc-gateway && yarn run watch",