mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
🔀 Merge branch 'trunk'
This commit is contained in:
commit
1a6ddbba2b
5 changed files with 96 additions and 7 deletions
|
@ -44,7 +44,13 @@ return array(
|
|||
'woocommerce-paypal-payments'
|
||||
);
|
||||
|
||||
if ( wc_terms_and_conditions_page_id() > 0 ) {
|
||||
/**
|
||||
* Replace wc_terms_and_conditions_page_id() function to avoid errors when to avoid errors because of early loading.
|
||||
*/
|
||||
$wc_terms_and_conditions_page_id = apply_filters( 'woocommerce_get_terms_page_id', get_option( 'woocommerce_terms_page_id' ) );
|
||||
$wc_terms_and_conditions_page_id = apply_filters( 'woocommerce_terms_and_conditions_page_id', 0 < $wc_terms_and_conditions_page_id ? absint( $wc_terms_and_conditions_page_id ) : 0 );
|
||||
|
||||
if ( $wc_terms_and_conditions_page_id > 0 ) {
|
||||
$label .= __(
|
||||
'<div class="ppcp-notice ppcp-notice-warning"><p><span class="highlight">Important:</span> Your store has a <a href="/wp-admin/admin.php?page=wc-settings&tab=advanced" target="_blank">Terms and Conditions</a> page configured. Buyers who use a PayPal express payment method will not be able to consent to the terms on the <code>Classic Checkout</code>, as the final checkout confirmation will be skipped.</p></div>',
|
||||
'woocommerce-paypal-payments'
|
||||
|
|
|
@ -157,12 +157,13 @@ export const usePaymentMethodsModal = () => {
|
|||
|
||||
export const usePaymentMethodsPayPalCheckout = () => {
|
||||
const { paypal, venmo, payLater, creditCard } = useHooks();
|
||||
|
||||
const paymentMethodsPayPalCheckout = [
|
||||
paypal,
|
||||
venmo,
|
||||
payLater,
|
||||
creditCard,
|
||||
];
|
||||
].filter( ( item ) => Object.keys( item ).length !== 0 );
|
||||
|
||||
return { paymentMethodsPayPalCheckout };
|
||||
};
|
||||
|
@ -174,7 +175,7 @@ export const usePaymentMethodsOnlineCardPayments = () => {
|
|||
fastlane,
|
||||
applePay,
|
||||
googlePay,
|
||||
];
|
||||
].filter( ( item ) => Object.keys( item ).length !== 0 );
|
||||
|
||||
return { paymentMethodsOnlineCardPayments };
|
||||
};
|
||||
|
@ -204,7 +205,7 @@ export const usePaymentMethodsAlternative = () => {
|
|||
multibanco,
|
||||
pui,
|
||||
oxxo,
|
||||
];
|
||||
].filter( ( item ) => Object.keys( item ).length !== 0 );
|
||||
|
||||
return { paymentMethodsAlternative };
|
||||
};
|
||||
|
|
|
@ -687,7 +687,7 @@ class PaymentRestEndpoint extends RestEndpoint {
|
|||
$gateway_settings['fastlaneCardholderName'] = $this->settings->get_fastlane_cardholder_name();
|
||||
$gateway_settings['fastlaneDisplayWatermark'] = $this->settings->get_fastlane_display_watermark();
|
||||
|
||||
return $this->return_success( $gateway_settings );
|
||||
return $this->return_success( apply_filters( 'woocommerce_paypal_payments_payment_methods', $gateway_settings ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,17 @@ declare( strict_types = 1 );
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\Settings;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
||||
use WooCommerce\PayPalCommerce\Applepay\Assets\AppleProductStatus;
|
||||
use WooCommerce\PayPalCommerce\Googlepay\Helper\ApmProductStatus;
|
||||
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\BancontactGateway;
|
||||
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\BlikGateway;
|
||||
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\EPSGateway;
|
||||
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\IDealGateway;
|
||||
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\MultibancoGateway;
|
||||
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\MyBankGateway;
|
||||
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\P24Gateway;
|
||||
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\TrustlyGateway;
|
||||
use WooCommerce\PayPalCommerce\Settings\Ajax\SwitchSettingsUiEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Settings\Data\OnboardingProfile;
|
||||
use WooCommerce\PayPalCommerce\Settings\Endpoint\RestEndpoint;
|
||||
|
@ -17,6 +28,11 @@ use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule
|
|||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\OXXO\OXXO;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PayUponInvoiceGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\DCCProductStatus;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
/**
|
||||
|
@ -263,6 +279,69 @@ class SettingsModule implements ServiceModule, ExecutableModule {
|
|||
}
|
||||
);
|
||||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_payment_methods',
|
||||
function( array $payment_methods ) use ( $container ) : array {
|
||||
$all_payment_methods = $payment_methods;
|
||||
|
||||
$dcc_product_status = $container->get( 'wcgateway.helper.dcc-product-status' );
|
||||
assert( $dcc_product_status instanceof DCCProductStatus );
|
||||
|
||||
$googlepay_product_status = $container->get( 'googlepay.helpers.apm-product-status' );
|
||||
assert( $googlepay_product_status instanceof ApmProductStatus );
|
||||
|
||||
$applepay_product_status = $container->get( 'applepay.apple-product-status' );
|
||||
assert( $applepay_product_status instanceof AppleProductStatus );
|
||||
|
||||
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
||||
assert( $dcc_applies instanceof DCCApplies );
|
||||
|
||||
// Unset BCDC if merchant is eligible for ACDC.
|
||||
if ( $dcc_product_status->dcc_is_active() && ! $container->get( 'wcgateway.settings.allow_card_button_gateway' ) ) {
|
||||
unset( $payment_methods[ CardButtonGateway::ID ] );
|
||||
}
|
||||
|
||||
// Unset Venmo when store location is not United States.
|
||||
if ( $container->get( 'api.shop.country' ) !== 'US' ) {
|
||||
unset( $payment_methods['venmo'] );
|
||||
}
|
||||
|
||||
// Unset if not eligible for Google Pay.
|
||||
if ( ! $googlepay_product_status->is_active() ) {
|
||||
unset( $payment_methods['ppcp-googlepay'] );
|
||||
}
|
||||
|
||||
// Unset if not eligible for Apple Pay.
|
||||
if ( ! $applepay_product_status->is_active() ) {
|
||||
unset( $payment_methods['ppcp-applepay'] );
|
||||
}
|
||||
|
||||
// Unset Fastlane if store location is not United States or merchant is not eligible for ACDC.
|
||||
if ( $container->get( 'api.shop.country' ) !== 'US' || ! $dcc_product_status->dcc_is_active() ) {
|
||||
unset( $payment_methods['ppcp-axo-gateway'] );
|
||||
}
|
||||
|
||||
// For non-ACDC regions unset ACDC, local APMs and set BCDC.
|
||||
if ( ! $dcc_applies ) {
|
||||
unset( $payment_methods[ CreditCardGateway::ID ] );
|
||||
unset( $payment_methods[ BancontactGateway::ID ] );
|
||||
unset( $payment_methods[ BlikGateway::ID ] );
|
||||
unset( $payment_methods[ EPSGateway::ID ] );
|
||||
unset( $payment_methods[ IDealGateway::ID ] );
|
||||
unset( $payment_methods[ MyBankGateway::ID ] );
|
||||
unset( $payment_methods[ P24Gateway::ID ] );
|
||||
unset( $payment_methods[ TrustlyGateway::ID ] );
|
||||
unset( $payment_methods[ MultibancoGateway::ID ] );
|
||||
unset( $payment_methods[ PayUponInvoiceGateway::ID ] );
|
||||
unset( $payment_methods[ OXXO::ID ] );
|
||||
|
||||
$payment_methods[ CardButtonGateway::ID ] = $all_payment_methods[ CardButtonGateway::ID ];
|
||||
}
|
||||
|
||||
return $payment_methods;
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1659,9 +1659,12 @@ return array(
|
|||
$settings = $container->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof ContainerInterface );
|
||||
|
||||
return $settings->has( 'allow_card_button_gateway' ) ?
|
||||
return apply_filters(
|
||||
'woocommerce_paypal_payments_enable_standard_card_button_gateway_settings',
|
||||
$settings->has( 'allow_card_button_gateway' ) ?
|
||||
(bool) $settings->get( 'allow_card_button_gateway' ) :
|
||||
$container->get( 'wcgateway.settings.allow_card_button_gateway.default' );
|
||||
$container->get( 'wcgateway.settings.allow_card_button_gateway.default' )
|
||||
);
|
||||
},
|
||||
'wcgateway.settings.has_enabled_separate_button_gateways' => static function ( ContainerInterface $container ): bool {
|
||||
return (bool) $container->get( 'wcgateway.settings.allow_card_button_gateway' );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue