mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-08 21:52:55 +08:00
codesniffer cleanup
This commit is contained in:
parent
51465324a0
commit
4478ec87f2
13 changed files with 51 additions and 55 deletions
2
.github/workflows/php.yml
vendored
2
.github/workflows/php.yml
vendored
|
@ -29,4 +29,4 @@ jobs:
|
|||
- name: Run test suite
|
||||
run: ./vendor/bin/phpunit
|
||||
- name: Run cs
|
||||
run: ./vendor/bin/phpcs src modules.local/ppcp-wc-gateway modules.local/ppcp-button/src/ --standard=Inpsyde
|
||||
run: ./vendor/bin/phpcs src modules.local/ppcp-wc-gateway modules.local/ppcp-button/src/ modules.local/ppcp-onboarding/src/ --standard=Inpsyde
|
||||
|
|
|
@ -47,7 +47,7 @@ class SmartButton implements SmartButtonInterface
|
|||
echo '<div id="ppc-button"></div>';
|
||||
};
|
||||
|
||||
$dccRenderer = static function ($id = null) {
|
||||
$dccRenderer = static function (string $id = null) {
|
||||
if (!$id) {
|
||||
$id = 'ppcp-hosted-fields';
|
||||
}
|
||||
|
@ -142,7 +142,6 @@ class SmartButton implements SmartButtonInterface
|
|||
10
|
||||
);
|
||||
if (
|
||||
|
||||
$this->settings->has('dcc_checkout_enabled')
|
||||
&& wc_string_to_bool($this->settings->get('dcc_checkout_enabled'))
|
||||
) {
|
||||
|
@ -252,7 +251,8 @@ class SmartButton implements SmartButtonInterface
|
|||
if ($payee->merchantId()) {
|
||||
$params['merchant-id'] = $payee->merchantId();
|
||||
}
|
||||
$disableFunding = $this->settings->has('disable_funding') ? $this->settings->get('disable_funding') : [];
|
||||
$disableFunding = $this->settings->has('disable_funding') ?
|
||||
$this->settings->get('disable_funding') : [];
|
||||
if (is_array($disableFunding) && count($disableFunding)) {
|
||||
$params['disable-funding'] = implode(',', $disableFunding);
|
||||
}
|
||||
|
@ -260,10 +260,9 @@ class SmartButton implements SmartButtonInterface
|
|||
return $smartButtonUrl;
|
||||
}
|
||||
|
||||
private function attributes() : array {
|
||||
$attributes = [
|
||||
//'data-partner-attribution-id' => '',
|
||||
];
|
||||
private function attributes(): array
|
||||
{
|
||||
$attributes = [];
|
||||
try {
|
||||
$clientToken = $this->identityToken->generate();
|
||||
$attributes['data-client-token'] = $clientToken->token();
|
||||
|
|
|
@ -148,7 +148,12 @@ class ChangeCartEndpoint implements EndpointInterface
|
|||
$variationId = $this->productDataStore->find_matching_product_variation($product, $variations);
|
||||
|
||||
//ToDo: Check stock status for variation.
|
||||
return false !== $this->cart->add_to_cart($product->get_id(), $quantity, $variationId, $variations);
|
||||
return false !== $this->cart->add_to_cart(
|
||||
$product->get_id(),
|
||||
$quantity,
|
||||
$variationId,
|
||||
$variations
|
||||
);
|
||||
}
|
||||
|
||||
private function generatePurchaseUnits(): array
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\Button\Endpoint;
|
||||
|
||||
|
||||
class CreateWcOrderEndpoint implements EndpointInterface
|
||||
{
|
||||
|
||||
public const ENDPOINT = 'ppc-create-wc-order';
|
||||
|
||||
public static function nonce(): string
|
||||
{
|
||||
return self::ENDPOINT;
|
||||
}
|
||||
|
||||
public function handleRequest(): bool
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -13,17 +13,17 @@ class RequestData
|
|||
{
|
||||
$stream = file_get_contents('php://input');
|
||||
$json = json_decode($stream, true);
|
||||
add_filter('nonce_user_logged_out', array($this, 'nonceFix'), 100);
|
||||
add_filter('nonce_user_logged_out', [$this, 'nonceFix'], 100);
|
||||
if (
|
||||
! isset($json['nonce'])
|
||||
|| !wp_verify_nonce($json['nonce'], $nonce)
|
||||
) {
|
||||
remove_filter('nonce_user_logged_out', array($this, 'nonceFix'), 100);
|
||||
remove_filter('nonce_user_logged_out', [$this, 'nonceFix'], 100);
|
||||
throw new RuntimeException(
|
||||
__('Could not validate nonce.', 'woocommerce-paypal-commerce-gateway')
|
||||
);
|
||||
}
|
||||
remove_filter('nonce_user_logged_out', array($this, 'nonceFix'), 100);
|
||||
remove_filter('nonce_user_logged_out', [$this, 'nonceFix'], 100);
|
||||
|
||||
return $this->sanitize($json);
|
||||
}
|
||||
|
@ -34,9 +34,11 @@ class RequestData
|
|||
* the nonce validation will fail. this fixes this problem:
|
||||
*
|
||||
* @wp-hook nonce_user_logged_out
|
||||
* @see https://github.com/woocommerce/woocommerce/blob/69e3835041113bee80379c1037e97e26815a699b/includes/class-wc-session-handler.php#L288-L296 * @return int
|
||||
* @see https://github.com/woocommerce/woocommerce/blob/69e3835041113bee80379c1037e97e26815a699b/includes/class-wc-session-handler.php#L288-L296
|
||||
* @return int
|
||||
*/
|
||||
public function nonceFix() {
|
||||
public function nonceFix(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,10 @@ class OrderTablePaymentStatusColumn
|
|||
|
||||
if ($this->isCaptured($wcOrder)) {
|
||||
$this->renderCompletedStatus();
|
||||
} else {
|
||||
$this->renderIncompletedStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->renderIncompletedStatus();
|
||||
}
|
||||
|
||||
private function renderForOrder(\WC_Order $order): bool
|
||||
|
|
|
@ -125,7 +125,8 @@ class WcGateway extends WcGatewayBase
|
|||
return false;
|
||||
}
|
||||
|
||||
private function renderAuthorizationMessageForStatus(string $status) {
|
||||
private function renderAuthorizationMessageForStatus(string $status)
|
||||
{
|
||||
|
||||
$messageMapping = [
|
||||
AuthorizedPaymentsProcessor::SUCCESSFUL => AuthorizeOrderActionNotice::SUCCESS,
|
||||
|
@ -137,7 +138,9 @@ class WcGateway extends WcGatewayBase
|
|||
$this->notice->displayMessage($displayMessage);
|
||||
}
|
||||
|
||||
public function generate_ppcp_onboarding_html($a, $b) {
|
||||
public function generate_ppcp_onboarding_html($a, $b)
|
||||
{
|
||||
|
||||
$this->onboardingRenderer->render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,9 @@ class AuthorizedPaymentsProcessor
|
|||
return true;
|
||||
}
|
||||
|
||||
public function lastStatus() : string {
|
||||
public function lastStatus(): string
|
||||
{
|
||||
|
||||
return $this->lastStatus;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
|
||||
class FullyOnboardedSettings extends StartSettings implements SettingsFields
|
||||
{
|
||||
public function fields(): array
|
||||
|
@ -127,7 +127,9 @@ class FullyOnboardedSettings extends StartSettings implements SettingsFields
|
|||
];
|
||||
}
|
||||
|
||||
private function creditCards() : array {
|
||||
private function creditCards(): array
|
||||
{
|
||||
|
||||
return [
|
||||
|
||||
'credit_card_settings' => [
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
|
||||
class ProgressiveSettings extends StartSettings implements SettingsFields
|
||||
{
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
|
||||
trait SettingsTrait
|
||||
{
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
|
||||
class StartSettings implements SettingsFields
|
||||
{
|
||||
|
||||
use SettingsTrait;
|
||||
|
||||
public function fields(): array
|
||||
|
|
4
yarn.lock
Normal file
4
yarn.lock
Normal file
|
@ -0,0 +1,4 @@
|
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue