mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
Show Venmo in cancellation section
This commit is contained in:
parent
9ef61a2b81
commit
014af02fbc
3 changed files with 45 additions and 7 deletions
|
@ -28,7 +28,10 @@ return array(
|
||||||
return $session_handler;
|
return $session_handler;
|
||||||
},
|
},
|
||||||
'session.cancellation.view' => function ( ContainerInterface $container ) : CancelView {
|
'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 {
|
'session.cancellation.controller' => function ( ContainerInterface $container ) : CancelController {
|
||||||
return new CancelController(
|
return new CancelController(
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CancelController {
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_review_order_after_submit',
|
'woocommerce_review_order_after_submit',
|
||||||
function () use ( $url ) {
|
function () use ( $url ) {
|
||||||
$this->view->render_session_cancellation( $url );
|
$this->view->render_session_cancellation( $url, $this->session_handler->funding_source() );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,31 +9,66 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\Session\Cancellation;
|
namespace WooCommerce\PayPalCommerce\Session\Cancellation;
|
||||||
|
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\FundingSource\FundingSourceRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CancelView
|
* Class CancelView
|
||||||
*/
|
*/
|
||||||
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.
|
* 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 ) {
|
||||||
?>
|
?>
|
||||||
<p id="ppcp-cancel"
|
<p id="ppcp-cancel"
|
||||||
class="has-text-align-center ppcp-cancel"
|
class="has-text-align-center ppcp-cancel"
|
||||||
>
|
>
|
||||||
<?php
|
<?php
|
||||||
|
$name = $funding_source ?
|
||||||
|
$this->funding_source_renderer->render_name( $funding_source )
|
||||||
|
: ( $this->settings->has( 'title' ) ? $this->settings->get( 'title' ) : __( 'PayPal', 'woocommerce-paypal-payments' ) );
|
||||||
printf(
|
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__(
|
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.',
|
this process, please click %1$shere%2$s.',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
),
|
),
|
||||||
'<a href="' . esc_url( $url ) . '">',
|
'<a href="' . esc_url( $url ) . '">',
|
||||||
'</a>'
|
'</a>',
|
||||||
|
esc_html( $name )
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue