mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Merge pull request #1427 from woocommerce/feat/PCP-1709_soft_descriptor
Include soft descriptor for card's activity
This commit is contained in:
commit
75f73ea090
4 changed files with 40 additions and 5 deletions
|
@ -298,6 +298,7 @@ return array(
|
|||
$shipping_factory = $container->get( 'api.factory.shipping' );
|
||||
$payments_factory = $container->get( 'api.factory.payments' );
|
||||
$prefix = $container->get( 'api.prefix' );
|
||||
$soft_descriptor = $container->get( 'wcgateway.soft-descriptor' );
|
||||
|
||||
return new PurchaseUnitFactory(
|
||||
$amount_factory,
|
||||
|
@ -306,7 +307,8 @@ return array(
|
|||
$item_factory,
|
||||
$shipping_factory,
|
||||
$payments_factory,
|
||||
$prefix
|
||||
$prefix,
|
||||
$soft_descriptor
|
||||
);
|
||||
},
|
||||
'api.factory.patch-collection-factory' => static function ( ContainerInterface $container ): PatchCollectionFactory {
|
||||
|
|
|
@ -70,6 +70,13 @@ class PurchaseUnitFactory {
|
|||
*/
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* The Soft Descriptor.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $soft_descriptor;
|
||||
|
||||
/**
|
||||
* PurchaseUnitFactory constructor.
|
||||
*
|
||||
|
@ -80,6 +87,7 @@ class PurchaseUnitFactory {
|
|||
* @param ShippingFactory $shipping_factory The shipping factory.
|
||||
* @param PaymentsFactory $payments_factory The payments factory.
|
||||
* @param string $prefix The prefix.
|
||||
* @param string $soft_descriptor The soft descriptor.
|
||||
*/
|
||||
public function __construct(
|
||||
AmountFactory $amount_factory,
|
||||
|
@ -88,7 +96,8 @@ class PurchaseUnitFactory {
|
|||
ItemFactory $item_factory,
|
||||
ShippingFactory $shipping_factory,
|
||||
PaymentsFactory $payments_factory,
|
||||
string $prefix = 'WC-'
|
||||
string $prefix = 'WC-',
|
||||
string $soft_descriptor = ''
|
||||
) {
|
||||
|
||||
$this->amount_factory = $amount_factory;
|
||||
|
@ -98,6 +107,7 @@ class PurchaseUnitFactory {
|
|||
$this->shipping_factory = $shipping_factory;
|
||||
$this->payments_factory = $payments_factory;
|
||||
$this->prefix = $prefix;
|
||||
$this->soft_descriptor = $soft_descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,7 +138,7 @@ class PurchaseUnitFactory {
|
|||
$payee = $this->payee_repository->payee();
|
||||
$custom_id = (string) $order->get_id();
|
||||
$invoice_id = $this->prefix . $order->get_order_number();
|
||||
$soft_descriptor = '';
|
||||
$soft_descriptor = $this->soft_descriptor;
|
||||
|
||||
$purchase_unit = new PurchaseUnit(
|
||||
$amount,
|
||||
|
@ -198,7 +208,7 @@ class PurchaseUnitFactory {
|
|||
}
|
||||
}
|
||||
$invoice_id = '';
|
||||
$soft_descriptor = '';
|
||||
$soft_descriptor = $this->soft_descriptor;
|
||||
$purchase_unit = new PurchaseUnit(
|
||||
$amount,
|
||||
$items,
|
||||
|
@ -233,7 +243,7 @@ class PurchaseUnitFactory {
|
|||
$description = ( isset( $data->description ) ) ? $data->description : '';
|
||||
$custom_id = ( isset( $data->custom_id ) ) ? $data->custom_id : '';
|
||||
$invoice_id = ( isset( $data->invoice_id ) ) ? $data->invoice_id : '';
|
||||
$soft_descriptor = ( isset( $data->soft_descriptor ) ) ? $data->soft_descriptor : '';
|
||||
$soft_descriptor = ( isset( $data->soft_descriptor ) ) ? $data->soft_descriptor : $this->soft_descriptor;
|
||||
$items = array();
|
||||
if ( isset( $data->items ) && is_array( $data->items ) ) {
|
||||
$items = array_map(
|
||||
|
|
|
@ -971,6 +971,15 @@ return array(
|
|||
return 'https://www.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=%s';
|
||||
},
|
||||
|
||||
'wcgateway.soft-descriptor' => static function ( ContainerInterface $container ): string {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
if ( $settings->has( 'soft_descriptor' ) ) {
|
||||
return $settings->get( 'soft_descriptor' );
|
||||
}
|
||||
return '';
|
||||
},
|
||||
|
||||
'wcgateway.transaction-url-provider' => static function ( ContainerInterface $container ): TransactionUrlProvider {
|
||||
$sandbox_url_base = $container->get( 'wcgateway.transaction-url-sandbox' );
|
||||
$live_url_base = $container->get( 'wcgateway.transaction-url-live' );
|
||||
|
|
|
@ -423,6 +423,20 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'</a>'
|
||||
),
|
||||
),
|
||||
'soft_descriptor' => array(
|
||||
'title' => __( 'Soft Descriptor', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'The soft descriptor is the dynamic text used to construct the statement descriptor that appears on a payer\'s card statement. Text field, max value of 22 characters.', 'woocommerce-paypal-payments' ),
|
||||
'maxlength' => 22,
|
||||
'default' => '',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => Settings::CONNECTION_TAB_ID,
|
||||
),
|
||||
'prefix' => array(
|
||||
'title' => __( 'Invoice prefix', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'text',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue