diff --git a/modules/ppcp-api-client/src/Endpoint/BillingPlans.php b/modules/ppcp-api-client/src/Endpoint/BillingPlans.php index 3210b0d19..df7c9eb37 100644 --- a/modules/ppcp-api-client/src/Endpoint/BillingPlans.php +++ b/modules/ppcp-api-client/src/Endpoint/BillingPlans.php @@ -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( diff --git a/modules/ppcp-api-client/src/Endpoint/BillingSubscriptions.php b/modules/ppcp-api-client/src/Endpoint/BillingSubscriptions.php index c7f910858..3145ffc7d 100644 --- a/modules/ppcp-api-client/src/Endpoint/BillingSubscriptions.php +++ b/modules/ppcp-api-client/src/Endpoint/BillingSubscriptions.php @@ -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(); diff --git a/modules/ppcp-api-client/src/Endpoint/CatalogProducts.php b/modules/ppcp-api-client/src/Endpoint/CatalogProducts.php index 6d276bc3d..32296f4ee 100644 --- a/modules/ppcp-api-client/src/Endpoint/CatalogProducts.php +++ b/modules/ppcp-api-client/src/Endpoint/CatalogProducts.php @@ -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(); diff --git a/modules/ppcp-api-client/src/Entity/BillingCycle.php b/modules/ppcp-api-client/src/Entity/BillingCycle.php index 7e8253be9..76f1c25fa 100644 --- a/modules/ppcp-api-client/src/Entity/BillingCycle.php +++ b/modules/ppcp-api-client/src/Entity/BillingCycle.php @@ -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 { diff --git a/modules/ppcp-api-client/src/Entity/PaymentPreferences.php b/modules/ppcp-api-client/src/Entity/PaymentPreferences.php index 41b6b335c..b257c2389 100644 --- a/modules/ppcp-api-client/src/Entity/PaymentPreferences.php +++ b/modules/ppcp-api-client/src/Entity/PaymentPreferences.php @@ -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(), diff --git a/modules/ppcp-api-client/src/Entity/Plan.php b/modules/ppcp-api-client/src/Entity/Plan.php index a04f99c5a..06747776b 100644 --- a/modules/ppcp-api-client/src/Entity/Plan.php +++ b/modules/ppcp-api-client/src/Entity/Plan.php @@ -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(), diff --git a/modules/ppcp-api-client/src/Entity/Product.php b/modules/ppcp-api-client/src/Entity/Product.php index f1ea29f58..63acecc80 100644 --- a/modules/ppcp-api-client/src/Entity/Product.php +++ b/modules/ppcp-api-client/src/Entity/Product.php @@ -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. diff --git a/modules/ppcp-api-client/src/Factory/BillingCycleFactory.php b/modules/ppcp-api-client/src/Factory/BillingCycleFactory.php index e028b9a9f..6b00ff0ac 100644 --- a/modules/ppcp-api-client/src/Factory/BillingCycleFactory.php +++ b/modules/ppcp-api-client/src/Factory/BillingCycleFactory.php @@ -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; diff --git a/modules/ppcp-api-client/src/Factory/PaymentPreferencesFactory.php b/modules/ppcp-api-client/src/Factory/PaymentPreferencesFactory.php index ee715199c..44c0d0cef 100644 --- a/modules/ppcp-api-client/src/Factory/PaymentPreferencesFactory.php +++ b/modules/ppcp-api-client/src/Factory/PaymentPreferencesFactory.php @@ -13,6 +13,9 @@ use stdClass; use WC_Product; use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentPreferences; +/** + * Class PaymentPreferencesFactory + */ class PaymentPreferencesFactory { /** diff --git a/modules/ppcp-api-client/src/Factory/PlanFactory.php b/modules/ppcp-api-client/src/Factory/PlanFactory.php index c51104bac..bbf332d10 100644 --- a/modules/ppcp-api-client/src/Factory/PlanFactory.php +++ b/modules/ppcp-api-client/src/Factory/PlanFactory.php @@ -1,4 +1,11 @@ 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( diff --git a/modules/ppcp-api-client/src/Factory/ProductFactory.php b/modules/ppcp-api-client/src/Factory/ProductFactory.php index bd58a0e0c..a34602a21 100644 --- a/modules/ppcp-api-client/src/Factory/ProductFactory.php +++ b/modules/ppcp-api-client/src/Factory/ProductFactory.php @@ -13,6 +13,9 @@ use stdClass; use WooCommerce\PayPalCommerce\ApiClient\Entity\Product; use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; +/** + * Class ProductFactory + */ class ProductFactory { /** diff --git a/modules/ppcp-button/src/Assets/SmartButton.php b/modules/ppcp-button/src/Assets/SmartButton.php index ec6aced40..bd890c3c5 100644 --- a/modules/ppcp-button/src/Assets/SmartButton.php +++ b/modules/ppcp-button/src/Assets/SmartButton.php @@ -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. diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php b/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php index 6cccf027c..c1aadef01 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php @@ -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,