mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
Merge pull request #882 from woocommerce/PCP-688-rc1-add-functionality-to-choose-subscription-failure-behavior
Revert vault failed value
This commit is contained in:
commit
7ffbb5e159
2 changed files with 9 additions and 26 deletions
|
@ -144,9 +144,12 @@ class PaymentTokenChecker {
|
|||
try {
|
||||
$subscription_behavior_when_fails = $this->settings->get( 'subscription_behavior_when_vault_fails' );
|
||||
} catch ( NotFoundException $exception ) {
|
||||
return;
|
||||
$subscription_behavior_when_fails = 'void_auth';
|
||||
}
|
||||
|
||||
$wc_order->update_meta_data( self::VAULTING_FAILED_META_KEY, $subscription_behavior_when_fails );
|
||||
$wc_order->save_meta_data();
|
||||
|
||||
switch ( $subscription_behavior_when_fails ) {
|
||||
case 'void_auth':
|
||||
$order = $this->order_repository->for_wc_order( $wc_order );
|
||||
|
|
|
@ -182,25 +182,15 @@ class VaultingModule implements ModuleInterface {
|
|||
*/
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
|
||||
/**
|
||||
* The Gateway settings.
|
||||
*
|
||||
* @var Settings $settings
|
||||
*/
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
|
||||
$vault_failed = get_post_meta( $order->get_id(), PaymentTokenChecker::VAULTING_FAILED_META_KEY );
|
||||
$vault_failed = $order->get_meta( PaymentTokenChecker::VAULTING_FAILED_META_KEY );
|
||||
if ( $subscription_helper->has_subscription( $order->get_id() ) && ! empty( $vault_failed ) ) {
|
||||
$subscription_behavior_when_vault_fails_setting_name = 'subscription_behavior_when_vault_fails';
|
||||
$subscription_behavior_when_vault_fails = $settings->get( $subscription_behavior_when_vault_fails_setting_name );
|
||||
|
||||
$logger->info( "Adding vaulting failure info to email for order #{$order->get_id()}." );
|
||||
|
||||
if ( $subscription_behavior_when_vault_fails === 'void_auth' ) {
|
||||
if ( $vault_failed === 'void_auth' ) {
|
||||
echo wp_kses_post( '<p>' . __( 'The subscription payment failed because the payment method could not be saved. Please try again with a different payment method.', 'woocommerce-paypal-payments' ) . '</p>' );
|
||||
}
|
||||
|
||||
if ( $subscription_behavior_when_vault_fails === 'capture_auth' ) {
|
||||
if ( $vault_failed === 'capture_auth' ) {
|
||||
echo wp_kses_post( '<p>' . __( 'The subscription has been activated, but the payment method could not be saved. Please contact the merchant to save a payment method for automatic subscription renewal payments.', 'woocommerce-paypal-payments' ) . '</p>' );
|
||||
}
|
||||
}
|
||||
|
@ -224,21 +214,11 @@ class VaultingModule implements ModuleInterface {
|
|||
*/
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
|
||||
/**
|
||||
* The Gateway settings.
|
||||
*
|
||||
* @var Settings $settings
|
||||
*/
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
|
||||
$vault_failed = get_post_meta( $order->get_id(), PaymentTokenChecker::VAULTING_FAILED_META_KEY );
|
||||
$vault_failed = $order->get_meta( PaymentTokenChecker::VAULTING_FAILED_META_KEY );
|
||||
if ( $subscription_helper->has_subscription( $order->get_id() ) && ! empty( $vault_failed ) ) {
|
||||
$subscription_behavior_when_vault_fails_setting_name = 'subscription_behavior_when_vault_fails';
|
||||
$subscription_behavior_when_vault_fails = $settings->get( $subscription_behavior_when_vault_fails_setting_name );
|
||||
|
||||
$logger->info( "Changing subscription auto-renewal status for order #{$order->get_id()}." );
|
||||
|
||||
if ( $subscription_behavior_when_vault_fails === 'capture_auth' ) {
|
||||
if ( $vault_failed === 'capture_auth' ) {
|
||||
$subscriptions = function_exists( 'wcs_get_subscriptions_for_order' ) ? wcs_get_subscriptions_for_order( $order->get_id() ) : array();
|
||||
foreach ( $subscriptions as $subscription ) {
|
||||
$subscription->set_requires_manual_renewal( true );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue