mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
fix code style in the TransactionUrlProvider
This commit is contained in:
parent
14ea92a0c3
commit
60e392c78f
1 changed files with 44 additions and 43 deletions
|
@ -1,4 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* Service able to provide transaction url base (URL with the placeholder instead of an actual transaction id)
|
||||
* based on the given WC Order.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\WcGateway\Gateway
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
@ -6,53 +12,48 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Gateway;
|
|||
|
||||
/**
|
||||
* Class TransactionUrlProvider
|
||||
*
|
||||
* Service able to provide transaction url base (URL with the placeholder instead of an actual transaction id)
|
||||
* based on the given WC Order.
|
||||
*/
|
||||
class TransactionUrlProvider
|
||||
{
|
||||
/**
|
||||
* Transaction URL base used for sandbox payments.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $transaction_url_base_sandbox;
|
||||
class TransactionUrlProvider {
|
||||
|
||||
/**
|
||||
* Transaction URL base used for live payments.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $transaction_url_base_live;
|
||||
/**
|
||||
* Transaction URL base used for sandbox payments.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $transaction_url_base_sandbox;
|
||||
|
||||
/**
|
||||
* TransactionUrlProvider constructor.
|
||||
*
|
||||
* @param string $transaction_url_base_sandbox URL for sandbox orders.
|
||||
* @param string $transaction_url_base_live URL for live orders.
|
||||
*/
|
||||
public function __construct(
|
||||
string $transaction_url_base_sandbox,
|
||||
string $transaction_url_base_live
|
||||
)
|
||||
{
|
||||
/**
|
||||
* Transaction URL base used for live payments.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $transaction_url_base_live;
|
||||
|
||||
$this->transaction_url_base_sandbox = $transaction_url_base_sandbox;
|
||||
$this->transaction_url_base_live = $transaction_url_base_live;
|
||||
}
|
||||
/**
|
||||
* TransactionUrlProvider constructor.
|
||||
*
|
||||
* @param string $transaction_url_base_sandbox URL for sandbox orders.
|
||||
* @param string $transaction_url_base_live URL for live orders.
|
||||
*/
|
||||
public function __construct(
|
||||
string $transaction_url_base_sandbox,
|
||||
string $transaction_url_base_live
|
||||
) {
|
||||
|
||||
/**
|
||||
* Return transaction url base
|
||||
*
|
||||
* @param \WC_Order $order
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_transaction_url_base(\WC_Order $order): string
|
||||
{
|
||||
$order_payment_mode = $order->get_meta(PayPalGateway::ORDER_PAYMENT_MODE_META_KEY, true);
|
||||
$this->transaction_url_base_sandbox = $transaction_url_base_sandbox;
|
||||
$this->transaction_url_base_live = $transaction_url_base_live;
|
||||
}
|
||||
|
||||
return $order_payment_mode === 'sandbox' ? $this->transaction_url_base_sandbox : $this->transaction_url_base_live;
|
||||
}
|
||||
/**
|
||||
* Return transaction url base
|
||||
*
|
||||
* @param \WC_Order $order WC order to get payment type from.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_transaction_url_base( \WC_Order $order ): string {
|
||||
$order_payment_mode = $order->get_meta( PayPalGateway::ORDER_PAYMENT_MODE_META_KEY, true );
|
||||
|
||||
return 'sandbox' === $order_payment_mode ? $this->transaction_url_base_sandbox : $this->transaction_url_base_live;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue