• I just faced an recent issue with partial payments.

    It just stopped automatic for no reason.

    I am using parital payments along side paypal payments and Payment Gateway Based Fees and Discounts for WooCommerce

    Everything was working fine untill a fine day the plugin updated now I have no clue what went wrong.

    Paypal is not accepting partial payment instead its taking full payment.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    Please send the link of the plugin that you are using for PayPal payment gateway

    Thread Starter Ashish Mishra

    (@ashbirmis)

    Ok we will test it out on our end to reproduce the issue

    Hi,

    We have checked the PayPal plugin; they have made some major changes in the PayPal plugin in the way they handle the checkout because of that partial payment option has stopped working.

    Earlier they used to consider the order total given by WooCommerce for checkout amount but in this new version they calculate the order total themself because of that we are not able to modify the amount

    At present we have not found any way to make it work with PayPal latest version so only workaround is to use their old version

    we will try to find the solution

    Thread Starter Ashish Mishra

    (@ashbirmis)

    Can you provide us with an ETA for the next built solving this issue?

    Thread Starter Ashish Mishra

    (@ashbirmis)



    /**
    * Force WooCommerce PayPal Payments to charge only partial/deposit amount.
    */

    add_filter(
    'woocommerce_paypal_payments_simulate_cart_enabled',
    '__return_false',
    999
    );

    /**
    * Disable PayPal item breakdown so custom amount does not mismatch.
    */
    add_filter(
    'ppcp_ditch_items_breakdown',
    '__return_true',
    999
    );

    /**
    * Get deposit amount from partial payment plugin session.
    */
    function nygold_get_paypal_partial_amount() {

    if ( ! function_exists( 'WC' ) || ! WC()->session ) {
    return false;
    }

    $partial_selected = WC()->session->get( 'pi_partial_payment' );

    if ( empty( $partial_selected ) ) {
    return false;
    }

    $advance_amount = WC()->session->get( 'pi_advance_amount' );

    if ( empty( $advance_amount ) || (float) $advance_amount <= 0 ) {
    return false;
    }

    return number_format(
    (float) $advance_amount,
    2,
    '.',
    ''
    );
    }

    /**
    * Override PayPal create order amount.
    */
    add_filter( 'ppcp_create_order_request_body_data', function( $data ) {

    $partial_amount = nygold_get_paypal_partial_amount();

    if ( ! $partial_amount ) {
    return $data;
    }

    if ( isset( $data['purchase_units'][0]['amount'] ) ) {

    $currency = $data['purchase_units'][0]['amount']['currency_code'] ?? get_woocommerce_currency();

    $data['purchase_units'][0]['amount'] = array(
    'currency_code' => $currency,
    'value' => $partial_amount,
    );
    }

    if ( isset( $data['purchase_units'][0]['items'] ) ) {
    unset( $data['purchase_units'][0]['items'] );
    }

    return $data;

    }, 999 );

    /**
    * Override PayPal patched amount too.
    * PayPal may patch totals after create order.
    */
    add_filter( 'ppcp_patch_order_request_body_data', function( $patches ) {

    $partial_amount = nygold_get_paypal_partial_amount();

    if ( ! $partial_amount ) {
    return $patches;
    }

    foreach ( $patches as $key => $patch ) {

    if ( isset( $patch['value']['amount'] ) ) {

    $currency = $patch['value']['amount']['currency_code'] ?? get_woocommerce_currency();

    $patches[ $key ]['value']['amount'] = array(
    'currency_code' => $currency,
    'value' => $partial_amount,
    );
    }

    if ( isset( $patch['value']['items'] ) ) {
    unset( $patches[ $key ]['value']['items'] );
    }
    }

    return $patches;

    }, 999 );

    This fixes the issue

    jyotsnasingh520

    (@jyotsnasingh520)

    Thanks for sharing the solution we have tested its working on our end and included it in the new release v1.1.9.49

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.