mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
Fix phpcs errors
This commit is contained in:
parent
f5a2fca5fb
commit
a71c8b134a
9 changed files with 207 additions and 206 deletions
|
@ -37,6 +37,8 @@ class PaymentToken {
|
||||||
private $type;
|
private $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The payment source.
|
||||||
|
*
|
||||||
* @var \stdClass
|
* @var \stdClass
|
||||||
*/
|
*/
|
||||||
private $source;
|
private $source;
|
||||||
|
@ -46,6 +48,7 @@ class PaymentToken {
|
||||||
*
|
*
|
||||||
* @param string $id The Id.
|
* @param string $id The Id.
|
||||||
* @param string $type The type.
|
* @param string $type The type.
|
||||||
|
* @param \stdClass $source The source.
|
||||||
* @throws RuntimeException When the type is not valid.
|
* @throws RuntimeException When the type is not valid.
|
||||||
*/
|
*/
|
||||||
public function __construct( string $id, string $type = self::TYPE_PAYMENT_METHOD_TOKEN, \stdClass $source ) {
|
public function __construct( string $id, string $type = self::TYPE_PAYMENT_METHOD_TOKEN, \stdClass $source ) {
|
||||||
|
@ -82,8 +85,7 @@ class PaymentToken {
|
||||||
*
|
*
|
||||||
* @return \stdClass
|
* @return \stdClass
|
||||||
*/
|
*/
|
||||||
public function source(): \stdClass
|
public function source(): \stdClass {
|
||||||
{
|
|
||||||
return $this->source;
|
return $this->source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,8 @@ class SmartButton implements SmartButtonInterface {
|
||||||
private $environment;
|
private $environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The payment token repository.
|
||||||
|
*
|
||||||
* @var PaymentTokenRepository
|
* @var PaymentTokenRepository
|
||||||
*/
|
*/
|
||||||
private $payment_token_repository;
|
private $payment_token_repository;
|
||||||
|
@ -136,6 +138,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
||||||
* @param MessagesApply $messages_apply The Messages apply helper.
|
* @param MessagesApply $messages_apply The Messages apply helper.
|
||||||
* @param Environment $environment The environment object.
|
* @param Environment $environment The environment object.
|
||||||
|
* @param PaymentTokenRepository $payment_token_repository The payment token repository.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $module_url,
|
string $module_url,
|
||||||
|
@ -1025,8 +1028,8 @@ class SmartButton implements SmartButtonInterface {
|
||||||
/**
|
/**
|
||||||
* Check if tokens has card source.
|
* Check if tokens has card source.
|
||||||
*
|
*
|
||||||
* @param PaymentToken[] $tokens
|
* @param PaymentToken[] $tokens The tokens.
|
||||||
* @return bool
|
* @return bool Wether tokens contains card or not.
|
||||||
*/
|
*/
|
||||||
protected function tokens_contains_card( $tokens ) {
|
protected function tokens_contains_card( $tokens ) {
|
||||||
foreach ( $tokens as $token ) {
|
foreach ( $tokens as $token ) {
|
||||||
|
|
|
@ -73,8 +73,10 @@ class PaymentTokenRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $id
|
* Return all tokens for a user.
|
||||||
* @return array
|
*
|
||||||
|
* @param int $id The user id.
|
||||||
|
* @return PaymentToken[]
|
||||||
*/
|
*/
|
||||||
public function all_for_user_id( int $id ) {
|
public function all_for_user_id( int $id ) {
|
||||||
$tokens = get_user_meta( $id, self::USER_META, true );
|
$tokens = get_user_meta( $id, self::USER_META, true );
|
||||||
|
@ -82,13 +84,13 @@ class PaymentTokenRepository {
|
||||||
return (array) $tokens;
|
return (array) $tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tokens_array = [];
|
$tokens_array = array();
|
||||||
try {
|
try {
|
||||||
$tokens = $this->endpoint->for_user( $id );
|
$tokens = $this->endpoint->for_user( $id );
|
||||||
update_user_meta( $id, self::USER_META, $tokens );
|
update_user_meta( $id, self::USER_META, $tokens );
|
||||||
return $tokens;
|
return $tokens;
|
||||||
} catch ( RuntimeException $exception ) {
|
} catch ( RuntimeException $exception ) {
|
||||||
return [];
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,24 +58,6 @@ class SubscriptionModule implements ModuleInterface {
|
||||||
10,
|
10,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
add_action('woocommerce_init', function () use($container) {
|
|
||||||
$api = $container->get('api.endpoint.payment-token' );
|
|
||||||
try {
|
|
||||||
$tokens = $api->for_user(1);
|
|
||||||
|
|
||||||
for($i = 0; $i < count($tokens); $i++) {
|
|
||||||
$api->delete_token($tokens[$i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$a = 1;
|
|
||||||
} catch (RuntimeException $exception) {
|
|
||||||
$a = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,21 +46,29 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
private $refund_processor;
|
private $refund_processor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The payment token repository.
|
||||||
|
*
|
||||||
* @var PaymentTokenRepository
|
* @var PaymentTokenRepository
|
||||||
*/
|
*/
|
||||||
private $payment_token_repository;
|
private $payment_token_repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The purchase unit factory.
|
||||||
|
*
|
||||||
* @var PurchaseUnitFactory
|
* @var PurchaseUnitFactory
|
||||||
*/
|
*/
|
||||||
private $purchase_unit_factory;
|
private $purchase_unit_factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The payer factory.
|
||||||
|
*
|
||||||
* @var PayerFactory
|
* @var PayerFactory
|
||||||
*/
|
*/
|
||||||
private $payer_factory;
|
private $payer_factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The order endpoint.
|
||||||
|
*
|
||||||
* @var OrderEndpoint
|
* @var OrderEndpoint
|
||||||
*/
|
*/
|
||||||
private $order_endpoint;
|
private $order_endpoint;
|
||||||
|
@ -77,6 +85,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
* @param SessionHandler $session_handler The Session Handler.
|
* @param SessionHandler $session_handler The Session Handler.
|
||||||
* @param RefundProcessor $refund_processor The refund processor.
|
* @param RefundProcessor $refund_processor The refund processor.
|
||||||
* @param State $state The state.
|
* @param State $state The state.
|
||||||
|
* @param PaymentTokenRepository $payment_token_repository The payment token repository.
|
||||||
|
* @param PurchaseUnitFactory $purchase_unit_factory The purchase unit factory.
|
||||||
|
* @param PayerFactory $payer_factory The payer factory.
|
||||||
|
* @param OrderEndpoint $order_endpoint The order endpoint.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
SettingsRenderer $settings_renderer,
|
SettingsRenderer $settings_renderer,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue