Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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

    Thread Starter Ashish Mishra

    (@ashbirmis)

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

    Thread Starter Ashish Mishra

    (@ashbirmis)

    Thread Starter Ashish Mishra

    (@ashbirmis)

    I had a talk with support team they are asking what modules we need to activate in the plugin app.

    I have activated auth 2, address validator and rating.

    is there any pending?

    Thread Starter Ashish Mishra

    (@ashbirmis)

    Please ensure that your UPS User ID, Password, Access Key, and Account Number are correctly entered in the plugin settings. If these are correct, the disconnection could be due to a temporary server issue or a restriction on your UPS account.

    I am not able to find the place where to add these details.

    https://prnt.sc/4ouNv9FnahP5

    In above screenshot i can only see authorize button when i click on it i enter the credentails and after successful login it redirects me back to the woocommerce settings page in url it says success as status but when i go back and check it says authentication error.

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