Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PT-560 buyer_fee_cents bugfix #122

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: mondu-ai, arthurmmoreira, tikohov20
Tags: mondu, woocommerce, e-commerce, ecommerce, store, sales, sell, woo, woo commerce, shop, cart, shopping cart, sell online, checkout, payment, payments, bnpl, b2b
Requires at least: 5.9.0
Tested up to: 6.5.3
Stable tag: 3.0.2
Stable tag: 3.0.3
Requires PHP: 7.4
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
== Changelog ==

= 3.0.3 =

* Bugfix - buyer_fee_cents should be on lines level

= 3.0.2 =

* Added filters for buyer_fee_cents and whole order_data
Expand Down
4 changes: 2 additions & 2 deletions mondu-buy-now-pay-later.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Mondu Buy Now Pay Later
* Plugin URI: https://github.com/mondu-ai/bnpl-checkout-woocommerce/releases
* Description: Mondu provides B2B E-commerce and B2B marketplaces with an online payment solution to buy now and pay later.
* Version: 3.0.2
* Version: 3.0.3
* Author: Mondu
* Author URI: https://mondu.ai
*
Expand All @@ -27,7 +27,7 @@
die( 'Direct access not allowed' );
}

define( 'MONDU_PLUGIN_VERSION', '3.0.2' );
define( 'MONDU_PLUGIN_VERSION', '3.0.3' );
define( 'MONDU_PLUGIN_FILE', __FILE__ );
define( 'MONDU_PLUGIN_PATH', __DIR__ );
define( 'MONDU_PLUGIN_BASENAME', plugin_basename(MONDU_PLUGIN_FILE) );
Expand Down
16 changes: 8 additions & 8 deletions src/Mondu/Mondu/Support/OrderData.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,13 @@ public static function order_data_from_wc_order( WC_Order $order ) {
$billing_zip_code = $order->get_billing_postcode();
$billing_country_code = $order->get_billing_country();

/**
* @since 3.0.2
*
* Can be used to include any additional costs that are not included by default.
*/
$buyer_fee_cents = apply_filters('mondu_buyer_fee_cents', 0, $order);

$order_data = [
'payment_method' => array_flip( Plugin::PAYMENT_METHODS )[ $order->get_payment_method() ],
'currency' => get_woocommerce_currency(),
'external_reference_id' => (string) $order->get_order_number(),
'gross_amount_cents' => round( (float) $order->get_total() * 100),
'net_price_cents' => round( (float) $order->get_subtotal() * 100),
'tax_cents' => round( (float) $order->get_total_tax() * 100),
'buyer_fee_cents' => $buyer_fee_cents,
'buyer' => [
'first_name' => isset($billing_first_name) && Helper::not_null_or_empty($billing_first_name) ? $billing_first_name : null,
'last_name' => isset($billing_last_name) && Helper::not_null_or_empty($billing_last_name) ? $billing_last_name : null,
Expand Down Expand Up @@ -249,8 +241,16 @@ private static function get_shipping_address_from_order( WC_Order $order ) {
* @return array
*/
private static function get_lines_from_order( WC_Order $order ) {
/**
* @since 3.0.2
*
* Can be used to include any additional costs that are not included by default.
*/
$buyer_fee_cents = apply_filters('mondu_buyer_fee_cents', 0, $order);

$line = [
'discount_cents' => round($order->get_discount_total() * 100),
'buyer_fee_cents' => $buyer_fee_cents,
'shipping_price_cents' => round( (float) ( $order->get_shipping_total() + $order->get_shipping_tax() ) * 100), # Considering that is not possible to save taxes that does not belongs to products, sums shipping taxes here
'line_items' => [],
];
Expand Down
Loading