mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Merge branch 'PCP-905-tracking-integration-hooks' into PCP-905-tracking-integration-compatibility-with-third-party-plugins
This commit is contained in:
commit
1aa1cebba9
23 changed files with 430 additions and 136 deletions
|
@ -5,3 +5,6 @@ if (!defined('EP_PAGES')) {
|
|||
if (!defined('MONTH_IN_SECONDS')) {
|
||||
define('MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS);
|
||||
}
|
||||
if (!defined('HOUR_IN_SECONDS')) {
|
||||
define('HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
*** Changelog ***
|
||||
|
||||
= 1.9.4 - TBD =
|
||||
* Add - Create new connection tab #801
|
||||
* Add - Functionality to choose subscription failure behavior #728
|
||||
* Fix - Virtual-only orders always move order status to completed #868
|
||||
* Fix - PayPal order created twice when context is checkout #832
|
||||
* Enhancement - Handle unsupported browsers better #843
|
||||
* Enhancement - Combine the Webhooks Status page into a new Connection tab (891) #827
|
||||
* Enhancement - Hide PayPal Card Processing tab if not available in country or for merchant #870
|
||||
* Enhancement - Resubscribe webhooks on plugin upgrades #838
|
||||
* Enhancement - PUI-relevant webhook not subscribed to #842
|
||||
* Enhancement - Remove WC logo during onboarding #881
|
||||
|
||||
= 1.9.3 - 2022-08-31 =
|
||||
* Add - Tracking API #792
|
||||
* Fix - Improve compatibility with Siteground Optimizer plugin #797
|
||||
|
|
|
@ -79,7 +79,6 @@ class PartnerReferralsData {
|
|||
'ppcp_partner_referrals_data',
|
||||
array(
|
||||
'partner_config_override' => array(
|
||||
'partner_logo_url' => 'https://connect.woocommerce.com/images/woocommerce_logo.png',
|
||||
/**
|
||||
* Returns the URL which will be opened at the end of onboarding.
|
||||
*/
|
||||
|
|
|
@ -311,6 +311,13 @@ document.addEventListener(
|
|||
]
|
||||
);
|
||||
|
||||
groupToggle(
|
||||
'#ppcp-vault_enabled',
|
||||
[
|
||||
'#field-subscription_behavior_when_vault_fails',
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
groupToggleSelect(
|
||||
'#ppcp-intent',
|
||||
|
|
2
modules/ppcp-order-tracking/.gitignore
vendored
2
modules/ppcp-order-tracking/.gitignore
vendored
|
@ -1,2 +1,2 @@
|
|||
node_modules
|
||||
/assets
|
||||
assets
|
||||
|
|
|
@ -117,7 +117,7 @@ class OrderTrackingEndpoint {
|
|||
$url = trailingslashit( $this->host ) . 'v1/shipping/trackers-batch';
|
||||
|
||||
$body = array(
|
||||
'trackers' => array( $data ),
|
||||
'trackers' => array( (array) apply_filters( 'woocommerce_paypal_payments_tracking_data_before_sending', $data, $order_id ) ),
|
||||
);
|
||||
|
||||
$args = array(
|
||||
|
@ -125,6 +125,9 @@ class OrderTrackingEndpoint {
|
|||
'headers' => $this->request_headers(),
|
||||
'body' => wp_json_encode( $body ),
|
||||
);
|
||||
|
||||
do_action( 'woocommerce_paypal_payments_before_tracking_is_added', $order_id, $data );
|
||||
|
||||
$response = $this->request( $url, $args );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
|
@ -169,6 +172,8 @@ class OrderTrackingEndpoint {
|
|||
}
|
||||
|
||||
update_post_meta( $order_id, '_ppcp_paypal_tracking_number', $data['tracking_number'] ?? '' );
|
||||
|
||||
do_action( 'woocommerce_paypal_payments_after_tracking_is_added', $order_id, $response );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,9 +248,11 @@ class OrderTrackingEndpoint {
|
|||
$args = array(
|
||||
'method' => 'PUT',
|
||||
'headers' => $this->request_headers(),
|
||||
'body' => wp_json_encode( $data ),
|
||||
'body' => wp_json_encode( (array) apply_filters( 'woocommerce_paypal_payments_tracking_data_before_update', $data, $order_id ) ),
|
||||
);
|
||||
|
||||
do_action( 'woocommerce_paypal_payments_before_tracking_is_updated', $order_id, $data );
|
||||
|
||||
$response = $this->request( $url, $args );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
|
@ -290,6 +297,8 @@ class OrderTrackingEndpoint {
|
|||
}
|
||||
|
||||
update_post_meta( $order_id, '_ppcp_paypal_tracking_number', $data['tracking_number'] ?? '' );
|
||||
|
||||
do_action( 'woocommerce_paypal_payments_after_tracking_is_updated', $order_id, $response );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -203,12 +203,8 @@ class RenewalHandler {
|
|||
|
||||
$this->handle_new_order_status( $order, $wc_order );
|
||||
|
||||
if ( $this->capture_authorized_downloads( $order ) && AuthorizedPaymentsProcessor::SUCCESSFUL === $this->authorized_payments_processor->process( $wc_order ) ) {
|
||||
$wc_order->add_order_note(
|
||||
__( 'Payment successfully captured.', 'woocommerce-paypal-payments' )
|
||||
);
|
||||
$wc_order->update_meta_data( AuthorizedPaymentsProcessor::CAPTURED_META_KEY, 'true' );
|
||||
$wc_order->update_status( 'completed' );
|
||||
if ( $this->capture_authorized_downloads( $order ) ) {
|
||||
$this->authorized_payments_processor->capture_authorized_payment( $wc_order );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ use WC_Order;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentsEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\OrderRepository;
|
||||
use WooCommerce\PayPalCommerce\Subscription\FreeTrialHandlerTrait;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
@ -29,6 +30,8 @@ class PaymentTokenChecker {
|
|||
|
||||
use FreeTrialHandlerTrait;
|
||||
|
||||
const VAULTING_FAILED_META_KEY = '_ppcp_vaulting_failed';
|
||||
|
||||
/**
|
||||
* The payment token repository.
|
||||
*
|
||||
|
@ -115,9 +118,6 @@ class PaymentTokenChecker {
|
|||
return;
|
||||
}
|
||||
|
||||
$tokens = $this->payment_token_repository->all_for_user_id( $customer_id );
|
||||
if ( $tokens ) {
|
||||
try {
|
||||
if ( $this->is_free_trial_order( $wc_order ) ) {
|
||||
if ( in_array( $wc_order->get_payment_method(), array( CreditCardGateway::ID, CardButtonGateway::ID ), true )
|
||||
|| ( PayPalGateway::ID === $wc_order->get_payment_method() && 'card' === $wc_order->get_meta( PayPalGateway::ORDER_PAYMENT_SOURCE_META_KEY ) )
|
||||
|
@ -130,24 +130,62 @@ class PaymentTokenChecker {
|
|||
return;
|
||||
}
|
||||
|
||||
$tokens = $this->payment_token_repository->all_for_user_id( $customer_id );
|
||||
if ( $tokens ) {
|
||||
try {
|
||||
$this->capture_authorized_payment( $wc_order );
|
||||
} catch ( Exception $exception ) {
|
||||
$this->logger->error( $exception->getMessage() );
|
||||
$this->logger->warning( $exception->getMessage() );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->logger->error( "Payment for subscription parent order #{$order_id} was not saved on PayPal." );
|
||||
|
||||
try {
|
||||
$order = $this->order_repository->for_wc_order( $wc_order );
|
||||
$this->authorized_payments_processor->void_authorizations( $order );
|
||||
} catch ( RuntimeException $exception ) {
|
||||
$this->logger->warning( $exception->getMessage() );
|
||||
$subscription_behavior_when_fails = $this->settings->get( 'subscription_behavior_when_vault_fails' );
|
||||
} catch ( NotFoundException $exception ) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( $subscription_behavior_when_fails ) {
|
||||
case 'void_auth':
|
||||
$order = $this->order_repository->for_wc_order( $wc_order );
|
||||
$this->authorized_payments_processor->void_authorizations( $order );
|
||||
$this->logger->warning( "Payment for subscription parent order #{$order_id} was not saved at PayPal." );
|
||||
$this->update_failed_status( $wc_order );
|
||||
break;
|
||||
case 'capture_auth':
|
||||
try {
|
||||
$this->capture_authorized_payment( $wc_order );
|
||||
} catch ( Exception $exception ) {
|
||||
$this->logger->warning( $exception->getMessage() );
|
||||
return;
|
||||
}
|
||||
|
||||
$subscriptions = function_exists( 'wcs_get_subscriptions_for_order' ) ? wcs_get_subscriptions_for_order( $wc_order ) : array();
|
||||
foreach ( $subscriptions as $subscription ) {
|
||||
try {
|
||||
$subscription->set_requires_manual_renewal( true );
|
||||
$subscription->save();
|
||||
|
||||
$message = __( 'Subscription set to Manual Renewal because payment method was not saved at PayPal.', 'woocommerce-paypal-payments' );
|
||||
$wc_order->add_order_note( $message );
|
||||
|
||||
} catch ( Exception $exception ) {
|
||||
$this->logger->warning( "Could not update payment method on subscription #{$subscription->get_id()} " . $exception->getMessage() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'capture_auth_ignore':
|
||||
try {
|
||||
$this->capture_authorized_payment( $wc_order );
|
||||
} catch ( Exception $exception ) {
|
||||
$this->logger->warning( $exception->getMessage() );
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,7 +208,7 @@ class PaymentTokenChecker {
|
|||
* @param WC_Order $wc_order The WC order.
|
||||
*/
|
||||
private function update_failed_status( WC_Order $wc_order ): void {
|
||||
$error_message = __( 'Could not process order because it was not possible to save the payment on PayPal.', 'woocommerce-paypal-payments' );
|
||||
$error_message = __( 'Subscription payment failed. Payment method was not saved at PayPal.', 'woocommerce-paypal-payments' );
|
||||
$wc_order->update_status( 'failed', $error_message );
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,12 @@ use Dhii\Container\ServiceProvider;
|
|||
use Dhii\Modular\Module\ModuleInterface;
|
||||
use Interop\Container\ServiceProviderInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||
use WooCommerce\PayPalCommerce\Vaulting\Endpoint\DeletePaymentTokenEndpoint;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
/**
|
||||
* Class StatusReportModule
|
||||
|
@ -35,6 +40,7 @@ class VaultingModule implements ModuleInterface {
|
|||
* {@inheritDoc}
|
||||
*
|
||||
* @param ContainerInterface $container A services container instance.
|
||||
* @throws NotFoundException When service could not be found.
|
||||
*/
|
||||
public function run( ContainerInterface $container ): void {
|
||||
|
||||
|
@ -144,6 +150,100 @@ class VaultingModule implements ModuleInterface {
|
|||
10,
|
||||
3
|
||||
);
|
||||
|
||||
$this->filterFailedVaultingEmailsForSubscriptionOrders( $container );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the emails when vaulting is failed for subscription orders.
|
||||
*
|
||||
* @param ContainerInterface $container A services container instance.
|
||||
* @throws NotFoundException When service could not be found.
|
||||
*/
|
||||
protected function filterFailedVaultingEmailsForSubscriptionOrders( ContainerInterface $container ):void {
|
||||
add_action(
|
||||
'woocommerce_email_before_order_table',
|
||||
function( WC_Order $order ) use ( $container ) {
|
||||
/**
|
||||
* The SubscriptionHelper.
|
||||
*
|
||||
* @var SubscriptionHelper $subscription_helper
|
||||
*/
|
||||
$subscription_helper = $container->get( 'subscription.helper' );
|
||||
|
||||
/**
|
||||
* The logger.
|
||||
*
|
||||
* @var LoggerInterface $logger
|
||||
*/
|
||||
$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 );
|
||||
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' ) {
|
||||
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' ) {
|
||||
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>' );
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'woocommerce_email_after_order_table',
|
||||
function( WC_Order $order ) use ( $container ) {
|
||||
/**
|
||||
* The SubscriptionHelper.
|
||||
*
|
||||
* @var SubscriptionHelper $subscription_helper
|
||||
*/
|
||||
$subscription_helper = $container->get( 'subscription.helper' );
|
||||
|
||||
/**
|
||||
* The logger.
|
||||
*
|
||||
* @var LoggerInterface $logger
|
||||
*/
|
||||
$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 );
|
||||
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' ) {
|
||||
$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 );
|
||||
$subscription->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,5 +69,9 @@
|
|||
togglePayLater()
|
||||
|
||||
vaultingCheckboxes.forEach(node => node.addEventListener('change', togglePayLater));
|
||||
|
||||
if(PayPalCommerceGatewaySettings.is_subscriptions_plugin_active !== '1') {
|
||||
document.getElementById('field-subscription_behavior_when_vault_fails').style.display = 'none';
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -243,6 +243,14 @@ return array(
|
|||
}
|
||||
}
|
||||
|
||||
$dcc_product_status = $container->get( 'wcgateway.helper.dcc-product-status' );
|
||||
assert( $dcc_product_status instanceof DCCProductStatus );
|
||||
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
||||
assert( $dcc_applies instanceof DccApplies );
|
||||
if ( ! $dcc_product_status->dcc_is_active() || ! $dcc_applies->for_country_currency() ) {
|
||||
unset( $sections['ppcp-credit-card-gateway'] );
|
||||
}
|
||||
|
||||
return $sections;
|
||||
},
|
||||
'wcgateway.settings.status' => static function ( ContainerInterface $container ): SettingsStatus {
|
||||
|
@ -603,6 +611,26 @@ return array(
|
|||
'gateway' => array( 'paypal', 'dcc' ),
|
||||
'input_class' => $container->get( 'wcgateway.helper.vaulting-scope' ) ? array() : array( 'ppcp-disabled-checkbox' ),
|
||||
),
|
||||
'subscription_behavior_when_vault_fails' => array(
|
||||
'title' => __( 'Subscription capture behavior if Vault fails', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'select',
|
||||
'class' => array(),
|
||||
'input_class' => array( 'wc-enhanced-select' ),
|
||||
'default' => 'void_auth',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'By default, subscription payments are captured only when saving the payment method was successful. Without a saved payment method, automatic renewal payments are not possible.', 'woocommerce-paypal-payments' ),
|
||||
'description_with_tip' => __( 'Determines whether authorized payments for subscription orders are captured or voided if there is no saved payment method. This only applies when the intent Capture is used for the subscription order.', 'woocommerce-paypal-payments' ),
|
||||
'options' => array(
|
||||
'void_auth' => __( 'Void authorization & fail the order/subscription', 'woocommerce-paypal-payments' ),
|
||||
'capture_auth' => __( 'Capture authorized payment & set subscription to Manual Renewal', 'woocommerce-paypal-payments' ),
|
||||
'capture_auth_ignore' => __( 'Capture authorized payment & disregard missing payment method', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => array( 'paypal', 'dcc' ),
|
||||
),
|
||||
'card_billing_data_mode' => array(
|
||||
'title' => __( 'Card billing data handling', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'select',
|
||||
|
@ -1923,7 +1951,12 @@ return array(
|
|||
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
$partner_endpoint = $container->get( 'api.endpoint.partners' );
|
||||
return new DCCProductStatus( $settings, $partner_endpoint, $container->get( 'dcc.status-cache' ) );
|
||||
return new DCCProductStatus(
|
||||
$settings,
|
||||
$partner_endpoint,
|
||||
$container->get( 'dcc.status-cache' ),
|
||||
$container->get( 'api.helpers.dccapplies' )
|
||||
);
|
||||
},
|
||||
|
||||
'button.helper.messages-disclaimers' => static function ( ContainerInterface $container ): MessagesDisclaimers {
|
||||
|
@ -2056,7 +2089,12 @@ return array(
|
|||
},
|
||||
|
||||
'button.helper.vaulting-label' => static function ( ContainerInterface $container ): string {
|
||||
$vaulting_label = __( 'Enable saved cards and subscription features on your store.', 'woocommerce-paypal-payments' );
|
||||
$vaulting_label = sprintf(
|
||||
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
|
||||
__( 'Enable saved cards, PayPal accounts, and subscription features on your store. Payment methods are saved in the secure %1$sPayPal Vault%2$s.', 'woocommerce-paypal-payments' ),
|
||||
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#vaulting-saving-a-payment-method" target="_blank">',
|
||||
'</a>'
|
||||
);
|
||||
|
||||
if ( ! $container->get( 'wcgateway.helper.vaulting-scope' ) ) {
|
||||
$vaulting_label .= sprintf(
|
||||
|
@ -2071,7 +2109,20 @@ return array(
|
|||
}
|
||||
|
||||
$vaulting_label .= '<p class="description">';
|
||||
$vaulting_label .= __( 'This will disable all Pay Later messaging on your site.', 'woocommerce-paypal-payments' );
|
||||
$vaulting_label .= sprintf(
|
||||
// translators: %1$s, %2$s, %3$s and %4$s are the opening and closing of HTML <a> tag.
|
||||
__( 'This will disable all %1$sPay Later%2$s features and %3$sAlternative Payment Methods%4$s on your site.', 'woocommerce-paypal-payments' ),
|
||||
'<a
|
||||
href="https://woocommerce.com/document/woocommerce-paypal-payments/#pay-later"
|
||||
target="_blank"
|
||||
>',
|
||||
'</a>',
|
||||
'<a
|
||||
href="https://woocommerce.com/document/woocommerce-paypal-payments/#alternative-payment-methods"
|
||||
target="_blank"
|
||||
>',
|
||||
'</a>'
|
||||
);
|
||||
$vaulting_label .= '</p>';
|
||||
|
||||
return $vaulting_label;
|
||||
|
|
|
@ -9,7 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||
|
||||
/**
|
||||
* Class SettingsPageAssets
|
||||
|
@ -30,15 +30,24 @@ class SettingsPageAssets {
|
|||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* The subscription helper.
|
||||
*
|
||||
* @var SubscriptionHelper
|
||||
*/
|
||||
protected $subscription_helper;
|
||||
|
||||
/**
|
||||
* Assets constructor.
|
||||
*
|
||||
* @param string $module_url The url of this module.
|
||||
* @param string $version The assets version.
|
||||
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
||||
*/
|
||||
public function __construct( string $module_url, string $version ) {
|
||||
public function __construct( string $module_url, string $version, SubscriptionHelper $subscription_helper ) {
|
||||
$this->module_url = $module_url;
|
||||
$this->version = $version;
|
||||
$this->subscription_helper = $subscription_helper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,5 +105,14 @@ class SettingsPageAssets {
|
|||
$this->version,
|
||||
true
|
||||
);
|
||||
|
||||
// Intent is configured with Authorize and Capture Virtual-Only Orders is not set.
|
||||
wp_localize_script(
|
||||
'ppcp-gateway-settings',
|
||||
'PayPalCommerceGatewaySettings',
|
||||
array(
|
||||
'is_subscriptions_plugin_active' => $this->subscription_helper->plugin_is_active(),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,16 @@ trait ProcessPaymentTrait {
|
|||
* @param int $customer_id The customer ID.
|
||||
*/
|
||||
protected function schedule_saved_payment_check( int $wc_order_id, int $customer_id ): void {
|
||||
$timestamp = 1 * MINUTE_IN_SECONDS;
|
||||
if (
|
||||
$this->config->has( 'subscription_behavior_when_vault_fails' )
|
||||
&& $this->config->get( 'subscription_behavior_when_vault_fails' ) === 'capture_auth'
|
||||
) {
|
||||
$timestamp = 0;
|
||||
}
|
||||
|
||||
as_schedule_single_action(
|
||||
time() + ( 1 * MINUTE_IN_SECONDS ),
|
||||
time() + $timestamp,
|
||||
'woocommerce_paypal_payments_check_saved_payment',
|
||||
array(
|
||||
'order_id' => $wc_order_id,
|
||||
|
|
|
@ -13,6 +13,7 @@ use Throwable;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnersEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\SellerStatusProduct;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
/**
|
||||
|
@ -49,21 +50,31 @@ class DCCProductStatus {
|
|||
*/
|
||||
private $partners_endpoint;
|
||||
|
||||
/**
|
||||
* The dcc applies helper.
|
||||
*
|
||||
* @var DccApplies
|
||||
*/
|
||||
protected $dcc_applies;
|
||||
|
||||
/**
|
||||
* DccProductStatus constructor.
|
||||
*
|
||||
* @param Settings $settings The Settings.
|
||||
* @param PartnersEndpoint $partners_endpoint The Partner Endpoint.
|
||||
* @param Cache $cache The cache.
|
||||
* @param DccApplies $dcc_applies The dcc applies helper.
|
||||
*/
|
||||
public function __construct(
|
||||
Settings $settings,
|
||||
PartnersEndpoint $partners_endpoint,
|
||||
Cache $cache
|
||||
Cache $cache,
|
||||
DccApplies $dcc_applies
|
||||
) {
|
||||
$this->settings = $settings;
|
||||
$this->partners_endpoint = $partners_endpoint;
|
||||
$this->cache = $cache;
|
||||
$this->dcc_applies = $dcc_applies;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +124,12 @@ class DCCProductStatus {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
$this->cache->set( self::DCC_STATUS_CACHE_KEY, false, 3 * MONTH_IN_SECONDS );
|
||||
|
||||
$expiration = 3 * MONTH_IN_SECONDS;
|
||||
if ( $this->dcc_applies->for_country_currency() ) {
|
||||
$expiration = 3 * HOUR_IN_SECONDS;
|
||||
}
|
||||
$this->cache->set( self::DCC_STATUS_CACHE_KEY, false, $expiration );
|
||||
|
||||
$this->current_status_cache = false;
|
||||
return false;
|
||||
|
|
|
@ -210,12 +210,8 @@ class OrderProcessor {
|
|||
|
||||
$this->handle_new_order_status( $order, $wc_order );
|
||||
|
||||
if ( $this->capture_authorized_downloads( $order ) && AuthorizedPaymentsProcessor::SUCCESSFUL === $this->authorized_payments_processor->process( $wc_order ) ) {
|
||||
$wc_order->add_order_note(
|
||||
__( 'Payment successfully captured.', 'woocommerce-paypal-payments' )
|
||||
);
|
||||
$wc_order->update_meta_data( AuthorizedPaymentsProcessor::CAPTURED_META_KEY, 'true' );
|
||||
$wc_order->update_status( 'completed' );
|
||||
if ( $this->capture_authorized_downloads( $order ) ) {
|
||||
$this->authorized_payments_processor->capture_authorized_payment( $wc_order );
|
||||
}
|
||||
$this->last_error = '';
|
||||
return true;
|
||||
|
|
|
@ -281,12 +281,15 @@ class SettingsListener {
|
|||
|
||||
$credentials_change_status = null; // Cannot detect on Card Processing page.
|
||||
|
||||
if ( PayPalGateway::ID === $this->page_id || Settings::CONNECTION_TAB_ID === $this->page_id ) {
|
||||
$settings['enabled'] = isset( $_POST['woocommerce_ppcp-gateway_enabled'] )
|
||||
&& 1 === absint( $_POST['woocommerce_ppcp-gateway_enabled'] );
|
||||
|
||||
if ( Settings::CONNECTION_TAB_ID === $this->page_id ) {
|
||||
$credentials_change_status = $this->determine_credentials_change_status( $settings );
|
||||
}
|
||||
|
||||
if ( PayPalGateway::ID === $this->page_id ) {
|
||||
$settings['enabled'] = isset( $_POST['woocommerce_ppcp-gateway_enabled'] )
|
||||
&& 1 === absint( $_POST['woocommerce_ppcp-gateway_enabled'] );
|
||||
}
|
||||
|
||||
// phpcs:enable phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||
// phpcs:enable phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||
if ( $credentials_change_status ) {
|
||||
|
|
|
@ -443,6 +443,10 @@ $data_rows_html
|
|||
<?php if ( $description ) : ?>
|
||||
<p class="<?php echo 'ppcp-heading' === $config['type'] ? '' : 'description'; ?>"><?php echo wp_kses_post( $description ); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( isset( $config['description_with_tip'] ) && $config['description_with_tip'] ) : ?>
|
||||
<p class="<?php echo 'description'; ?>"><?php echo wp_kses_post( $config['description_with_tip'] ); ?></p>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -155,7 +155,8 @@ class WCGatewayModule implements ModuleInterface {
|
|||
if ( $c->has( 'wcgateway.url' ) ) {
|
||||
$assets = new SettingsPageAssets(
|
||||
$c->get( 'wcgateway.url' ),
|
||||
$c->get( 'ppcp.asset-version' )
|
||||
$c->get( 'ppcp.asset-version' ),
|
||||
$c->get( 'subscription.helper' )
|
||||
);
|
||||
$assets->register_assets();
|
||||
}
|
||||
|
|
|
@ -143,6 +143,21 @@ class WebhookModule implements ModuleInterface {
|
|||
$logger->error( 'Failed to load webhooks list: ' . $exception->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_gateway_migrate',
|
||||
static function () use ( $container ) {
|
||||
$registrar = $container->get( 'webhook.registrar' );
|
||||
assert( $registrar instanceof WebhookRegistrar );
|
||||
add_action(
|
||||
'init',
|
||||
function () use ( $registrar ) {
|
||||
$registrar->unregister();
|
||||
$registrar->register();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "woocommerce-paypal-payments",
|
||||
"version": "1.9.3",
|
||||
"version": "1.9.4",
|
||||
"description": "WooCommerce PayPal Payments",
|
||||
"repository": "https://github.com/woocommerce/woocommerce-paypal-payments",
|
||||
"license": "GPL-2.0",
|
||||
|
|
14
readme.txt
14
readme.txt
|
@ -4,7 +4,7 @@ Tags: woocommerce, paypal, payments, ecommerce, e-commerce, store, sales, sell,
|
|||
Requires at least: 5.3
|
||||
Tested up to: 6.0
|
||||
Requires PHP: 7.1
|
||||
Stable tag: 1.9.3
|
||||
Stable tag: 1.9.4
|
||||
License: GPLv2
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
|
@ -81,6 +81,18 @@ Follow the steps below to connect the plugin to your PayPal account:
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 1.9.4 =
|
||||
* Add - Create new connection tab #801
|
||||
* Add - Functionality to choose subscription failure behavior #728
|
||||
* Fix - Virtual-only orders always move order status to completed #868
|
||||
* Fix - PayPal order created twice when context is checkout #832
|
||||
* Enhancement - Handle unsupported browsers better #843
|
||||
* Enhancement - Combine the Webhooks Status page into a new Connection tab (891) #827
|
||||
* Enhancement - Hide PayPal Card Processing tab if not available in country or for merchant #870
|
||||
* Enhancement - Resubscribe webhooks on plugin upgrades #838
|
||||
* Enhancement - PUI-relevant webhook not subscribed to #842
|
||||
* Enhancement - Remove WC logo during onboarding #881
|
||||
|
||||
= 1.9.3 =
|
||||
* Add - Tracking API #792
|
||||
* Fix - Improve compatibility with Siteground Optimizer plugin #797
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||
use WooCommerce\PayPalCommerce\TestCase;
|
||||
use function Brain\Monkey\Functions\when;
|
||||
use Mockery;
|
||||
|
@ -13,8 +14,9 @@ class SettingsPagesAssetsTest extends TestCase
|
|||
{
|
||||
$moduleUrl = 'http://example.com/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway';
|
||||
$modulePath = '/var/www/html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway';
|
||||
$subscriptionsHelper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = new SettingsPageAssets($moduleUrl, $modulePath);
|
||||
$testee = new SettingsPageAssets($moduleUrl, $modulePath, $subscriptionsHelper);
|
||||
|
||||
when('is_admin')
|
||||
->justReturn(true);
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* Plugin Name: WooCommerce PayPal Payments
|
||||
* Plugin URI: https://woocommerce.com/products/woocommerce-paypal-payments/
|
||||
* Description: PayPal's latest complete payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
|
||||
* Version: 1.9.3
|
||||
* Version: 1.9.4
|
||||
* Author: WooCommerce
|
||||
* Author URI: https://woocommerce.com/
|
||||
* License: GPL-2.0
|
||||
* Requires PHP: 7.1
|
||||
* WC requires at least: 3.9
|
||||
* WC tested up to: 6.8
|
||||
* WC tested up to: 6.9
|
||||
* Text Domain: woocommerce-paypal-payments
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue