mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
add reset button
This commit is contained in:
parent
cbca7491f5
commit
3b35d6a0ee
6 changed files with 71 additions and 19 deletions
|
@ -73,10 +73,11 @@ return [
|
|||
if ($state->currentState() === State::STATE_START) {
|
||||
return new StartSettings();
|
||||
}
|
||||
$environment = $container->get('onboarding.environment');
|
||||
if ($state->currentState() === State::STATE_PROGRESSIVE) {
|
||||
return new ProgressiveSettings();
|
||||
return new ProgressiveSettings($environment);
|
||||
}
|
||||
return new FullyOnboardedSettings();
|
||||
return new FullyOnboardedSettings($environment);
|
||||
},
|
||||
'wcgateway.order-processor' => static function (ContainerInterface $container): OrderProcessor {
|
||||
|
||||
|
|
|
@ -159,4 +159,23 @@ class WcGateway extends WcGatewayBase
|
|||
ob_end_clean();
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function generate_ppcp_info_html($type, $data) : string
|
||||
{
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<?php echo wp_kses_post( $data['title'] ); ?>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<?php echo wp_kses_post( $data['text'] ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
use Inpsyde\PayPalCommerce\Onboarding\Environment;
|
||||
|
||||
class FullyOnboardedSettings extends StartSettings implements SettingsFields
|
||||
{
|
||||
|
||||
use SettingsTrait;
|
||||
public function __construct(Environment $environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return array_merge(
|
||||
|
@ -23,7 +32,7 @@ class FullyOnboardedSettings extends StartSettings implements SettingsFields
|
|||
private function gateway(): array
|
||||
{
|
||||
return array_merge(
|
||||
parent::fields(),
|
||||
$this->defaultFields(),
|
||||
[
|
||||
'intent' => [
|
||||
'title' => __('Intent', 'woocommerce-paypal-gateway'),
|
||||
|
|
|
@ -4,23 +4,33 @@ declare(strict_types=1);
|
|||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
class ProgressiveSettings extends StartSettings implements SettingsFields
|
||||
use Inpsyde\PayPalCommerce\Onboarding\Environment;
|
||||
|
||||
class ProgressiveSettings implements SettingsFields
|
||||
{
|
||||
|
||||
use SettingsTrait;
|
||||
|
||||
public function __construct(Environment $environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return array_merge(
|
||||
$fields = array_merge(
|
||||
[
|
||||
'onboarding' => [
|
||||
'type' => 'ppcp_onboarding',
|
||||
],
|
||||
],
|
||||
parent::fields(),
|
||||
$this->defaultFields(),
|
||||
[
|
||||
'reset' => [
|
||||
'type' => 'ppcp_reset',
|
||||
],
|
||||
]
|
||||
);
|
||||
return $fields;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,23 @@ declare(strict_types=1);
|
|||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
use Inpsyde\PayPalCommerce\Onboarding\Environment;
|
||||
|
||||
trait SettingsTrait
|
||||
{
|
||||
/**
|
||||
* @var Environment
|
||||
*/
|
||||
private $environment;
|
||||
|
||||
private function defaultFields(): array
|
||||
{
|
||||
$isSandbox = ($this->environment) ? $this->environment->currentEnvironmentIs(Environment::SANDBOX) : false;
|
||||
$sandbox = [
|
||||
'type' => 'ppcp_info',
|
||||
'title' => __('Sandbox'),
|
||||
'text' => ($isSandbox) ? __('You are currently in the sandbox mode. Click Reset if you want to change your mode.', 'woocommerce-paypal-commerce-gateway') : __('You are in production mode. Click Reset if you want to change your mode.', 'woocommerce-paypal-commerce-gateway'),
|
||||
];
|
||||
return [
|
||||
'enabled' => [
|
||||
'title' => __('Enable/Disable', 'woocommerce-paypal-gateway'),
|
||||
|
@ -45,15 +57,17 @@ trait SettingsTrait
|
|||
'type' => 'title',
|
||||
'description' => '',
|
||||
],
|
||||
'sandbox_on' => [
|
||||
'title' => __('Enable Sandbox', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __(
|
||||
'For testing your integration, you can enable the sandbox.',
|
||||
'merchant_email' => [
|
||||
'title' => __('PayPal Email', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'email',
|
||||
'description' => __(
|
||||
'Please enter the email address with which you want to receive payments.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'default' => 'yes',
|
||||
'default' => '',
|
||||
'desc_tip' => true,
|
||||
],
|
||||
'sandbox_on' => $sandbox,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,15 +13,14 @@ class StartSettings implements SettingsFields
|
|||
return array_merge(
|
||||
$this->defaultFields(),
|
||||
[
|
||||
'merchant_email' => [
|
||||
'title' => __('PayPal Email', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'email',
|
||||
'description' => __(
|
||||
'Please enter the email address with which you want to receive payments.',
|
||||
'sandbox_on' => [
|
||||
'title' => __('Enable Sandbox', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __(
|
||||
'For testing your integration, you can enable the sandbox.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'default' => '',
|
||||
'desc_tip' => true,
|
||||
'default' => 'no',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue