diff --git a/modules/ppcp-session/services.php b/modules/ppcp-session/services.php index b83a1a6a5..b5d76e82b 100644 --- a/modules/ppcp-session/services.php +++ b/modules/ppcp-session/services.php @@ -28,7 +28,10 @@ return array( return $session_handler; }, 'session.cancellation.view' => function ( ContainerInterface $container ) : CancelView { - return new CancelView(); + return new CancelView( + $container->get( 'wcgateway.settings' ), + $container->get( 'wcgateway.funding-source.renderer' ) + ); }, 'session.cancellation.controller' => function ( ContainerInterface $container ) : CancelController { return new CancelController( diff --git a/modules/ppcp-session/src/Cancellation/CancelController.php b/modules/ppcp-session/src/Cancellation/CancelController.php index 6de8a2262..54eb13cb2 100644 --- a/modules/ppcp-session/src/Cancellation/CancelController.php +++ b/modules/ppcp-session/src/Cancellation/CancelController.php @@ -67,7 +67,7 @@ class CancelController { add_action( 'woocommerce_review_order_after_submit', function () use ( $url ) { - $this->view->render_session_cancellation( $url ); + $this->view->render_session_cancellation( $url, $this->session_handler->funding_source() ); } ); } diff --git a/modules/ppcp-session/src/Cancellation/CancelView.php b/modules/ppcp-session/src/Cancellation/CancelView.php index 2c4e1356b..4727e6b0e 100644 --- a/modules/ppcp-session/src/Cancellation/CancelView.php +++ b/modules/ppcp-session/src/Cancellation/CancelView.php @@ -9,31 +9,66 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\Session\Cancellation; +use Psr\Container\ContainerInterface; +use WooCommerce\PayPalCommerce\WcGateway\FundingSource\FundingSourceRenderer; + /** * Class CancelView */ class CancelView { + /** + * The settings. + * + * @var ContainerInterface + */ + protected $settings; + + /** + * The funding source renderer. + * + * @var FundingSourceRenderer + */ + protected $funding_source_renderer; + + /** + * CancelView constructor. + * + * @param ContainerInterface $settings The settings. + * @param FundingSourceRenderer $funding_source_renderer The funding source renderer. + */ + public function __construct( + ContainerInterface $settings, + FundingSourceRenderer $funding_source_renderer + ) { + $this->settings = $settings; + $this->funding_source_renderer = $funding_source_renderer; + } /** * Renders the cancel link. * - * @param string $url The URL. + * @param string $url The URL. + * @param string|null $funding_source The ID of the funding source, such as 'venmo'. */ - public function render_session_cancellation( string $url ) { + public function render_session_cancellation( string $url, ?string $funding_source ) { ?>
funding_source_renderer->render_name( $funding_source ) + : ( $this->settings->has( 'title' ) ? $this->settings->get( 'title' ) : __( 'PayPal', 'woocommerce-paypal-payments' ) ); printf( - // translators: the placeholders are html tags for a link. + // translators: %3$ is funding source like "PayPal" or "Venmo", other placeholders are html tags for a link. esc_html__( - 'You are currently paying with PayPal. If you want to cancel + 'You are currently paying with %3$s. If you want to cancel this process, please click %1$shere%2$s.', 'woocommerce-paypal-payments' ), '', - '' + '', + esc_html( $name ) ); ?>