downgrade plugin to php 7.0

This commit is contained in:
David Remer 2020-09-11 13:38:02 +03:00
parent 5e011b4f95
commit c5899d915c
61 changed files with 419 additions and 368 deletions

View file

@ -19,11 +19,11 @@ use Psr\Log\LoggerInterface;
return array(
'api.merchant_email' => static function ( ContainerInterface $container ): string {
'api.merchant_email' => static function ( $container ): string {
$settings = $container->get( 'wcgateway.settings' );
return $settings->has( 'merchant_email' ) ? (string) $settings->get( 'merchant_email' ) : '';
},
'api.merchant_id' => static function ( ContainerInterface $container ): string {
'api.merchant_id' => static function ( $container ): string {
$settings = $container->get( 'wcgateway.settings' );
return $settings->has( 'merchant_id' ) ? (string) $settings->get( 'merchant_id' ) : '';
},
@ -31,20 +31,20 @@ return array(
// @ToDo: Replace with the real merchant id of platform
return 'KQ8FCM66JFGDL';
},
'api.key' => static function ( ContainerInterface $container ): string {
'api.key' => static function ( $container ): string {
$settings = $container->get( 'wcgateway.settings' );
$key = $settings->has( 'client_id' ) ? (string) $settings->get( 'client_id' ) : '';
return $key;
},
'api.secret' => static function ( ContainerInterface $container ): string {
'api.secret' => static function ( $container ): string {
$settings = $container->get( 'wcgateway.settings' );
return $settings->has( 'client_secret' ) ? (string) $settings->get( 'client_secret' ) : '';
},
'api.prefix' => static function ( ContainerInterface $container ): string {
'api.prefix' => static function ( $container ): string {
$settings = $container->get( 'wcgateway.settings' );
return $settings->has( 'prefix' ) ? (string) $settings->get( 'prefix' ) : 'WC-';
},
'api.endpoint.order' => static function ( ContainerInterface $container ): OrderEndpoint {
'api.endpoint.order' => static function ( $container ): OrderEndpoint {
$order_factory = $container->get( 'api.factory.order' );
$patch_collection_factory = $container->get( 'api.factory.patch-collection-factory' );
$logger = $container->get( 'woocommerce.logger.woocommerce' );
@ -77,7 +77,7 @@ return array(
$bn_code
);
},
'woocommerce.logger.woocommerce' => function ( ContainerInterface $container ): LoggerInterface {
'woocommerce.logger.woocommerce' => function ( $container ): LoggerInterface {
$settings = $container->get( 'wcgateway.settings' );
if ( ! function_exists( 'wc_get_logger' ) || ! $settings->has( 'logging_enabled' ) || ! $settings->get( 'logging_enabled' ) ) {
return new NullLogger();

View file

@ -11,6 +11,7 @@ namespace Inpsyde\PayPalCommerce\WcGateway;
use Dhii\Data\Container\ContainerInterface;
use Inpsyde\PayPalCommerce\ApiClient\Entity\ApplicationContext;
use Inpsyde\PayPalCommerce\ApiClient\Helper\Cache;
use Inpsyde\PayPalCommerce\Onboarding\State;
use Inpsyde\PayPalCommerce\WcGateway\Admin\OrderTablePaymentStatusColumn;
use Inpsyde\PayPalCommerce\WcGateway\Admin\PaymentStatusOrderDetail;
@ -30,7 +31,7 @@ use Inpsyde\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
use WpOop\TransientCache\CachePoolFactory;
return array(
'wcgateway.paypal-gateway' => static function ( ContainerInterface $container ): PayPalGateway {
'wcgateway.paypal-gateway' => static function ( $container ): PayPalGateway {
$order_processor = $container->get( 'wcgateway.order-processor' );
$settings_renderer = $container->get( 'wcgateway.settings.render' );
$authorized_payments = $container->get( 'wcgateway.processor.authorized-payments' );
@ -47,7 +48,7 @@ return array(
$session_handler
);
},
'wcgateway.credit-card-gateway' => static function ( ContainerInterface $container ): CreditCardGateway {
'wcgateway.credit-card-gateway' => static function ( $container ): CreditCardGateway {
$order_processor = $container->get( 'wcgateway.order-processor' );
$settings_renderer = $container->get( 'wcgateway.settings.render' );
$authorized_payments = $container->get( 'wcgateway.processor.authorized-payments' );
@ -65,27 +66,27 @@ return array(
$session_handler
);
},
'wcgateway.disabler' => static function ( ContainerInterface $container ): DisableGateways {
'wcgateway.disabler' => static function ( $container ): DisableGateways {
$session_handler = $container->get( 'session.handler' );
$settings = $container->get( 'wcgateway.settings' );
return new DisableGateways( $session_handler, $settings );
},
'wcgateway.settings' => static function ( ContainerInterface $container ): Settings {
'wcgateway.settings' => static function ( $container ): Settings {
return new Settings();
},
'wcgateway.notice.connect' => static function ( ContainerInterface $container ): ConnectAdminNotice {
'wcgateway.notice.connect' => static function ( $container ): ConnectAdminNotice {
$state = $container->get( 'onboarding.state' );
$settings = $container->get( 'wcgateway.settings' );
return new ConnectAdminNotice( $state, $settings );
},
'wcgateway.notice.authorize-order-action' =>
static function ( ContainerInterface $container ): AuthorizeOrderActionNotice {
static function ( $container ): AuthorizeOrderActionNotice {
return new AuthorizeOrderActionNotice();
},
'wcgateway.settings.sections-renderer' => static function ( ContainerInterface $container ): SectionsRenderer {
'wcgateway.settings.sections-renderer' => static function ( $container ): SectionsRenderer {
return new SectionsRenderer();
},
'wcgateway.settings.render' => static function ( ContainerInterface $container ): SettingsRenderer {
'wcgateway.settings.render' => static function ( $container ): SettingsRenderer {
$settings = $container->get( 'wcgateway.settings' );
$state = $container->get( 'onboarding.state' );
$fields = $container->get( 'wcgateway.settings.fields' );
@ -99,18 +100,15 @@ return array(
$messages_apply
);
},
'wcgateway.settings.listener' => static function ( ContainerInterface $container ): SettingsListener {
'wcgateway.settings.listener' => static function ( $container ): SettingsListener {
$settings = $container->get( 'wcgateway.settings' );
$fields = $container->get( 'wcgateway.settings.fields' );
$webhook_registrar = $container->get( 'webhook.registrar' );
$state = $container->get( 'onboarding.state' );
global $wpdb;
$cache_pool_factory = new CachePoolFactory( $wpdb );
$pool = $cache_pool_factory->createCachePool( 'ppcp-token' );
return new SettingsListener( $settings, $fields, $webhook_registrar, $pool, $state );
$cache = new Cache('ppcp-token');
return new SettingsListener( $settings, $fields, $webhook_registrar, $cache, $state );
},
'wcgateway.order-processor' => static function ( ContainerInterface $container ): OrderProcessor {
'wcgateway.order-processor' => static function ( $container ): OrderProcessor {
$session_handler = $container->get( 'session.handler' );
$cart_repository = $container->get( 'api.repository.cart' );
@ -131,20 +129,20 @@ return array(
$settings
);
},
'wcgateway.processor.authorized-payments' => static function ( ContainerInterface $container ): AuthorizedPaymentsProcessor {
'wcgateway.processor.authorized-payments' => static function ( $container ): AuthorizedPaymentsProcessor {
$order_endpoint = $container->get( 'api.endpoint.order' );
$payments_endpoint = $container->get( 'api.endpoint.payments' );
return new AuthorizedPaymentsProcessor( $order_endpoint, $payments_endpoint );
},
'wcgateway.admin.order-payment-status' => static function ( ContainerInterface $container ): PaymentStatusOrderDetail {
'wcgateway.admin.order-payment-status' => static function ( $container ): PaymentStatusOrderDetail {
return new PaymentStatusOrderDetail();
},
'wcgateway.admin.orders-payment-status-column' => static function ( ContainerInterface $container ): OrderTablePaymentStatusColumn {
'wcgateway.admin.orders-payment-status-column' => static function ( $container ): OrderTablePaymentStatusColumn {
$settings = $container->get( 'wcgateway.settings' );
return new OrderTablePaymentStatusColumn( $settings );
},
'wcgateway.settings.fields' => static function ( ContainerInterface $container ): array {
'wcgateway.settings.fields' => static function ( $container ): array {
$settings = $container->get( 'wcgateway.settings' );
$sandbox_text = $settings->has( 'sandbox_on' ) && $settings->get( 'sandbox_on' ) ?
// translators: %1$s and %2$s are button tags.
@ -1589,19 +1587,19 @@ return array(
return $fields;
},
'wcgateway.checkout.address-preset' => static function( ContainerInterface $container ): CheckoutPayPalAddressPreset {
'wcgateway.checkout.address-preset' => static function( $container ): CheckoutPayPalAddressPreset {
return new CheckoutPayPalAddressPreset(
$container->get( 'session.handler' )
);
},
'wcgateway.url' => static function ( ContainerInterface $container ): string {
'wcgateway.url' => static function ( $container ): string {
return plugins_url(
'/modules/ppcp-wc-gateway/',
dirname( __FILE__, 3 ) . '/woocommerce-paypal-commerce-gateway.php'
);
},
'wcgateway.endpoint.return-url' => static function ( ContainerInterface $container ) : ReturnUrlEndpoint {
'wcgateway.endpoint.return-url' => static function ( $container ) : ReturnUrlEndpoint {
$gateway = $container->get( 'wcgateway.paypal-gateway' );
$endpoint = $container->get( 'api.endpoint.order' );
$prefix = $container->get( 'api.prefix' );

View file

@ -18,9 +18,9 @@ use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings;
*/
class OrderTablePaymentStatusColumn {
private const COLUMN_KEY = 'ppcp_payment_status';
private const INTENT = 'authorize';
private const AFTER_COLUMN_KEY = 'order_status';
const COLUMN_KEY = 'ppcp_payment_status';
const INTENT = 'authorize';
const AFTER_COLUMN_KEY = 'order_status';
/**
* The settings.

View file

@ -51,7 +51,7 @@ class CheckoutPayPalAddressPreset {
*
* @return string|null
*/
public function filter_checkout_field( $default_value, $field_id ): ?string {
public function filter_checkout_field( $default_value, $field_id ) {
if ( ! is_string( $default_value ) ) {
$default_value = null;
}
@ -70,7 +70,7 @@ class CheckoutPayPalAddressPreset {
*
* @return string|null
*/
private function read_preset_for_field( string $field_id ): ?string {
private function read_preset_for_field( string $field_id ) {
$order = $this->session_handler->order();
if ( ! $order ) {
return null;
@ -127,7 +127,7 @@ class CheckoutPayPalAddressPreset {
*
* @return Shipping|null
*/
private function read_shipping_from_order(): ?Shipping {
private function read_shipping_from_order() {
$order = $this->session_handler->order();
if ( ! $order ) {
return null;

View file

@ -19,7 +19,7 @@ use Inpsyde\PayPalCommerce\Webhooks\Handler\PrefixTrait;
class ReturnUrlEndpoint {
use PrefixTrait;
public const ENDPOINT = 'ppc-return-url';
const ENDPOINT = 'ppc-return-url';
/**
* The PayPal Gateway.

View file

@ -21,7 +21,7 @@ use Psr\Container\ContainerInterface;
*/
class CreditCardGateway extends PayPalGateway {
public const ID = 'ppcp-credit-card-gateway';
const ID = 'ppcp-credit-card-gateway';
/**
* The URL to the module.

View file

@ -23,10 +23,10 @@ use Psr\Container\ContainerInterface;
*/
class PayPalGateway extends \WC_Payment_Gateway {
public const ID = 'ppcp-gateway';
public const CAPTURED_META_KEY = '_ppcp_paypal_captured';
public const INTENT_META_KEY = '_ppcp_paypal_intent';
public const ORDER_ID_META_KEY = '_ppcp_paypal_order_id';
const ID = 'ppcp-gateway';
const CAPTURED_META_KEY = '_ppcp_paypal_captured';
const INTENT_META_KEY = '_ppcp_paypal_intent';
const ORDER_ID_META_KEY = '_ppcp_paypal_order_id';
/**
* The Settings Renderer.
@ -175,7 +175,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
*
* @return array|null
*/
public function process_payment( $order_id ): ?array {
public function process_payment( $order_id ) {
global $woocommerce;
$wc_order = wc_get_order( $order_id );
if ( ! is_a( $wc_order, \WC_Order::class ) ) {

View file

@ -16,20 +16,20 @@ use Inpsyde\PayPalCommerce\AdminNotices\Entity\Message;
*/
class AuthorizeOrderActionNotice {
public const QUERY_PARAM = 'ppcp-authorized-message';
const QUERY_PARAM = 'ppcp-authorized-message';
public const NO_INFO = 81;
public const ALREADY_CAPTURED = 82;
public const FAILED = 83;
public const SUCCESS = 84;
public const NOT_FOUND = 85;
const NO_INFO = 81;
const ALREADY_CAPTURED = 82;
const FAILED = 83;
const SUCCESS = 84;
const NOT_FOUND = 85;
/**
* Returns the current message if there is one.
*
* @return Message|null
*/
public function message(): ?Message {
public function message() {
$message = $this->current_message();
if ( ! $message ) {
@ -95,7 +95,7 @@ class AuthorizeOrderActionNotice {
*
* @param int $message_code The message code.
*/
public function display_message( int $message_code ): void {
public function display_message( int $message_code ) {
add_filter(
'redirect_post_location',
static function ( $location ) use ( $message_code ) {

View file

@ -49,7 +49,7 @@ class ConnectAdminNotice {
*
* @return Message|null
*/
public function connect_message(): ?Message {
public function connect_message() {
if ( ! $this->should_display() ) {
return null;
}

View file

@ -22,11 +22,11 @@ use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
*/
class AuthorizedPaymentsProcessor {
public const SUCCESSFUL = 'SUCCESSFUL';
public const ALREADY_CAPTURED = 'ALREADY_CAPTURED';
public const FAILED = 'FAILED';
public const INACCESSIBLE = 'INACCESSIBLE';
public const NOT_FOUND = 'NOT_FOUND';
const SUCCESSFUL = 'SUCCESSFUL';
const ALREADY_CAPTURED = 'ALREADY_CAPTURED';
const FAILED = 'FAILED';
const INACCESSIBLE = 'INACCESSIBLE';
const NOT_FOUND = 'NOT_FOUND';
/**
* The Order endpoint.

View file

@ -17,7 +17,7 @@ use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
*/
class SectionsRenderer {
public const KEY = 'ppcp-tab';
const KEY = 'ppcp-tab';
/**
* Whether the sections tab should be rendered.

View file

@ -17,7 +17,7 @@ use Psr\Container\ContainerInterface;
*/
class Settings implements ContainerInterface {
public const KEY = 'woocommerce-ppcp-settings';
const KEY = 'woocommerce-ppcp-settings';
/**
* The settings.

View file

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
use Inpsyde\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
use Inpsyde\PayPalCommerce\ApiClient\Helper\Cache;
use Inpsyde\PayPalCommerce\Onboarding\State;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
@ -22,7 +23,7 @@ use Psr\SimpleCache\CacheInterface;
class SettingsListener {
public const NONCE = 'ppcp-settings';
const NONCE = 'ppcp-settings';
/**
* The Settings.
@ -48,7 +49,7 @@ class SettingsListener {
/**
* The Cache.
*
* @var CacheInterface
* @var Cache
*/
private $cache;
@ -65,14 +66,14 @@ class SettingsListener {
* @param Settings $settings The settings.
* @param array $setting_fields The setting fields.
* @param WebhookRegistrar $webhook_registrar The Webhook Registrar.
* @param CacheInterface $cache The Cache.
* @param Cache $cache The Cache.
* @param State $state The state.
*/
public function __construct(
Settings $settings,
array $setting_fields,
WebhookRegistrar $webhook_registrar,
CacheInterface $cache,
Cache $cache,
State $state
) {

View file

@ -314,7 +314,7 @@ class WcGatewayModule implements ModuleInterface {
*
* @param ContainerInterface $container The container.
*/
private function register_checkout_paypal_address_preset( ContainerInterface $container ): void {
private function register_checkout_paypal_address_preset( ContainerInterface $container ) {
add_filter(
'woocommerce_checkout_get_value',
static function ( ...$args ) use ( $container ) {