Plugin Directory

Changeset 2921678


Ignore:
Timestamp:
06/05/2023 01:25:15 PM (3 years ago)
Author:
Biont
Message:

update develop brach with Version 1.4.0

Location:
payoneer-checkout/trunk
Files:
8 added
25 edited

Legend:

Unmodified
Added
Removed
  • payoneer-checkout/trunk/inc/services.php

    r2915933 r2921678  
    514514            new Alias('inpsyde_payment_gateway.settings_option_key'),
    515515
     516        'core.misconfiguration_detector' =>
     517            new Alias('checkout.misconfiguration_detector'),
     518
    516519        # Essential factories
    517520        # =================================================================
     
    15341537            new Alias('core.wc.countries'),
    15351538
     1539        'checkout.is_frontend_request' =>
     1540            new Alias('wp.is_frontend_request'),
     1541
    15361542        ## webhooks
    15371543        # --------------------------
     
    16981704            new Alias('core.wc_ajax_url'),
    16991705
     1706        'embedded_payment.misconfiguration_detector' =>
     1707            new Alias('core.misconfiguration_detector'),
     1708
    17001709        ## websdk
    17011710        # --------------------------
     
    17291738
    17301739        'admin_banner.configure_url' => new Alias('core.http.settings_url'),
     1740
     1741        ## hosted_payment
     1742        # --------------------------
     1743
     1744        'hosted_payment.misconfiguration_detector' =>
     1745            new Alias('core.misconfiguration_detector'),
    17311746    ];
    17321747};
  • payoneer-checkout/trunk/languages/en_GB.pot

    r2915933 r2921678  
    4343msgstr ""
    4444
    45 #: ../inc/services.php:835
     45#: ../inc/services.php:838
    4646msgid "live"
    4747msgstr ""
    4848
    49 #: ../inc/services.php:838
     49#: ../inc/services.php:841
    5050msgid "sandbox"
    5151msgstr ""
     
    7171msgstr ""
    7272
     73#: ../modules.local/checkout/inc/amex_icon_setting_field.php:10
     74msgid "American Express logo"
     75msgstr ""
     76
     77#: ../modules.local/checkout/inc/amex_icon_setting_field.php:12
     78msgid "Display American Express logo next to the payment method title on the checkout page. Merchants of Record shall not display the logo."
     79msgstr ""
     80
     81#: ../modules.local/checkout/inc/appearance_settings_fields.php:11
     82msgid "Payment widget appearance"
     83msgstr ""
     84
    7385#: ../modules.local/checkout/inc/general_settings_fields.php:16
    7486msgid "Select payment flow"
    7587msgstr ""
    7688
    77 #: ../modules.local/checkout/inc/services.php:560
     89#: ../modules.local/checkout/inc/services.php:585
    7890msgid "Select the payment flow for every transaction."
    7991msgstr ""
    8092
    81 #: ../modules.local/checkout/src/CheckoutModule.php:256
     93#: ../modules.local/checkout/src/CheckoutModule.php:260
    8294msgid "Payment failed. Please try again"
    8395msgstr ""
    8496
    85 #: ../modules.local/checkout/src/CheckoutModule.php:258
     97#: ../modules.local/checkout/src/CheckoutModule.php:262
    8698msgid "Payment canceled. Please try again or choose another payment method."
    8799msgstr ""
    88100
    89 #: ../modules.local/checkout/src/CheckoutModule.php:279
     101#: ../modules.local/checkout/src/CheckoutModule.php:283
    90102msgid "Payment has been aborted"
    91103msgstr ""
    92104
    93105#. translators: %1$s, %2$s and %3$s are replaced with the opening and closing 'a' tags
    94 #: ../modules.local/checkout/src/CheckoutModule.php:424
     106#: ../modules.local/checkout/src/CheckoutModule.php:428
    95107msgid "Enter correct test credentials and save settings to get status notification and unblock live mode. You can %1$srefresh%2$s the page to check if status notification is already received."
    96108msgstr ""
    97109
    98 #: ../modules.local/checkout/src/CheckoutModule.php:469
     110#: ../modules.local/checkout/src/CheckoutModule.php:473
    99111msgid "Payment was aborted by Payoneer Checkout. Please try again."
    100112msgstr ""
    101113
    102 #: ../modules.local/checkout/src/CheckoutModule.php:474
     114#: ../modules.local/checkout/src/CheckoutModule.php:478
    103115msgid "An unknown error occurred when initiating payment through Payoneer Checkout. Please try again."
     116msgstr ""
     117
     118#: ../modules.local/embedded-payment/inc/custom_css_fields.php:16
     119msgid "Custom CSS"
     120msgstr ""
     121
     122#: ../modules.local/embedded-payment/inc/custom_css_fields.php:18
     123msgid "Customize the look and feel of the payment widget in embedded payment flow"
    104124msgstr ""
    105125
     
    112132msgstr ""
    113133
    114 #: ../modules.local/embedded-payment/inc/fields.php:16
    115 msgid "Payment widget appearance"
    116 msgstr ""
    117 
    118 #: ../modules.local/embedded-payment/inc/fields.php:20
    119 msgid "Custom CSS"
    120 msgstr ""
    121 
    122 #: ../modules.local/embedded-payment/inc/fields.php:22
    123 msgid "Customize the look and feel of the payment widget in embedded payment flow"
    124 msgstr ""
    125 
    126134#: ../modules.local/embedded-payment/src/EmbeddedPaymentModule.php:214
    127135msgid "Pay for order"
     
    132140msgstr ""
    133141
    134 #: ../modules.local/embedded-payment/src/EmbeddedPaymentModule.php:359
    135 msgid "Failed to initialize Payoneer session based on current checkout data. Possible reasons include incomplete billing data or an invalid order total"
     142#: ../modules.local/embedded-payment/src/EmbeddedPaymentModule.php:362
     143msgid "The selected payment method for your order is not available at the moment. Please select another payment method."
    136144msgstr ""
    137145
     
    140148msgstr ""
    141149
    142 #: ../modules.local/hosted-payment/inc/extensions.php:19
     150#: ../modules.local/hosted-payment/inc/extensions.php:20
    143151msgid "Hosted"
    144152msgstr ""
    145153
    146 #: ../modules.local/hosted-payment/inc/extensions.php:26
     154#: ../modules.local/hosted-payment/inc/extensions.php:27
    147155msgid "Hosted: customers get redirected to an external payment page."
    148156msgstr ""
     
    212220msgstr ""
    213221
    214 #: ../modules.local/payment-gateway/inc/services.php:161
     222#: ../modules.local/payment-gateway/inc/services.php:156
    215223msgid "Payoneer Checkout is the next generation of payment processing platforms."
    216224msgstr ""
    217225
    218226#. translators: %1$s, %2$s, %3$s and %4$s are replaced with opening and closing 'a' tags.
    219 #: ../modules.local/payment-gateway/inc/services.php:167
     227#: ../modules.local/payment-gateway/inc/services.php:162
    220228msgid "By using Payoneer Checkout, you agree to the %1$sTerms of Service%2$s and %3$sPrivacy policy%4$s."
    221229msgstr ""
    222230
    223231#. translators: %1$s, %2$s, %3$s, %4$s, %5$s and %6$s is replaced with the opening and closing 'a' tags.
    224 #: ../modules.local/payment-gateway/inc/services.php:191
     232#: ../modules.local/payment-gateway/inc/services.php:186
    225233msgid "Before you begin read How to %1$sConnect WooCommerce%2$s to Payoneer Checkout. Make sure you have a Payoneer Account. If you don't, see %3$sRegister for Checkout%4$s. You can get your %5$sauthentication data%6$s in the Payoneer Account."
    226234msgstr ""
    227235
    228 #: ../modules.local/payment-gateway/inc/services.php:213
     236#: ../modules.local/payment-gateway/inc/services.php:208
    229237msgid "Payoneer Checkout"
    230238msgstr ""
    231239
    232240#. translators: %1$s is replaced with the refund long ID
    233 #: ../modules.local/payment-gateway/inc/services.php:229
     241#: ../modules.local/payment-gateway/inc/services.php:224
    234242msgid " Refunded by Payoneer Checkout - long ID: %1$s"
    235243msgstr ""
    236244
    237 #: ../modules.local/payment-gateway/inc/services.php:778
     245#: ../modules.local/payment-gateway/inc/services.php:773
    238246msgid "Are you sure you want to reset this field to its default value?"
    239247msgstr ""
     
    260268msgstr ""
    261269
     270#: ../modules.local/checkout/src/PaymentProcessor/AbstractPaymentProcessor.php:40
     271msgid "Failed to initialize Payoneer session. Payoneer Checkout is not configured properly."
     272msgstr ""
     273
    262274#: ../modules.local/embedded-payment/src/AjaxOrderPay/AjaxPayAction.php:52
    263275msgid "Please read and accept the terms and conditions to proceed with your order."
     
    268280msgstr ""
    269281
    270 #: ../modules.local/embedded-payment/src/PaymentProcessor/EmbeddedPaymentProcessor.php:90
     282#: ../modules.local/embedded-payment/src/PaymentProcessor/EmbeddedPaymentProcessor.php:94
    271283msgid "API call failed. Please try again or contact the shop admin. Error details can be found in logs."
    272284msgstr ""
    273285
    274286#. translators: Transaction ID supplied by WooCommerce plugin
    275 #: ../modules.local/embedded-payment/src/PaymentProcessor/EmbeddedPaymentProcessor.php:136
     287#: ../modules.local/embedded-payment/src/PaymentProcessor/EmbeddedPaymentProcessor.php:140
    276288msgid "Initiating payment with transaction ID \"%1$s\""
    277289msgstr ""
    278290
    279 #: ../modules.local/embedded-payment/src/PaymentProcessor/EmbeddedPaymentProcessor.php:173
     291#: ../modules.local/embedded-payment/src/PaymentProcessor/EmbeddedPaymentProcessor.php:177
    280292msgid "The payment was not processed. Please try again."
    281293msgstr ""
    282294
    283 #: ../modules.local/hosted-payment/src/PaymentProcessor/HostedPaymentProcessor.php:105
     295#: ../modules.local/hosted-payment/src/PaymentProcessor/HostedPaymentProcessor.php:109
    284296msgid "The customer is being redirected to an external payment page."
    285297msgstr ""
    286298
    287 #: ../modules.local/hosted-payment/src/PaymentProcessor/HostedPaymentProcessor.php:126
     299#: ../modules.local/hosted-payment/src/PaymentProcessor/HostedPaymentProcessor.php:130
    288300msgid "An error occurred during payment processing"
    289301msgstr ""
     
    308320#. translators: Placeholder text if payment fields failed to render
    309321#: ../modules.local/payment-gateway/src/Gateway/PaymentGateway.php:396
    310 msgid "Payment widget failed to initialize due to an error"
     322msgid "Payment method not available. Please select another payment method."
    311323msgstr ""
    312324
  • payoneer-checkout/trunk/modules.local/checkout/inc/extensions.php

    r2879805 r2921678  
    6464                    )
    6565                );
    66                 /**
    67                  * The WC_Session is not always "booted", for example on order-pay
    68                  * Our assumption is that if our services depend on WC_Session,
    69                  * they depend on a *usable* WC_Session. So we initialize it transparently here
    70                  * @var WC_Session_Handler $session
    71                  */
    72                 if (! $session->has_session()) {
    73                     $session->init_session_cookie();
    74                     $session->set_customer_session_cookie(true);
    75                 }
     66
    7667                if (empty($session->get($tokenField))) {
    7768                    $tokenGenerator = $container->get('checkout.security_token_generator');
     
    8374            },
    8475
     76            'checkout.settings.appearance_settings_fields' => static function (
     77                array $fields,
     78                ContainerInterface $container
     79            ): array {
     80                /** @var array<string, array-key> $amexField */
     81                $amexField = $container->get('checkout.amex_settings_field');
     82
     83                return array_merge($fields, $amexField);
     84            },
     85
    8586            'inpsyde_payment_gateway.settings_fields' => static function (
    8687                array $previous,
    8788                ContainerInterface $container
    8889            ): array {
    89                 /** @var array $generalSettingsFields */
     90                /** @var array<string, array-key> $generalSettingsFields */
    9091                $generalSettingsFields = $container->get('checkout.settings.general_settings_fields');
     92                /** @var array<string, array-key> $appearanceSettingsFields */
     93                $appearanceSettingsFields = $container->get('checkout.settings.appearance_settings_fields');
    9194
    9295                return array_merge(
    9396                    $previous,
    94                     $generalSettingsFields
     97                    $generalSettingsFields,
     98                    $appearanceSettingsFields
    9599                );
    96100            },
     
    196200                };
    197201            },
     202            'embedded_payment.settings.fields' => static function (
     203                array $fields,
     204                ContainerInterface $container
     205            ): array {
     206                /** @psalm-var array<string, array-key> $amexField */
     207                $amexField = $container->get('checkout.amex_settings_field');
     208
     209                if (! array_key_exists('checkout_css_fieldset_title', $fields)) {
     210                    return array_merge($fields, $amexField);
     211                }
     212
     213                $combinedFields = [];
     214
     215                foreach ($fields as $fieldName => $fieldConfig) {
     216                    $combinedFields[$fieldName] = $fieldConfig;
     217
     218                    if ($fieldName === 'checkout_css_fieldset_title') {
     219                        $combinedFields = array_merge($combinedFields, $amexField);
     220                    }
     221                }
     222
     223                return $combinedFields;
     224            },
    198225        ];
    199226    };
  • payoneer-checkout/trunk/modules.local/checkout/inc/services.php

    r2915933 r2921678  
    3838use Inpsyde\PayoneerForWoocommerce\Checkout\ListSession\WcSessionListSessionManager;
    3939use Inpsyde\PayoneerForWoocommerce\Checkout\ListSession\WcTransientListSessionManager;
     40use Inpsyde\PayoneerForWoocommerce\Checkout\MisconfigurationDetector\MisconfigurationDetector;
    4041use Inpsyde\PayoneerForWoocommerce\Checkout\PaymentFieldsRenderer\CompoundPaymentFieldsRenderer;
    4142use Inpsyde\PayoneerForWoocommerce\Checkout\StateProvider\StateProvider;
     
    184185
    185186            'checkout.list_session_manager.cache_key.checkout' => new StringService(
    186                 'payoneer_list_{0}_checkout_{1}',
    187                 ['wc.session.customer_id', 'checkout.list_session_manager.cache_key.salt']
     187                'payoneer_list_checkout_{0}',
     188                ['checkout.list_session_manager.cache_key.salt']
    188189            ),
    189190            'checkout.list_session_manager.cache_key.payment' => new StringService(
    190                 'payoneer_list_{0}_pay_{1}_{2}',
    191                 [
    192                     'wc.session.customer_id',
     191                'payoneer_list_pay_{0}_{1}',
     192                [
    193193                    'wc.pay_for_order_id',
    194194                    'checkout.list_session_manager.cache_key.salt',
     
    503503                new Constructor(CheckoutHashProvider::class, ['wc']),
    504504
     505            'checkout.misconfiguration_detector' =>
     506                new Constructor(MisconfigurationDetector::class),
     507
    505508            'checkout.gateway_icon_elements_filenames' =>
    506                 new Value([
    507                     'visa.png',
    508                     'mastercard.png',
    509                 ]),
     509                new Factory(
     510                    [
     511                        'checkout.amex_icon_enabled',
     512                    ],
     513                    static function (bool $amexEnabled): array {
     514                        $icons = [
     515                            'mastercard.svg',
     516                            'visa.svg',
     517                        ];
     518
     519                        if ($amexEnabled) {
     520                            $icons = array_merge(['amex.svg'], $icons);
     521                        }
     522
     523                        return $icons;
     524                    }
     525                ),
     526
     527            'checkout.amex_settings_field' => Service::fromFile(
     528                __DIR__ . '/amex_icon_setting_field.php'
     529            ),
    510530
    511531            'checkout.gateway_icon_elements' => static function (
     
    537557                __DIR__ . "/general_settings_fields.php"
    538558            ),
     559
     560            'checkout.settings.appearance_settings_fields' => Service::fromFile(
     561                __DIR__ . "/appearance_settings_fields.php"
     562            ),
     563
    539564            'checkout.on_error_refresh_fragment_flag' => new Value('payoneer_refresh_fragment_onError'),
    540565            'checkout.is_on_error_refresh_fragment_flag' => new Factory([
     
    630655                    return $optionValue;
    631656                }),
     657            'checkout.amex_icon_enabled' =>
     658                new Factory([
     659                    'checkout.payment_gateway_options',
     660                ], static function (ContainerInterface $options): bool {
     661                    if (! $options->has('show_amex_icon')) {
     662                        return true; //Show icon by default even if options wasn't saved yet.
     663                    }
     664
     665                    $enabled = $options->get('show_amex_icon') !== 'no';
     666
     667                    return $enabled;
     668                }),
    632669        ];
    633670    };
  • payoneer-checkout/trunk/modules.local/checkout/src/CheckoutModule.php

    r2906967 r2921678  
    66
    77use Dhii\Services\Factories\FuncService;
     8use Exception;
    89use Inpsyde\Modularity\Module\ExecutableModule;
    910use Inpsyde\Modularity\Module\ExtendingModule;
     
    1112use Inpsyde\Modularity\Module\ServiceModule;
    1213use Inpsyde\PayoneerForWoocommerce\Checkout\ListSession\ListSessionRemover;
     14use Inpsyde\PayoneerForWoocommerce\Checkout\MisconfigurationDetector\MisconfigurationDetectorInterface;
    1315use Psr\Container\ContainerInterface;
    1416use RuntimeException;
     
    107109        $notificationReceivedOptionName = (string) $container->get('checkout.notification_received.option_name');
    108110        $this->addIncomingWebhookListener($notificationReceivedOptionName);
     111
     112        $this->addCreateListSessionFailedListener($container);
    109113
    110114        return true;
     
    478482        }
    479483    }
     484
     485    /**
     486     * Add listener hiding payment gateway if failed to create LIST because of authorization issue.
     487     *
     488     * @param ContainerInterface $container
     489     *
     490     * @return void
     491     */
     492    protected function addCreateListSessionFailedListener(ContainerInterface $container): void
     493    {
     494        /**
     495         * Make our payment gateway unavailable if LIST session wasn't created because of incorrect
     496         * merchant configuration.
     497         */
     498        add_action('payoneer-checkout.create_list_session_failed', static function (
     499            $arg
     500        ) use ($container): void {
     501            $isFrontendRequest = $container->get('checkout.is_frontend_request');
     502            if (! $isFrontendRequest) {
     503                return;
     504            }
     505
     506            if (! is_array($arg)) {
     507                return;
     508            }
     509
     510            $exception = $arg['exception'] ?? null;
     511
     512            if (! $exception instanceof Exception) {
     513                return;
     514            }
     515
     516            $misconfigurationDetector = $container->get('checkout.misconfiguration_detector');
     517            assert($misconfigurationDetector instanceof MisconfigurationDetectorInterface);
     518            $exceptionCausedByMisconfiguration = $misconfigurationDetector
     519                ->isCausedByMisconfiguration($exception);
     520
     521            if ($exceptionCausedByMisconfiguration) {
     522                $isHostedFlow = $container->get('checkout.selected_payment_flow') === 'hosted';
     523
     524                if (! $isHostedFlow) {
     525                    add_filter(
     526                        'payoneer-checkout.payment_gateway_is_available',
     527                        '__return_false'
     528                    );
     529                }
     530
     531                do_action('payoneer-checkout.payment_gateway_misconfiguration_detected');
     532            }
     533        });
     534    }
    480535}
  • payoneer-checkout/trunk/modules.local/checkout/src/Factory/Customer/WcBasedCustomerFactory.php

    r2915933 r2921678  
    170170        /** @var mixed $lastName */
    171171        $lastName = $wcCustomer->get_billing_last_name();
    172         /** @var mixed $state */
    173         $state = $wcCustomer->get_billing_state();
     172        /** @var mixed $billingStateCode */
     173        $billingStateCode = $wcCustomer->get_billing_state();
    174174
    175175        $name = $this->nameFactory->createName(
     
    181181            $billingState = $this->stateProvider->provideStateNameByCountryAndStateCode(
    182182                (string) $country,
    183                 (string) $state
     183                (string) $billingStateCode
    184184            );
    185185        } catch (CheckoutExceptionInterface $exception) {
    186             $billingState = null;
     186            $billingState = (string) $billingStateCode;
     187            $billingState = $billingState === '' ? null : $billingState;
    187188        }
    188189
     
    220221        /** @var mixed $lastName */
    221222        $lastName = $wcCustomer->get_shipping_last_name();
    222         /** @var mixed $state */
    223         $state = $wcCustomer->get_shipping_state();
     223        /** @var mixed $shippingStateCode */
     224        $shippingStateCode = $wcCustomer->get_shipping_state();
    224225
    225226        $name = $this->nameFactory->createName((string) $firstName, (string) $lastName);
     
    228229            $shippingState = $this->stateProvider->provideStateNameByCountryAndStateCode(
    229230                (string) $country,
    230                 (string) $state
     231                (string) $shippingStateCode
    231232            );
    232233        } catch (CheckoutExceptionInterface $exception) {
    233             $shippingState = null;
     234            $shippingState = (string) $shippingStateCode;
     235            $shippingState = $shippingState === '' ? null : $shippingState;
    234236        }
    235237
  • payoneer-checkout/trunk/modules.local/checkout/src/Factory/ListSession/OrderBasedListCommandFactory.php

    r2879805 r2921678  
    103103                               $this->wcOrderBasedProductsFactory->createProductsFromWcOrder($order)
    104104                           );
    105         if ($this->division) {
     105        if (is_string($this->division)) {
    106106            $command = $command->withDivision($this->division);
    107107        }
  • payoneer-checkout/trunk/modules.local/checkout/src/PaymentProcessor/AbstractPaymentProcessor.php

    r2814392 r2921678  
    33namespace Inpsyde\PayoneerForWoocommerce\Checkout\PaymentProcessor;
    44
     5use Inpsyde\PayoneerForWoocommerce\Checkout\MisconfigurationDetector\MisconfigurationDetectorInterface;
    56use Inpsyde\PayoneerForWoocommerce\PaymentGateway\PaymentProcessor\PaymentProcessorInterface;
    67use Inpsyde\PayoneerSdk\Api\Command\ResponseValidator\InteractionCodeFailureInterface;
     
    910abstract class AbstractPaymentProcessor implements PaymentProcessorInterface
    1011{
     12    /**
     13     * @var MisconfigurationDetectorInterface
     14     */
     15    protected $misconfigurationDetector;
     16
     17    /**
     18     * @param MisconfigurationDetectorInterface $misconfigurationDetector
     19     */
     20    public function __construct(MisconfigurationDetectorInterface $misconfigurationDetector)
     21    {
     22        $this->misconfigurationDetector = $misconfigurationDetector;
     23    }
     24
    1125    abstract public function processPayment(WC_Order $order): array;
    1226    /**
     
    2236        string $fallback
    2337    ): string {
     38
     39        if ($this->misconfigurationDetector->isCausedByMisconfiguration($exception)) {
     40            return __(
     41                'Failed to initialize Payoneer session. Payoneer Checkout is not configured properly.',
     42                'payoneer-checkout'
     43            );
     44        }
    2445
    2546        $previous = $exception;
  • payoneer-checkout/trunk/modules.local/embedded-payment/inc/custom_css_fields.php

    r2801406 r2921678  
    33declare(strict_types=1);
    44
    5 //Setting fields used to render widget CSS in custom mode.
    6 return [
    7     'checkout_css_custom_css' => [
    8         'title' => __('Custom CSS', 'payoneer-checkout'),
    9         'type' => 'textarea',
    10         'description' => __('Enter your custom CSS here', 'payoneer-checkout'),
    11     ],
    12 ];
     5use Dhii\Services\Factory;
     6
     7return new Factory([
     8    'embedded_payment.is_enabled',
     9    'embedded_payment.settings.checkout_css_custom_css.default',
     10], static function (
     11    bool $embeddedModeEnabled,
     12    string $defaultCss
     13): array {
     14    return [
     15        'checkout_css_custom_css' => [
     16            'title' => __('Custom CSS', 'payoneer-checkout'),
     17            'type' => 'css',
     18            'description' => __(
     19                'Customize the look and feel of the payment widget in embedded payment flow',
     20                'payoneer-checkout'
     21            ),
     22            'default' => $defaultCss,
     23            'class' => 'code css',
     24            'sanitize_callback' => 'strip_tags',
     25            'custom_attributes' => $embeddedModeEnabled ? [] : ['readonly' => 'readonly'],
     26        ],
     27    ];
     28});
  • payoneer-checkout/trunk/modules.local/embedded-payment/inc/extensions.php

    r2879805 r2921678  
    152152            return $payload->getOrder()->get_id();
    153153        },
     154
     155        'checkout.settings.appearance_settings_fields' => static function (
     156            array $fields,
     157            ContainerInterface $container
     158        ): array {
     159            /** @var array<string, array-key> $customCssFields */
     160            $customCssFields = $container->get('embedded_payment.settings.fields');
     161
     162            return array_merge($fields, $customCssFields);
     163        },
    154164    ];
    155165};
  • payoneer-checkout/trunk/modules.local/embedded-payment/inc/services.php

    r2906967 r2921678  
    1616use Inpsyde\PayoneerForWoocommerce\Checkout\ListSession\OrderAwareListSessionPersistor;
    1717use Inpsyde\PayoneerForWoocommerce\Checkout\ListSession\OrderAwareListSessionProvider;
     18use Inpsyde\PayoneerForWoocommerce\Checkout\MisconfigurationDetector\MisconfigurationDetectorInterface;
    1819use Inpsyde\PayoneerForWoocommerce\EmbeddedPayment\AjaxOrderPay\AjaxPayAction;
    1920use Inpsyde\PayoneerForWoocommerce\EmbeddedPayment\AjaxOrderPay\OrderPayload;
     
    4142        }),
    4243        'embedded_payment.settings.fields' => static function (ContainerInterface $container) {
    43             return (require __DIR__ . "/fields.php")($container);
     44            return (require __DIR__ . "/custom_css_fields.php")($container);
    4445        },
    4546
     
    336337            'inpsyde_payment_gateway.transaction_id_field_name',
    337338            'checkout.payment_flow_override_flag',
     339            'embedded_payment.misconfiguration_detector',
    338340        ], static function (
    339341            PaymentGateway $paymentGateway,
     
    343345            string $chargeIdFieldName,
    344346            string $transactionIdFieldName,
    345             string $hostedModeOverrideFlag
     347            string $hostedModeOverrideFlag,
     348            MisconfigurationDetectorInterface $misconfigurationDetector
    346349        ): PaymentProcessorInterface {
    347350            return new EmbeddedPaymentProcessor(
     
    352355                $chargeIdFieldName,
    353356                $transactionIdFieldName,
    354                 $hostedModeOverrideFlag
     357                $hostedModeOverrideFlag,
     358                $misconfigurationDetector
    355359            );
    356360        }),
  • payoneer-checkout/trunk/modules.local/embedded-payment/src/EmbeddedPaymentModule.php

    r2906967 r2921678  
    356356                    );
    357357                } catch (CheckoutExceptionInterface $exception) {
    358                     if ($addNotice) {
     358                    $misconfigurationDetected = did_action(
     359                        'payoneer-checkout.payment_gateway_misconfiguration_detected'
     360                    );
     361                    if ($addNotice && ! $misconfigurationDetected) {
    359362                        $message = __(
    360                             'Failed to initialize Payoneer session based on current checkout data. Possible reasons include incomplete billing data or an invalid order total',
     363                            'The selected payment method for your order is not available at the moment. Please select another payment method.',
    361364                            'payoneer-checkout'
    362365                        );
  • payoneer-checkout/trunk/modules.local/embedded-payment/src/PaymentProcessor/EmbeddedPaymentProcessor.php

    r2906967 r2921678  
    1010use Inpsyde\PayoneerForWoocommerce\Checkout\ListSession\OrderAwareListSessionPersistor;
    1111use Inpsyde\PayoneerForWoocommerce\Checkout\ListSession\OrderAwareListSessionProvider;
     12use Inpsyde\PayoneerForWoocommerce\Checkout\MisconfigurationDetector\MisconfigurationDetectorInterface;
    1213use Inpsyde\PayoneerForWoocommerce\Checkout\PaymentProcessor\AbstractPaymentProcessor;
    1314use Inpsyde\PayoneerForWoocommerce\PaymentGateway\Gateway\CommandFactory\WcOrderBasedUpdateCommandFactoryInterface;
     
    6162        string $chargeIdFieldName,
    6263        string $transactionIdFieldName,
    63         string $hostedModeOverrideFlag
     64        string $hostedModeOverrideFlag,
     65        MisconfigurationDetectorInterface $misconfigurationDetector
    6466    ) {
     67
     68        parent::__construct($misconfigurationDetector);
    6569
    6670        $this->paymentGateway = $paymentGateway;
  • payoneer-checkout/trunk/modules.local/hosted-payment/inc/extensions.php

    r2879805 r2921678  
    77use Inpsyde\PayoneerForWoocommerce\Checkout\Factory\ListSession\OrderBasedListCommandFactoryInterface;
    88use Inpsyde\PayoneerForWoocommerce\Checkout\ListSession\WcOrderListSessionPersistor;
     9use Inpsyde\PayoneerForWoocommerce\Checkout\MisconfigurationDetector\MisconfigurationDetectorInterface;
    910use Inpsyde\PayoneerForWoocommerce\HostedPayment\PaymentFieldsRenderer\DescriptionFieldRenderer;
    1011use Inpsyde\PayoneerForWoocommerce\HostedPayment\PaymentProcessor\HostedPaymentProcessor;
     
    4849                    'checkout.list_session_persistor.wc_order',
    4950                    'inpsyde_payment_gateway.transaction_id_field_name',
     51                    'hosted_payment.misconfiguration_detector',
    5052                ],
    5153                static function (
    5254                    OrderBasedListCommandFactoryInterface $listCommandFactory,
    5355                    WcOrderListSessionPersistor $persistor,
    54                     string $transactionIdFieldName
     56                    string $transactionIdFieldName,
     57                    MisconfigurationDetectorInterface $misconfigurationDetector
    5558                ): PaymentProcessorInterface {
    5659                    return new HostedPaymentProcessor(
    5760                        $listCommandFactory,
    5861                        $persistor,
    59                         $transactionIdFieldName
     62                        $transactionIdFieldName,
     63                        $misconfigurationDetector
    6064                    );
    6165                }
  • payoneer-checkout/trunk/modules.local/hosted-payment/src/PaymentProcessor/HostedPaymentProcessor.php

    r2837230 r2921678  
    99use Inpsyde\PayoneerForWoocommerce\Checkout\Factory\ListSession\OrderBasedListCommandFactoryInterface;
    1010use Inpsyde\PayoneerForWoocommerce\Checkout\ListSession\WcOrderListSessionPersistor;
     11use Inpsyde\PayoneerForWoocommerce\Checkout\MisconfigurationDetector\MisconfigurationDetectorInterface;
    1112use Inpsyde\PayoneerForWoocommerce\Checkout\PaymentProcessor\AbstractPaymentProcessor;
    1213use Inpsyde\PayoneerForWoocommerce\Checkout\PaymentProcessor\RedirectUrlCreatorTrait;
     
    4243        OrderBasedListCommandFactoryInterface $listCommandFactory,
    4344        WcOrderListSessionPersistor $listSessionPersistor,
    44         string $transactionIdFieldName
     45        string $transactionIdFieldName,
     46        MisconfigurationDetectorInterface $misconfigurationDetector
    4547    ) {
     48
     49        parent::__construct($misconfigurationDetector);
    4650
    4751        $this->listCommandFactory = $listCommandFactory;
  • payoneer-checkout/trunk/modules.local/payment-gateway/inc/services.php

    r2915933 r2921678  
    111111                    'inpsyde_payment_gateway.is_live_mode',
    112112                    'inpsyde_payment_gateway.show_payment_widget_to_customers_in_sandbox_mode',
    113                     'inpsyde_payment_gateway.is_debug',
    114113                ], static function (
    115114                    bool $isLiveMode,
    116                     bool $renderWidgetInSandboxMode,
    117                     bool $isDebug
     115                    bool $renderWidgetInSandboxMode
    118116                ): callable {
    119117                    return static function () use (
    120118                        $isLiveMode,
    121                         $renderWidgetInSandboxMode,
    122                         $isDebug
     119                        $renderWidgetInSandboxMode
    123120                    ): bool {
    124 
    125                         $renderWidgetForCustomers = $renderWidgetInSandboxMode && $isDebug;
    126121
    127122                        return $isLiveMode ||
    128123                               current_user_can('manage_woocommerce') ||
    129                                $renderWidgetForCustomers;
     124                               $renderWidgetInSandboxMode;
    130125                    };
    131126                }),
  • payoneer-checkout/trunk/modules.local/payment-gateway/src/Gateway/Factory/Customer/WcOrderBasedCustomerFactory.php

    r2915933 r2921678  
    130130        );
    131131
     132        /** @var mixed $billingStateCode */
     133        $billingStateCode = $order->get_billing_state();
     134
    132135        try {
    133136            $billingState = $this->stateProvider->provideStateNameByCountryAndStateCode(
    134137                $order->get_billing_country(),
    135                 $order->get_billing_state()
     138                (string) $billingStateCode
    136139            );
    137140        } catch (CheckoutExceptionInterface $exception) {
    138             $billingState = null;
     141            $billingState = (string) $billingStateCode;
     142            $billingState = $billingState === '' ? null : $billingState;
    139143        }
    140144
     
    163167        );
    164168
     169        /** @var mixed $shippingStateCode */
     170        $shippingStateCode = $order->get_shipping_state();
     171
    165172        try {
    166173            $shippingState = $this->stateProvider->provideStateNameByCountryAndStateCode(
    167174                $order->get_shipping_country(),
    168                 $order->get_shipping_state()
     175                (string) $shippingStateCode
    169176            );
    170177        } catch (CheckoutExceptionInterface $exception) {
    171             $shippingState = null;
     178            $shippingState = (string) $shippingStateCode;
     179            $shippingState = $shippingState === '' ? null : $shippingState;
    172180        }
    173181
  • payoneer-checkout/trunk/modules.local/payment-gateway/src/Gateway/PaymentGateway.php

    r2895123 r2921678  
    394394            // Print a generic error message right in the gateway fields
    395395            /* translators: Placeholder text if payment fields failed to render */
    396             esc_html_e('Payment widget failed to initialize due to an error', 'payoneer-checkout');
     396            esc_html_e(
     397                'Payment method not available. Please select another payment method.',
     398                'payoneer-checkout'
     399            );
    397400        }
    398401    }
  • payoneer-checkout/trunk/modules.local/wp/inc/services.php

    r2915933 r2921678  
    152152                    ],
    153153                    static function (WooCommerce $wooCommerce, bool $isAdmin, bool $isAjax): WC_Session {
    154                         if ($isAdmin && ! $isAjax) {
     154                        if (($isAdmin && ! $isAjax) || ! $wooCommerce->session instanceof WC_Session) {
    155155                            throw new PayoneerException('WooCommerce session is not available.');
    156156                        }
    157                         $wooCommerce->initialize_session();
    158157
    159158                        return $wooCommerce->session;
    160                     }
    161                 ),
    162 
    163             'wc.session.customer_id' =>
    164                 new Factory(
    165                     [
    166                         'wc.session',
    167                     ],
    168                     static function (\WC_Session $wcSession): string {
    169                         assert(
    170                             $wcSession instanceof \WC_Session_Handler
    171                             ||
    172                             /**
    173                              * Achieve CoCart compatibility without directly addressing CoCart
    174                              *
    175                              * @see https://github.com/co-cart/co-cart/issues/268#issuecomment-1269806425
    176                              */
    177                             count(
    178                                 array_intersect([
    179                                     'has_session',
    180                                 ], get_class_methods($wcSession))
    181                             )
    182                         );
    183 
    184                         /**
    185                          * Replicate \WC_Session_Handler::get_customer_unique_id()
    186                          * Which is only present in 5.3+ while we need to support 5.0+
    187                          * @psalm-suppress all
    188                          * phpcs:disable
    189                          */
    190                         $idExtractor = function (): string {
    191                             $id = '';
    192                             if (
    193 
    194                                 $this->has_session()
    195                                 && $this->_customer_id
    196                             ) {
    197                                 $id = $this->_customer_id;
    198                             } elseif (is_user_logged_in()) {
    199                                 $id = (string)get_current_user_id();
    200                             }
    201 
    202                             return $id;
    203                         };
    204                         //phpcs:enable
    205                         return (string)$idExtractor->call($wcSession);
    206159                    }
    207160                ),
  • payoneer-checkout/trunk/payoneer-checkout.php

    r2915933 r2921678  
    44 * Plugin Name: Payoneer Checkout
    55 * Description: Payoneer Checkout for WooCommerce
    6  * Version: 1.3.2
     6 * Version: 1.4.0-rc3
    77 * Author:      Payoneer
    88 * Requires at least: 5.4
     
    1515 * Text Domain: payoneer-checkout
    1616 * Domain Path: /languages
    17  * SHA: 853f563
     17 * SHA: 0b759ed
    1818 */
    1919
  • payoneer-checkout/trunk/vendor/autoload.php

    r2915933 r2921678  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInit8ad44ad16bf2f8d4f4584bd8fd37ad9f::getLoader();
     25return ComposerAutoloaderInit6829d72963e55d0174a46b02fef9558d::getLoader();
  • payoneer-checkout/trunk/vendor/composer/autoload_classmap.php

    r2915933 r2921678  
    205205    'Inpsyde\\PayoneerForWoocommerce\\Checkout\\ListSession\\WcSessionListSessionManager' => $baseDir . '/modules.local/checkout/src/ListSession/WcSessionListSessionManager.php',
    206206    'Inpsyde\\PayoneerForWoocommerce\\Checkout\\ListSession\\WcTransientListSessionManager' => $baseDir . '/modules.local/checkout/src/ListSession/WcTransientListSessionManager.php',
     207    'Inpsyde\\PayoneerForWoocommerce\\Checkout\\MisconfigurationDetector\\MisconfigurationDetector' => $baseDir . '/modules.local/checkout/src/MisconfigurationDetector/MisconfigurationDetector.php',
     208    'Inpsyde\\PayoneerForWoocommerce\\Checkout\\MisconfigurationDetector\\MisconfigurationDetectorInterface' => $baseDir . '/modules.local/checkout/src/MisconfigurationDetector/MisconfigurationDetectorInterface.php',
    207209    'Inpsyde\\PayoneerForWoocommerce\\Checkout\\PaymentFieldsRenderer\\CompoundPaymentFieldsRenderer' => $baseDir . '/modules.local/checkout/src/PaymentFieldsRenderer/CompoundPaymentFieldsRenderer.php',
    208210    'Inpsyde\\PayoneerForWoocommerce\\Checkout\\PaymentProcessor\\AbstractPaymentProcessor' => $baseDir . '/modules.local/checkout/src/PaymentProcessor/AbstractPaymentProcessor.php',
  • payoneer-checkout/trunk/vendor/composer/autoload_real.php

    r2915933 r2921678  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit8ad44ad16bf2f8d4f4584bd8fd37ad9f
     5class ComposerAutoloaderInit6829d72963e55d0174a46b02fef9558d
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit8ad44ad16bf2f8d4f4584bd8fd37ad9f', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInit6829d72963e55d0174a46b02fef9558d', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit8ad44ad16bf2f8d4f4584bd8fd37ad9f', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit6829d72963e55d0174a46b02fef9558d', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInit8ad44ad16bf2f8d4f4584bd8fd37ad9f::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInit6829d72963e55d0174a46b02fef9558d::getInitializer($loader));
    3333
    3434        $loader->register(true);
    3535
    36         $filesToLoad = \Composer\Autoload\ComposerStaticInit8ad44ad16bf2f8d4f4584bd8fd37ad9f::$files;
     36        $filesToLoad = \Composer\Autoload\ComposerStaticInit6829d72963e55d0174a46b02fef9558d::$files;
    3737        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3838            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • payoneer-checkout/trunk/vendor/composer/autoload_static.php

    r2915933 r2921678  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit8ad44ad16bf2f8d4f4584bd8fd37ad9f
     7class ComposerStaticInit6829d72963e55d0174a46b02fef9558d
    88{
    99    public static $files = array (
     
    438438        'Inpsyde\\PayoneerForWoocommerce\\Checkout\\ListSession\\WcSessionListSessionManager' => __DIR__ . '/../..' . '/modules.local/checkout/src/ListSession/WcSessionListSessionManager.php',
    439439        'Inpsyde\\PayoneerForWoocommerce\\Checkout\\ListSession\\WcTransientListSessionManager' => __DIR__ . '/../..' . '/modules.local/checkout/src/ListSession/WcTransientListSessionManager.php',
     440        'Inpsyde\\PayoneerForWoocommerce\\Checkout\\MisconfigurationDetector\\MisconfigurationDetector' => __DIR__ . '/../..' . '/modules.local/checkout/src/MisconfigurationDetector/MisconfigurationDetector.php',
     441        'Inpsyde\\PayoneerForWoocommerce\\Checkout\\MisconfigurationDetector\\MisconfigurationDetectorInterface' => __DIR__ . '/../..' . '/modules.local/checkout/src/MisconfigurationDetector/MisconfigurationDetectorInterface.php',
    440442        'Inpsyde\\PayoneerForWoocommerce\\Checkout\\PaymentFieldsRenderer\\CompoundPaymentFieldsRenderer' => __DIR__ . '/../..' . '/modules.local/checkout/src/PaymentFieldsRenderer/CompoundPaymentFieldsRenderer.php',
    441443        'Inpsyde\\PayoneerForWoocommerce\\Checkout\\PaymentProcessor\\AbstractPaymentProcessor' => __DIR__ . '/../..' . '/modules.local/checkout/src/PaymentProcessor/AbstractPaymentProcessor.php',
     
    859861    {
    860862        return \Closure::bind(function () use ($loader) {
    861             $loader->prefixLengthsPsr4 = ComposerStaticInit8ad44ad16bf2f8d4f4584bd8fd37ad9f::$prefixLengthsPsr4;
    862             $loader->prefixDirsPsr4 = ComposerStaticInit8ad44ad16bf2f8d4f4584bd8fd37ad9f::$prefixDirsPsr4;
    863             $loader->classMap = ComposerStaticInit8ad44ad16bf2f8d4f4584bd8fd37ad9f::$classMap;
     863            $loader->prefixLengthsPsr4 = ComposerStaticInit6829d72963e55d0174a46b02fef9558d::$prefixLengthsPsr4;
     864            $loader->prefixDirsPsr4 = ComposerStaticInit6829d72963e55d0174a46b02fef9558d::$prefixDirsPsr4;
     865            $loader->classMap = ComposerStaticInit6829d72963e55d0174a46b02fef9558d::$classMap;
    864866
    865867        }, null, ClassLoader::class);
  • payoneer-checkout/trunk/vendor/composer/installed.php

    r2915933 r2921678  
    22    'root' => array(
    33        'name' => 'inpsyde/payoneer-checkout',
    4         'pretty_version' => 'dev-release/1.3.2',
    5         'version' => 'dev-release/1.3.2',
    6         'reference' => '853f5638ad5614d9c343391533b6e7c4d5bb00c5',
     4        'pretty_version' => 'dev-release/1.4.0',
     5        'version' => 'dev-release/1.4.0',
     6        'reference' => '0b759edaef2068d711a2a299b5000e464e2fc6ca',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    113113        ),
    114114        'inpsyde/payoneer-checkout' => array(
    115             'pretty_version' => 'dev-release/1.3.2',
    116             'version' => 'dev-release/1.3.2',
    117             'reference' => '853f5638ad5614d9c343391533b6e7c4d5bb00c5',
     115            'pretty_version' => 'dev-release/1.4.0',
     116            'version' => 'dev-release/1.4.0',
     117            'reference' => '0b759edaef2068d711a2a299b5000e464e2fc6ca',
    118118            'type' => 'wordpress-plugin',
    119119            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.