mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Add soft descriptor to PurchaseUnitFactory PCP-1709
This commit is contained in:
parent
71f669070d
commit
f812d043af
3 changed files with 21 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 {
|
||||
|
|
|
@ -68,6 +68,13 @@ class PurchaseUnitFactory {
|
|||
*/
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* The Soft Descriptor.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $soft_descriptor;
|
||||
|
||||
/**
|
||||
* PurchaseUnitFactory constructor.
|
||||
*
|
||||
|
@ -78,6 +85,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,
|
||||
|
@ -86,7 +94,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;
|
||||
|
@ -96,6 +105,7 @@ class PurchaseUnitFactory {
|
|||
$this->shipping_factory = $shipping_factory;
|
||||
$this->payments_factory = $payments_factory;
|
||||
$this->prefix = $prefix;
|
||||
$this->soft_descriptor = $soft_descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +136,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,
|
||||
|
@ -189,7 +199,7 @@ class PurchaseUnitFactory {
|
|||
|
||||
$custom_id = '';
|
||||
$invoice_id = '';
|
||||
$soft_descriptor = '';
|
||||
$soft_descriptor = $this->soft_descriptor;
|
||||
$purchase_unit = new PurchaseUnit(
|
||||
$amount,
|
||||
$items,
|
||||
|
@ -224,7 +234,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(
|
||||
|
|
|
@ -955,6 +955,10 @@ return array(
|
|||
return 'https://www.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=%s';
|
||||
},
|
||||
|
||||
'wcgateway.soft-descriptor' => static function ( ContainerInterface $container ): string {
|
||||
return 'soft descriptor test';
|
||||
},
|
||||
|
||||
'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' );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue