Merge branch 'trunk' into PCP-1393-update-to-vault-v-3

# Conflicts:
#	modules/ppcp-api-client/services.php
#	modules/ppcp-wc-gateway/src/Processor/OrderProcessor.php
#	tests/PHPUnit/WcGateway/Processor/OrderProcessorTest.php
This commit is contained in:
Pedro Silva 2023-11-24 11:20:15 +00:00
commit fb1ceeba76
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
27 changed files with 658 additions and 231 deletions

View file

@ -97,7 +97,9 @@ return array(
$payment_token_repository,
$logger,
$api_shop_country,
$container->get( 'api.endpoint.order' )
$container->get( 'api.endpoint.order' ),
$container->get( 'api.factory.paypal-checkout-url' ),
$container->get( 'wcgateway.place-order-button-text' )
);
},
'wcgateway.credit-card-gateway' => static function ( ContainerInterface $container ): CreditCardGateway {
@ -141,7 +143,9 @@ return array(
$container->get( 'wcgateway.settings.allow_card_button_gateway.default' ),
$container->get( 'onboarding.environment' ),
$container->get( 'vaulting.repository.payment-token' ),
$container->get( 'woocommerce.logger.woocommerce' )
$container->get( 'woocommerce.logger.woocommerce' ),
$container->get( 'api.factory.paypal-checkout-url' ),
$container->get( 'wcgateway.place-order-button-text' )
);
},
'wcgateway.disabler' => static function ( ContainerInterface $container ): DisableGateways {
@ -209,7 +213,9 @@ return array(
static function ( ContainerInterface $container ): Settings {
return new Settings(
$container->get( 'wcgateway.button.default-locations' ),
$container->get( 'wcgateway.settings.dcc-gateway-title.default' )
$container->get( 'wcgateway.settings.dcc-gateway-title.default' ),
$container->get( 'wcgateway.settings.pay-later.default-button-locations' ),
$container->get( 'wcgateway.settings.pay-later.default-messaging-locations' )
);
}
),
@ -350,7 +356,10 @@ return array(
$logger,
$environment,
$subscription_helper,
$order_helper
$order_helper,
$container->get( 'api.factory.purchase-unit' ),
$container->get( 'api.factory.payer' ),
$container->get( 'api.factory.shipping-preference' )
);
},
'wcgateway.processor.refunds' => static function ( ContainerInterface $container ): RefundProcessor {
@ -1156,6 +1165,25 @@ return array(
);
},
'wcgateway.use-place-order-button' => function ( ContainerInterface $container ) : bool {
/**
* Whether to use the standard "Place order" button with redirect to PayPal instead of the PayPal smart buttons.
*/
return apply_filters(
'woocommerce_paypal_payments_use_place_order_button',
false
);
},
'wcgateway.place-order-button-text' => function ( ContainerInterface $container ) : string {
/**
* The text for the standard "Place order" button, when the "Place order" button mode is enabled.
*/
return apply_filters(
'woocommerce_paypal_payments_place_order_button_text',
__( 'Pay with PayPal', 'woocommerce-paypal-payments' )
);
},
'wcgateway.helper.vaulting-scope' => static function ( ContainerInterface $container ): bool {
try {
$token = $container->get( 'api.bearer' )->bearer();
@ -1360,6 +1388,11 @@ return array(
'mini-cart' => 'Mini Cart',
);
},
'wcgateway.button.default-locations' => static function( ContainerInterface $container ): array {
$button_locations = $container->get( 'wcgateway.button.locations' );
unset( $button_locations['mini-cart'] );
return array_keys( $button_locations );
},
'wcgateway.settings.pay-later.messaging-locations' => static function( ContainerInterface $container ): array {
$button_locations = $container->get( 'wcgateway.button.locations' );
unset( $button_locations['mini-cart'] );
@ -1371,8 +1404,10 @@ return array(
)
);
},
'wcgateway.button.default-locations' => static function( ContainerInterface $container ): array {
return array_keys( $container->get( 'wcgateway.settings.pay-later.messaging-locations' ) );
'wcgateway.settings.pay-later.default-messaging-locations' => static function( ContainerInterface $container ): array {
$locations = $container->get( 'wcgateway.settings.pay-later.messaging-locations' );
unset( $locations['home'] );
return array_keys( $locations );
},
'wcgateway.settings.pay-later.button-locations' => static function( ContainerInterface $container ): array {
$settings = $container->get( 'wcgateway.settings' );
@ -1384,6 +1419,9 @@ return array(
return array_intersect_key( $button_locations, array_flip( $smart_button_selected_locations ) );
},
'wcgateway.settings.pay-later.default-button-locations' => static function( ContainerInterface $container ): array {
return $container->get( 'wcgateway.button.default-locations' );
},
'wcgateway.ppcp-gateways' => static function ( ContainerInterface $container ): array {
return array(
PayPalGateway::ID,