Skip to content

Instantly share code, notes, and snippets.

@vladutilie
Created July 7, 2025 12:43
Show Gist options
  • Save vladutilie/b050f7e49ce10f2912b8c25eefd00cdf to your computer and use it in GitHub Desktop.
Save vladutilie/b050f7e49ce10f2912b8c25eefd00cdf to your computer and use it in GitHub Desktop.
Netopia split payments for WooCommerce
<?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
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment