Fix pay later enabling

It should be enabled only when enabled on the Pay Later tab, also we disabling we can use `paylater` instead of `credit`
This commit is contained in:
Alex P 2023-02-27 12:02:47 +02:00
parent 68b13a480b
commit d35fdea592
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -972,19 +972,20 @@ class SmartButton implements SmartButtonInterface {
$disable_funding = $all_sources;
}
if ( ! $this->settings_status->is_pay_later_button_enabled_for_location( $this->context() ) ) {
$disable_funding[] = 'credit';
$enable_funding = array( 'venmo' );
if ( $this->settings_status->is_pay_later_button_enabled_for_location( $this->context() ) ||
$this->settings_status->is_pay_later_messaging_enabled_for_location( $this->context() )
) {
$enable_funding[] = 'paylater';
} else {
$disable_funding[] = 'paylater';
}
if ( count( $disable_funding ) > 0 ) {
$params['disable-funding'] = implode( ',', array_unique( $disable_funding ) );
}
$enable_funding = array( 'venmo' );
if ( $this->settings_status->is_pay_later_messaging_enabled_for_location( $this->context() ) || ! in_array( 'credit', $disable_funding, true ) ) {
$enable_funding[] = 'paylater';
}
if ( $this->is_free_trial_cart() ) {
$enable_funding = array();
}