Skip to content

Instantly share code, notes, and snippets.

@vladutilie
Last active July 18, 2025 11:50
Show Gist options
  • Select an option

  • Save vladutilie/b050f7e49ce10f2912b8c25eefd00cdf to your computer and use it in GitHub Desktop.

Select an option

Save vladutilie/b050f7e49ce10f2912b8c25eefd00cdf to your computer and use it in GitHub Desktop.

Revisions

  1. vladutilie revised this gist Jul 18, 2025. 1 changed file with 4 additions and 10 deletions.
    14 changes: 4 additions & 10 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,10 @@ function ( \Netopia_Payment_Request_Abstract $mobilpay_instance, int $order_id )
    $amount = 123; // Amount based on some products from the $order.

    /**
    * The destination seller account ID and the amount that will be transferred to that seller account.
    * The destination seller account (SAC) ID and the amount that will be transferred to that seller account.
    * The currency will always be that of the originating request.
    *
    * The rest of the amount will go in the Netopia main account.
    */
    $netopia_instance->split->destinations = array(
    array(
    @@ -20,15 +22,7 @@ function ( \Netopia_Payment_Request_Abstract $mobilpay_instance, int $order_id )
    ),
    );

    error_log(
    print_r(
    array(
    'amount_1' => $amount_1,
    'amount_2' => $amount_2,
    ),
    true
    )
    );
    error_log( print_r( array( 'amount_1' => $amount_1 ), true ) );

    return $netopia_instance;
    },
  2. vladutilie revised this gist Jul 18, 2025. 1 changed file with 7 additions and 14 deletions.
    21 changes: 7 additions & 14 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -2,28 +2,21 @@
    add_filter(
    'netopia_payment_request_params',
    function ( \Netopia_Payment_Request_Abstract $mobilpay_instance, int $order_id ) {
    require_once get_stylesheet_directory() . '/inc/classes/Split.php';
    $mobilpay_instance->split = new Inc\Classes\Mobilpay_Payment_Split();
    require_once get_stylesheet_directory() . '/inc/classes/class-netopia-payment-split.php';
    $netopia_instance->split = new Inc\Classes\Netopia_Payment_Split();

    $order = wc_get_order( $order_id );

    $percent = 0.15; // Split the payment by 15%.
    $total = round( $order->get_total() * 100 );
    $amount_1 = round( $total * $percent );
    $amount_2 = $total - $amount_1;
    $amount = 123; // Amount based on some products from the $order.

    /**
    * The destination seller account ID and the amount that will be transferred to that seller account.
    * The currency will always be that of the originating request.
    */
    $mobilpay_instance->split->destinations = array(
    $netopia_instance->split->destinations = array(
    array(
    'id' => 'netopia-merchant-1-id',
    'amount' => $amount_1 / 100,
    ),
    array(
    'id' => 'netopia-merchant-2-id',
    'amount' => $amount_2 / 100,
    'id' => 'netopia-sac-id',
    'amount' => $amount / 100,
    ),
    );

    @@ -37,7 +30,7 @@ function ( \Netopia_Payment_Request_Abstract $mobilpay_instance, int $order_id )
    )
    );

    return $mobilpay_instance;
    return $netopia_instance;
    },
    10,
    2
  3. vladutilie revised this gist Jul 18, 2025. No changes.
  4. vladutilie revised this gist Jul 7, 2025. No changes.
  5. vladutilie created this gist Jul 7, 2025.
    44 changes: 44 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    <?php
    add_filter(
    'netopia_payment_request_params',
    function ( \Netopia_Payment_Request_Abstract $mobilpay_instance, int $order_id ) {
    require_once get_stylesheet_directory() . '/inc/classes/Split.php';
    $mobilpay_instance->split = new Inc\Classes\Mobilpay_Payment_Split();

    $order = wc_get_order( $order_id );

    $percent = 0.15; // Split the payment by 15%.
    $total = round( $order->get_total() * 100 );
    $amount_1 = round( $total * $percent );
    $amount_2 = $total - $amount_1;

    /**
    * The destination seller account ID and the amount that will be transferred to that seller account.
    * The currency will always be that of the originating request.
    */
    $mobilpay_instance->split->destinations = array(
    array(
    'id' => 'netopia-merchant-1-id',
    'amount' => $amount_1 / 100,
    ),
    array(
    'id' => 'netopia-merchant-2-id',
    'amount' => $amount_2 / 100,
    ),
    );

    error_log(
    print_r(
    array(
    'amount_1' => $amount_1,
    'amount_2' => $amount_2,
    ),
    true
    )
    );

    return $mobilpay_instance;
    },
    10,
    2
    );