mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +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;
|
private $bearer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Billing cycle factory
|
||||||
|
*
|
||||||
* @var BillingCycleFactory
|
* @var BillingCycleFactory
|
||||||
*/
|
*/
|
||||||
private $billing_cycle_factory;
|
private $billing_cycle_factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Plan factory
|
||||||
|
*
|
||||||
* @var PlanFactory
|
* @var PlanFactory
|
||||||
*/
|
*/
|
||||||
private $plan_factory;
|
private $plan_factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The logger.
|
||||||
|
*
|
||||||
* The logger.
|
* The logger.
|
||||||
*
|
*
|
||||||
* @var LoggerInterface
|
* @var LoggerInterface
|
||||||
|
@ -61,6 +67,8 @@ class BillingPlans {
|
||||||
*
|
*
|
||||||
* @param string $host The host.
|
* @param string $host The host.
|
||||||
* @param Bearer $bearer The bearer.
|
* @param Bearer $bearer The bearer.
|
||||||
|
* @param BillingCycleFactory $billing_cycle_factory Billing cycle factory.
|
||||||
|
* @param PlanFactory $plan_factory Plan factory.
|
||||||
* @param LoggerInterface $logger The logger.
|
* @param LoggerInterface $logger The logger.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -80,7 +88,10 @@ class BillingPlans {
|
||||||
/**
|
/**
|
||||||
* Creates a subscription plan.
|
* 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
|
* @return Plan
|
||||||
*
|
*
|
||||||
|
@ -131,6 +142,16 @@ class BillingPlans {
|
||||||
return $this->plan_factory->from_paypal_response( $json );
|
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 {
|
public function plan( string $id ): Plan {
|
||||||
$bearer = $this->bearer->bearer();
|
$bearer = $this->bearer->bearer();
|
||||||
$url = trailingslashit( $this->host ) . 'v1/billing/plans/' . $id;
|
$url = trailingslashit( $this->host ) . 'v1/billing/plans/' . $id;
|
||||||
|
@ -159,6 +180,17 @@ class BillingPlans {
|
||||||
return $this->plan_factory->from_paypal_response( $json );
|
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 {
|
public function update_pricing( string $id, BillingCycle $billing_cycle ): void {
|
||||||
$data = array(
|
$data = array(
|
||||||
'pricing_schemes' => array(
|
'pricing_schemes' => array(
|
||||||
|
|
|
@ -140,7 +140,11 @@ class BillingSubscriptions {
|
||||||
* Cancels a Subscription.
|
* Cancels a Subscription.
|
||||||
*
|
*
|
||||||
* @param string $id Subscription ID.
|
* @param string $id Subscription ID.
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws RuntimeException If the request fails.
|
||||||
|
* @throws PayPalApiException If the request fails.
|
||||||
*/
|
*/
|
||||||
public function cancel( string $id ): void {
|
public function cancel( string $id ): void {
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@ -177,7 +181,11 @@ class BillingSubscriptions {
|
||||||
* Returns a Subscription object from the given ID.
|
* Returns a Subscription object from the given ID.
|
||||||
*
|
*
|
||||||
* @param string $id Subscription ID.
|
* @param string $id Subscription ID.
|
||||||
|
*
|
||||||
* @return stdClass
|
* @return stdClass
|
||||||
|
*
|
||||||
|
* @throws RuntimeException If the request fails.
|
||||||
|
* @throws PayPalApiException If the request fails.
|
||||||
*/
|
*/
|
||||||
public function subscription( string $id ): stdClass {
|
public function subscription( string $id ): stdClass {
|
||||||
$bearer = $this->bearer->bearer();
|
$bearer = $this->bearer->bearer();
|
||||||
|
|
|
@ -42,7 +42,10 @@ class CatalogProducts {
|
||||||
* @var LoggerInterface
|
* @var LoggerInterface
|
||||||
*/
|
*/
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Product factory.
|
||||||
|
*
|
||||||
* @var ProductFactory
|
* @var ProductFactory
|
||||||
*/
|
*/
|
||||||
private $product_factory;
|
private $product_factory;
|
||||||
|
@ -52,6 +55,7 @@ class CatalogProducts {
|
||||||
*
|
*
|
||||||
* @param string $host The host.
|
* @param string $host The host.
|
||||||
* @param Bearer $bearer The bearer.
|
* @param Bearer $bearer The bearer.
|
||||||
|
* @param ProductFactory $product_factory Product factory.
|
||||||
* @param LoggerInterface $logger The logger.
|
* @param LoggerInterface $logger The logger.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -121,7 +125,11 @@ class CatalogProducts {
|
||||||
*
|
*
|
||||||
* @param string $id Product ID.
|
* @param string $id Product ID.
|
||||||
* @param array $data Data to update.
|
* @param array $data Data to update.
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws RuntimeException If the request fails.
|
||||||
|
* @throws PayPalApiException If the request fails.
|
||||||
*/
|
*/
|
||||||
public function update( string $id, array $data ): void {
|
public function update( string $id, array $data ): void {
|
||||||
$bearer = $this->bearer->bearer();
|
$bearer = $this->bearer->bearer();
|
||||||
|
@ -155,7 +163,11 @@ class CatalogProducts {
|
||||||
* Return a Product from the given ID.
|
* Return a Product from the given ID.
|
||||||
*
|
*
|
||||||
* @param string $id Product ID.
|
* @param string $id Product ID.
|
||||||
|
*
|
||||||
* @return Product
|
* @return Product
|
||||||
|
*
|
||||||
|
* @throws RuntimeException If the request fails.
|
||||||
|
* @throws PayPalApiException If the request fails.
|
||||||
*/
|
*/
|
||||||
public function product( string $id ): Product {
|
public function product( string $id ): Product {
|
||||||
$bearer = $this->bearer->bearer();
|
$bearer = $this->bearer->bearer();
|
||||||
|
|
|
@ -9,33 +9,55 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BillingCycle
|
||||||
|
*/
|
||||||
class BillingCycle {
|
class BillingCycle {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Frequency.
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $frequency;
|
private $frequency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sequence.
|
||||||
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $sequence;
|
private $sequence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Tenure Type.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $tenure_type;
|
private $tenure_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Pricing scheme.
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $pricing_scheme;
|
private $pricing_scheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Total cycles.
|
||||||
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $total_cycles;
|
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(
|
public function __construct(
|
||||||
array $frequency,
|
array $frequency,
|
||||||
int $sequence,
|
int $sequence,
|
||||||
|
@ -51,6 +73,8 @@ class BillingCycle {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns frequency.
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function frequency(): array {
|
public function frequency(): array {
|
||||||
|
@ -58,6 +82,8 @@ class BillingCycle {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns sequence.
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function sequence(): int {
|
public function sequence(): int {
|
||||||
|
@ -65,6 +91,8 @@ class BillingCycle {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns tenure type.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function tenure_type(): string {
|
public function tenure_type(): string {
|
||||||
|
@ -72,6 +100,8 @@ class BillingCycle {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns pricing scheme.
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function pricing_scheme(): array {
|
public function pricing_scheme(): array {
|
||||||
|
@ -79,6 +109,8 @@ class BillingCycle {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Return total cycles.
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function total_cycles(): int {
|
public function total_cycles(): int {
|
||||||
|
|
|
@ -9,27 +9,47 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||||
|
|
||||||
class PaymentPreferences {
|
|
||||||
/**
|
/**
|
||||||
|
* Class PaymentPreferences
|
||||||
|
*/
|
||||||
|
class PaymentPreferences {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup fee.
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $setup_fee;
|
private $setup_fee;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Auto bill outstanding.
|
||||||
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $auto_bill_outstanding;
|
private $auto_bill_outstanding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Setup fee failure action.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $setup_fee_failure_action;
|
private $setup_fee_failure_action;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Payment failure threshold.
|
||||||
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $payment_failure_threshold;
|
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(
|
public function __construct(
|
||||||
array $setup_fee,
|
array $setup_fee,
|
||||||
bool $auto_bill_outstanding = true,
|
bool $auto_bill_outstanding = true,
|
||||||
|
@ -44,6 +64,8 @@ class PaymentPreferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Setup fee.
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function setup_fee(): array {
|
public function setup_fee(): array {
|
||||||
|
@ -51,6 +73,8 @@ class PaymentPreferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Auto bill outstanding.
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function auto_bill_outstanding(): bool {
|
public function auto_bill_outstanding(): bool {
|
||||||
|
@ -58,6 +82,8 @@ class PaymentPreferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Setup fee failure action.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function setup_fee_failure_action(): string {
|
public function setup_fee_failure_action(): string {
|
||||||
|
@ -65,12 +91,19 @@ class PaymentPreferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Payment failure threshold.
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function payment_failure_threshold(): int {
|
public function payment_failure_threshold(): int {
|
||||||
return $this->payment_failure_threshold;
|
return $this->payment_failure_threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns Payment Preferences as array.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function to_array():array {
|
public function to_array():array {
|
||||||
return array(
|
return array(
|
||||||
'setup_fee' => $this->setup_fee(),
|
'setup_fee' => $this->setup_fee(),
|
||||||
|
|
|
@ -9,38 +9,63 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Plan
|
||||||
|
*/
|
||||||
class Plan {
|
class Plan {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Plan ID.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Plan name.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Product ID.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $product_id;
|
private $product_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Billing cycles.
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $billing_cycles;
|
private $billing_cycles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Payment preferences.
|
||||||
|
*
|
||||||
* @var PaymentPreferences
|
* @var PaymentPreferences
|
||||||
*/
|
*/
|
||||||
private $payment_preferences;
|
private $payment_preferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Plan status.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $status;
|
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(
|
public function __construct(
|
||||||
string $id,
|
string $id,
|
||||||
string $name,
|
string $name,
|
||||||
|
@ -58,6 +83,8 @@ class Plan {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns Plan ID.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function id(): string {
|
public function id(): string {
|
||||||
|
@ -65,6 +92,8 @@ class Plan {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns Plan name.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function name(): string {
|
public function name(): string {
|
||||||
|
@ -72,6 +101,8 @@ class Plan {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns Product ID.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function product_id(): string {
|
public function product_id(): string {
|
||||||
|
@ -79,6 +110,8 @@ class Plan {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns Billing cycles.
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function billing_cycles(): array {
|
public function billing_cycles(): array {
|
||||||
|
@ -86,6 +119,8 @@ class Plan {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns Payment preferences.
|
||||||
|
*
|
||||||
* @return PaymentPreferences
|
* @return PaymentPreferences
|
||||||
*/
|
*/
|
||||||
public function payment_preferences(): PaymentPreferences {
|
public function payment_preferences(): PaymentPreferences {
|
||||||
|
@ -93,12 +128,19 @@ class Plan {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns Plan status.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function status(): string {
|
public function status(): string {
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns Plan as array.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function to_array():array {
|
public function to_array():array {
|
||||||
return array(
|
return array(
|
||||||
'id' => $this->id(),
|
'id' => $this->id(),
|
||||||
|
|
|
@ -9,6 +9,9 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Product
|
||||||
|
*/
|
||||||
class Product {
|
class Product {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,6 +36,8 @@ class Product {
|
||||||
private $description;
|
private $description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Product constructor.
|
||||||
|
*
|
||||||
* @param string $id Product ID.
|
* @param string $id Product ID.
|
||||||
* @param string $name Product name.
|
* @param string $name Product name.
|
||||||
* @param string $description Product description.
|
* @param string $description Product description.
|
||||||
|
|
|
@ -13,6 +13,9 @@ use stdClass;
|
||||||
use WC_Product;
|
use WC_Product;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\BillingCycle;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\BillingCycle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BillingCycleFactory
|
||||||
|
*/
|
||||||
class BillingCycleFactory {
|
class BillingCycleFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,9 +26,9 @@ class BillingCycleFactory {
|
||||||
private $currency;
|
private $currency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The currency.
|
* BillingCycleFactory constructor.
|
||||||
*
|
*
|
||||||
* @param string $currency
|
* @param string $currency The currency.
|
||||||
*/
|
*/
|
||||||
public function __construct( string $currency ) {
|
public function __construct( string $currency ) {
|
||||||
$this->currency = $currency;
|
$this->currency = $currency;
|
||||||
|
|
|
@ -13,6 +13,9 @@ use stdClass;
|
||||||
use WC_Product;
|
use WC_Product;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentPreferences;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentPreferences;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PaymentPreferencesFactory
|
||||||
|
*/
|
||||||
class PaymentPreferencesFactory {
|
class PaymentPreferencesFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Plan Factory.
|
||||||
|
*
|
||||||
|
* @package WooCommerce\PayPalCommerce\Webhooks\Handler
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
|
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
|
||||||
|
|
||||||
|
@ -6,17 +13,31 @@ use stdClass;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Plan;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\Plan;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PlanFactory
|
||||||
|
*/
|
||||||
class PlanFactory {
|
class PlanFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Billing cycle factory.
|
||||||
|
*
|
||||||
* @var BillingCycleFactory
|
* @var BillingCycleFactory
|
||||||
*/
|
*/
|
||||||
private $billing_cycle_factory;
|
private $billing_cycle_factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Payment preferences factory.
|
||||||
|
*
|
||||||
* @var PaymentPreferencesFactory
|
* @var PaymentPreferencesFactory
|
||||||
*/
|
*/
|
||||||
private $payment_preferences_factory;
|
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(
|
public function __construct(
|
||||||
BillingCycleFactory $billing_cycle_factory,
|
BillingCycleFactory $billing_cycle_factory,
|
||||||
PaymentPreferencesFactory $payment_preferences_factory
|
PaymentPreferencesFactory $payment_preferences_factory
|
||||||
|
@ -25,6 +46,15 @@ class PlanFactory {
|
||||||
$this->payment_preferences_factory = $payment_preferences_factory;
|
$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 {
|
public function from_paypal_response( stdClass $data ): Plan {
|
||||||
if ( ! isset( $data->id ) ) {
|
if ( ! isset( $data->id ) ) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
|
|
|
@ -13,6 +13,9 @@ use stdClass;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Product;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\Product;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ProductFactory
|
||||||
|
*/
|
||||||
class ProductFactory {
|
class ProductFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -200,7 +200,10 @@ class SmartButton implements SmartButtonInterface {
|
||||||
* @var LoggerInterface
|
* @var LoggerInterface
|
||||||
*/
|
*/
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Session handler.
|
||||||
|
*
|
||||||
* @var SessionHandler
|
* @var SessionHandler
|
||||||
*/
|
*/
|
||||||
private $session_handler;
|
private $session_handler;
|
||||||
|
@ -210,6 +213,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
*
|
*
|
||||||
* @param string $module_url The URL to the module.
|
* @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 Settings $settings The Settings.
|
||||||
* @param PayerFactory $payer_factory The Payer factory.
|
* @param PayerFactory $payer_factory The Payer factory.
|
||||||
* @param string $client_id The client ID.
|
* @param string $client_id The client ID.
|
||||||
|
|
|
@ -176,8 +176,9 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
||||||
* @param string $page_id ID of the current PPCP gateway settings page, or empty if it is not such page.
|
* @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 Environment $environment The environment.
|
||||||
* @param PaymentTokenRepository $payment_token_repository The payment token repository.
|
* @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(
|
public function __construct(
|
||||||
SettingsRenderer $settings_renderer,
|
SettingsRenderer $settings_renderer,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue