-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2620 from woocommerce/PCP-3680-simplify-fastlane-…
…settings Fastlane: Remove Gateway Title, and move Cardholder Name to Advanced Card Processing (3680)
- Loading branch information
Showing
9 changed files
with
150 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
modules/ppcp-wc-gateway/src/Helper/DCCGatewayConfiguration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/** | ||
* Encapsulates all configuration details for "Credit & Debit Card" gateway. | ||
* | ||
* @package WooCommerce\PayPalCommerce\WcGateway\Helper | ||
*/ | ||
|
||
declare( strict_types = 1 ); | ||
|
||
namespace WooCommerce\PayPalCommerce\WcGateway\Helper; | ||
|
||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; | ||
use WooCommerce\PayPalCommerce\Axo\Helper\PropertiesDictionary; | ||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException; | ||
|
||
/** | ||
* A simple DTO that provides convenient access to the DCC/AXO gateway settings. | ||
* | ||
* This class should not implement business logic, but only provide a convenient | ||
* way to access gateway settings by wrapping the Settings instance. | ||
*/ | ||
class DCCGatewayConfiguration { | ||
/** | ||
* Gateway title. | ||
* | ||
* @var string | ||
*/ | ||
private string $gateway_title; | ||
|
||
/** | ||
* Whether to display the cardholder's name on the payment form. | ||
* | ||
* @var string | ||
*/ | ||
private string $show_name_on_card; | ||
|
||
/** | ||
* Initializes the gateway details based on the provided Settings instance. | ||
* | ||
* @throws NotFoundException If an expected gateway setting is not found. | ||
* | ||
* @param Settings $settings Plugin settings instance. | ||
*/ | ||
public function __construct( Settings $settings ) { | ||
$this->gateway_title = $settings->has( 'dcc_gateway_title' ) ? | ||
$settings->get( 'dcc_gateway_title' ) : ''; | ||
|
||
$show_on_card = ''; | ||
if ( $settings->has( 'dcc_name_on_card' ) ) { | ||
$show_on_card = $settings->get( 'dcc_name_on_card' ); | ||
} elseif ( $settings->has( 'axo_name_on_card' ) ) { | ||
// Legacy. The AXO gateway setting was replaced by the DCC setting. | ||
$show_on_card = $settings->get( 'axo_name_on_card' ); | ||
} | ||
$valid_options = array_keys( PropertiesDictionary::cardholder_name_options() ); | ||
|
||
$this->show_name_on_card = in_array( $show_on_card, $valid_options, true ) | ||
? $show_on_card | ||
: $valid_options[0]; | ||
} | ||
|
||
/** | ||
* User facing title of the gateway. | ||
* | ||
* @return string Display title of the gateway. | ||
*/ | ||
public function gateway_title() : string { | ||
return $this->gateway_title ?: __( 'Advanced Card Processing', 'woocommerce-paypal-payments' ); | ||
} | ||
|
||
/** | ||
* Whether to show a field for the cardholder's name in the payment form. | ||
* | ||
* @return string [yes|no] | ||
*/ | ||
public function show_name_on_card() : string { | ||
return $this->show_name_on_card; | ||
} | ||
} |
Oops, something went wrong.