Skip to content

Commit

Permalink
Merge pull request #1979 from woocommerce/PCP-2084-free-trial-subscri…
Browse files Browse the repository at this point in the history
…ption-products-using-pay-pal-vaulting-when-pay-pal-subscriptions-configured-as-subscriptions-mode

Free trial subscription products using PayPal Vaulting when PayPal Subscriptions configured as Subscriptions Mode (2084)
  • Loading branch information
Dinamiko authored Feb 1, 2024
2 parents f95fe26 + 0160e42 commit 9988675
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion modules/ppcp-button/resources/js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const bootstrap = () => {
}

const isFreeTrial = PayPalCommerceGateway.is_free_trial_cart;
if (isFreeTrial && data.fundingSource !== 'card') {
if (isFreeTrial && data.fundingSource !== 'card' && ! PayPalCommerceGateway.subscription_plan_id) {
freeTrialHandler.handle();
return actions.reject();
}
Expand Down Expand Up @@ -241,6 +241,7 @@ document.addEventListener(
if (!typeof (PayPalCommerceGateway)) {
console.error('PayPal button could not be configured.');
return;
return;
}

if (
Expand Down
2 changes: 1 addition & 1 deletion modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public function process_payment( $order_id ) {
$wc_order->save();
}

if ( 'card' !== $funding_source && $this->is_free_trial_order( $wc_order ) ) {
if ( 'card' !== $funding_source && $this->is_free_trial_order( $wc_order ) && ! $this->subscription_helper->paypal_subscription_id() ) {
$user_id = (int) $wc_order->get_customer_id();
$tokens = $this->payment_token_repository->all_for_user_id( $user_id );
if ( ! array_filter(
Expand Down

0 comments on commit 9988675

Please sign in to comment.