mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
Fix phpcs (WIP)
This commit is contained in:
parent
eca8a3b09c
commit
48db0851ce
13 changed files with 227 additions and 19 deletions
|
@ -40,16 +40,22 @@ class BillingPlans {
|
|||
private $bearer;
|
||||
|
||||
/**
|
||||
* Billing cycle factory
|
||||
*
|
||||
* @var BillingCycleFactory
|
||||
*/
|
||||
private $billing_cycle_factory;
|
||||
|
||||
/**
|
||||
* Plan factory
|
||||
*
|
||||
* @var PlanFactory
|
||||
*/
|
||||
private $plan_factory;
|
||||
|
||||
/**
|
||||
* The logger.
|
||||
*
|
||||
* The logger.
|
||||
*
|
||||
* @var LoggerInterface
|
||||
|
@ -59,9 +65,11 @@ class BillingPlans {
|
|||
/**
|
||||
* BillingPlans constructor.
|
||||
*
|
||||
* @param string $host The host.
|
||||
* @param Bearer $bearer The bearer.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param string $host The host.
|
||||
* @param Bearer $bearer The bearer.
|
||||
* @param BillingCycleFactory $billing_cycle_factory Billing cycle factory.
|
||||
* @param PlanFactory $plan_factory Plan factory.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
*/
|
||||
public function __construct(
|
||||
string $host,
|
||||
|
@ -80,7 +88,10 @@ class BillingPlans {
|
|||
/**
|
||||
* Creates a subscription plan.
|
||||
*
|
||||
* @param string $product_id The product id.
|
||||
* @param string $name Product name.
|
||||
* @param string $product_id Product ID.
|
||||
* @param array $billing_cycles Billing cycles.
|
||||
* @param array $payment_preferences Payment preferences.
|
||||
*
|
||||
* @return Plan
|
||||
*
|
||||
|
@ -131,6 +142,16 @@ class BillingPlans {
|
|||
return $this->plan_factory->from_paypal_response( $json );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a plan,
|
||||
*
|
||||
* @param string $id Plan ID.
|
||||
*
|
||||
* @return Plan
|
||||
*
|
||||
* @throws RuntimeException If the request fails.
|
||||
* @throws PayPalApiException If the request fails.
|
||||
*/
|
||||
public function plan( string $id ): Plan {
|
||||
$bearer = $this->bearer->bearer();
|
||||
$url = trailingslashit( $this->host ) . 'v1/billing/plans/' . $id;
|
||||
|
@ -159,6 +180,17 @@ class BillingPlans {
|
|||
return $this->plan_factory->from_paypal_response( $json );
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates pricing.
|
||||
*
|
||||
* @param string $id Plan ID.
|
||||
* @param BillingCycle $billing_cycle Billing cycle.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws RuntimeException If the request fails.
|
||||
* @throws PayPalApiException If the request fails.
|
||||
*/
|
||||
public function update_pricing( string $id, BillingCycle $billing_cycle ): void {
|
||||
$data = array(
|
||||
'pricing_schemes' => array(
|
||||
|
|
|
@ -140,7 +140,11 @@ class BillingSubscriptions {
|
|||
* Cancels a Subscription.
|
||||
*
|
||||
* @param string $id Subscription ID.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws RuntimeException If the request fails.
|
||||
* @throws PayPalApiException If the request fails.
|
||||
*/
|
||||
public function cancel( string $id ): void {
|
||||
$data = array(
|
||||
|
@ -177,7 +181,11 @@ class BillingSubscriptions {
|
|||
* Returns a Subscription object from the given ID.
|
||||
*
|
||||
* @param string $id Subscription ID.
|
||||
*
|
||||
* @return stdClass
|
||||
*
|
||||
* @throws RuntimeException If the request fails.
|
||||
* @throws PayPalApiException If the request fails.
|
||||
*/
|
||||
public function subscription( string $id ): stdClass {
|
||||
$bearer = $this->bearer->bearer();
|
||||
|
|
|
@ -42,7 +42,10 @@ class CatalogProducts {
|
|||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* Product factory.
|
||||
*
|
||||
* @var ProductFactory
|
||||
*/
|
||||
private $product_factory;
|
||||
|
@ -52,6 +55,7 @@ class CatalogProducts {
|
|||
*
|
||||
* @param string $host The host.
|
||||
* @param Bearer $bearer The bearer.
|
||||
* @param ProductFactory $product_factory Product factory.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
*/
|
||||
public function __construct(
|
||||
|
@ -121,7 +125,11 @@ class CatalogProducts {
|
|||
*
|
||||
* @param string $id Product ID.
|
||||
* @param array $data Data to update.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws RuntimeException If the request fails.
|
||||
* @throws PayPalApiException If the request fails.
|
||||
*/
|
||||
public function update( string $id, array $data ): void {
|
||||
$bearer = $this->bearer->bearer();
|
||||
|
@ -155,7 +163,11 @@ class CatalogProducts {
|
|||
* Return a Product from the given ID.
|
||||
*
|
||||
* @param string $id Product ID.
|
||||
*
|
||||
* @return Product
|
||||
*
|
||||
* @throws RuntimeException If the request fails.
|
||||
* @throws PayPalApiException If the request fails.
|
||||
*/
|
||||
public function product( string $id ): Product {
|
||||
$bearer = $this->bearer->bearer();
|
||||
|
|
|
@ -9,33 +9,55 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||
|
||||
/**
|
||||
* Class BillingCycle
|
||||
*/
|
||||
class BillingCycle {
|
||||
|
||||
/**
|
||||
* Frequency.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $frequency;
|
||||
|
||||
/**
|
||||
* Sequence.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $sequence;
|
||||
|
||||
/**
|
||||
* Tenure Type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tenure_type;
|
||||
|
||||
/**
|
||||
* Pricing scheme.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $pricing_scheme;
|
||||
|
||||
/**
|
||||
* Total cycles.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $total_cycles;
|
||||
|
||||
/**
|
||||
* BillingCycle constructor.
|
||||
*
|
||||
* @param array $frequency Frequency.
|
||||
* @param int $sequence Sequence.
|
||||
* @param string $tenure_type Tenure type.
|
||||
* @param array $pricing_scheme Pricing scheme.
|
||||
* @param int $total_cycles Total cycles.
|
||||
*/
|
||||
public function __construct(
|
||||
array $frequency,
|
||||
int $sequence,
|
||||
|
@ -51,6 +73,8 @@ class BillingCycle {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns frequency.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function frequency(): array {
|
||||
|
@ -58,6 +82,8 @@ class BillingCycle {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns sequence.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function sequence(): int {
|
||||
|
@ -65,6 +91,8 @@ class BillingCycle {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns tenure type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function tenure_type(): string {
|
||||
|
@ -72,6 +100,8 @@ class BillingCycle {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns pricing scheme.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function pricing_scheme(): array {
|
||||
|
@ -79,6 +109,8 @@ class BillingCycle {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return total cycles.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function total_cycles(): int {
|
||||
|
|
|
@ -9,27 +9,47 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||
|
||||
/**
|
||||
* Class PaymentPreferences
|
||||
*/
|
||||
class PaymentPreferences {
|
||||
|
||||
/**
|
||||
* Setup fee.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $setup_fee;
|
||||
|
||||
/**
|
||||
* Auto bill outstanding.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $auto_bill_outstanding;
|
||||
|
||||
/**
|
||||
* Setup fee failure action.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $setup_fee_failure_action;
|
||||
|
||||
/**
|
||||
* Payment failure threshold.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $payment_failure_threshold;
|
||||
|
||||
/**
|
||||
* PaymentPreferences constructor.
|
||||
*
|
||||
* @param array $setup_fee Setup fee.
|
||||
* @param bool $auto_bill_outstanding Auto bill outstanding.
|
||||
* @param string $setup_fee_failure_action Setup fee failure action.
|
||||
* @param int $payment_failure_threshold payment failure threshold.
|
||||
*/
|
||||
public function __construct(
|
||||
array $setup_fee,
|
||||
bool $auto_bill_outstanding = true,
|
||||
|
@ -44,6 +64,8 @@ class PaymentPreferences {
|
|||
}
|
||||
|
||||
/**
|
||||
* Setup fee.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setup_fee(): array {
|
||||
|
@ -51,6 +73,8 @@ class PaymentPreferences {
|
|||
}
|
||||
|
||||
/**
|
||||
* Auto bill outstanding.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function auto_bill_outstanding(): bool {
|
||||
|
@ -58,6 +82,8 @@ class PaymentPreferences {
|
|||
}
|
||||
|
||||
/**
|
||||
* Setup fee failure action.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setup_fee_failure_action(): string {
|
||||
|
@ -65,12 +91,19 @@ class PaymentPreferences {
|
|||
}
|
||||
|
||||
/**
|
||||
* Payment failure threshold.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function payment_failure_threshold(): int {
|
||||
return $this->payment_failure_threshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Payment Preferences as array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array():array {
|
||||
return array(
|
||||
'setup_fee' => $this->setup_fee(),
|
||||
|
|
|
@ -9,38 +9,63 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||
|
||||
/**
|
||||
* Class Plan
|
||||
*/
|
||||
class Plan {
|
||||
|
||||
/**
|
||||
* Plan ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* Plan name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Product ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $product_id;
|
||||
|
||||
/**
|
||||
* Billing cycles.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $billing_cycles;
|
||||
|
||||
/**
|
||||
* Payment preferences.
|
||||
*
|
||||
* @var PaymentPreferences
|
||||
*/
|
||||
private $payment_preferences;
|
||||
|
||||
/**
|
||||
* Plan status.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* Plan constructor.
|
||||
*
|
||||
* @param string $id Plan ID.
|
||||
* @param string $name Plan name.
|
||||
* @param string $product_id Product ID.
|
||||
* @param array $billing_cycles Billing cycles.
|
||||
* @param PaymentPreferences $payment_preferences Payment preferences.
|
||||
* @param string $status Plan status.
|
||||
*/
|
||||
public function __construct(
|
||||
string $id,
|
||||
string $name,
|
||||
|
@ -58,6 +83,8 @@ class Plan {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns Plan ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function id(): string {
|
||||
|
@ -65,6 +92,8 @@ class Plan {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns Plan name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function name(): string {
|
||||
|
@ -72,6 +101,8 @@ class Plan {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns Product ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function product_id(): string {
|
||||
|
@ -79,6 +110,8 @@ class Plan {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns Billing cycles.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function billing_cycles(): array {
|
||||
|
@ -86,6 +119,8 @@ class Plan {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns Payment preferences.
|
||||
*
|
||||
* @return PaymentPreferences
|
||||
*/
|
||||
public function payment_preferences(): PaymentPreferences {
|
||||
|
@ -93,12 +128,19 @@ class Plan {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns Plan status.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function status(): string {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Plan as array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array():array {
|
||||
return array(
|
||||
'id' => $this->id(),
|
||||
|
|
|
@ -9,6 +9,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||
|
||||
/**
|
||||
* Class Product
|
||||
*/
|
||||
class Product {
|
||||
|
||||
/**
|
||||
|
@ -33,6 +36,8 @@ class Product {
|
|||
private $description;
|
||||
|
||||
/**
|
||||
* Product constructor.
|
||||
*
|
||||
* @param string $id Product ID.
|
||||
* @param string $name Product name.
|
||||
* @param string $description Product description.
|
||||
|
|
|
@ -13,6 +13,9 @@ use stdClass;
|
|||
use WC_Product;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\BillingCycle;
|
||||
|
||||
/**
|
||||
* Class BillingCycleFactory
|
||||
*/
|
||||
class BillingCycleFactory {
|
||||
|
||||
/**
|
||||
|
@ -23,9 +26,9 @@ class BillingCycleFactory {
|
|||
private $currency;
|
||||
|
||||
/**
|
||||
* The currency.
|
||||
* BillingCycleFactory constructor.
|
||||
*
|
||||
* @param string $currency
|
||||
* @param string $currency The currency.
|
||||
*/
|
||||
public function __construct( string $currency ) {
|
||||
$this->currency = $currency;
|
||||
|
|
|
@ -13,6 +13,9 @@ use stdClass;
|
|||
use WC_Product;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentPreferences;
|
||||
|
||||
/**
|
||||
* Class PaymentPreferencesFactory
|
||||
*/
|
||||
class PaymentPreferencesFactory {
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* Plan Factory.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\Webhooks\Handler
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
|
||||
|
||||
|
@ -6,17 +13,31 @@ use stdClass;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Plan;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* Class PlanFactory
|
||||
*/
|
||||
class PlanFactory {
|
||||
|
||||
/**
|
||||
* Billing cycle factory.
|
||||
*
|
||||
* @var BillingCycleFactory
|
||||
*/
|
||||
private $billing_cycle_factory;
|
||||
|
||||
/**
|
||||
* Payment preferences factory.
|
||||
*
|
||||
* @var PaymentPreferencesFactory
|
||||
*/
|
||||
private $payment_preferences_factory;
|
||||
|
||||
/**
|
||||
* PlanFactory constructor.
|
||||
*
|
||||
* @param BillingCycleFactory $billing_cycle_factory Billing cycle factory.
|
||||
* @param PaymentPreferencesFactory $payment_preferences_factory Payment preferences factory.
|
||||
*/
|
||||
public function __construct(
|
||||
BillingCycleFactory $billing_cycle_factory,
|
||||
PaymentPreferencesFactory $payment_preferences_factory
|
||||
|
@ -25,6 +46,15 @@ class PlanFactory {
|
|||
$this->payment_preferences_factory = $payment_preferences_factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Plan from PayPal response.
|
||||
*
|
||||
* @param stdClass $data The data.
|
||||
*
|
||||
* @return Plan
|
||||
*
|
||||
* @throws RuntimeException If it could not create Plan.
|
||||
*/
|
||||
public function from_paypal_response( stdClass $data ): Plan {
|
||||
if ( ! isset( $data->id ) ) {
|
||||
throw new RuntimeException(
|
||||
|
|
|
@ -13,6 +13,9 @@ use stdClass;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Product;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* Class ProductFactory
|
||||
*/
|
||||
class ProductFactory {
|
||||
|
||||
/**
|
||||
|
|
|
@ -200,7 +200,10 @@ class SmartButton implements SmartButtonInterface {
|
|||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* Session handler.
|
||||
*
|
||||
* @var SessionHandler
|
||||
*/
|
||||
private $session_handler;
|
||||
|
@ -209,7 +212,8 @@ class SmartButton implements SmartButtonInterface {
|
|||
* SmartButton constructor.
|
||||
*
|
||||
* @param string $module_url The URL to the module.
|
||||
* @param string $version The assets version.
|
||||
* @param string $version The assets version.
|
||||
* @param SessionHandler $session_handler The Session handler.
|
||||
* @param Settings $settings The Settings.
|
||||
* @param PayerFactory $payer_factory The Payer factory.
|
||||
* @param string $client_id The client ID.
|
||||
|
|
|
@ -164,20 +164,21 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
/**
|
||||
* PayPalGateway constructor.
|
||||
*
|
||||
* @param SettingsRenderer $settings_renderer The Settings Renderer.
|
||||
* @param FundingSourceRenderer $funding_source_renderer The funding source renderer.
|
||||
* @param OrderProcessor $order_processor The Order Processor.
|
||||
* @param ContainerInterface $config The settings.
|
||||
* @param SessionHandler $session_handler The Session Handler.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param State $state The state.
|
||||
* @param SettingsRenderer $settings_renderer The Settings Renderer.
|
||||
* @param FundingSourceRenderer $funding_source_renderer The funding source renderer.
|
||||
* @param OrderProcessor $order_processor The Order Processor.
|
||||
* @param ContainerInterface $config The settings.
|
||||
* @param SessionHandler $session_handler The Session Handler.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param State $state The state.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
||||
* @param string $page_id ID of the current PPCP gateway settings page, or empty if it is not such page.
|
||||
* @param Environment $environment The environment.
|
||||
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
||||
* @param string $page_id ID of the current PPCP gateway settings page, or empty if it is not such page.
|
||||
* @param Environment $environment The environment.
|
||||
* @param PaymentTokenRepository $payment_token_repository The payment token repository.
|
||||
* @param string $api_shop_country The api shop country.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param string $api_shop_country The api shop country.
|
||||
* @param OrderEndpoint $order_endpoint The order endpoint.
|
||||
*/
|
||||
public function __construct(
|
||||
SettingsRenderer $settings_renderer,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue