Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakpathania committed Dec 24, 2024
1 parent d6c41ca commit 8b2da26
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
3 changes: 0 additions & 3 deletions includes/class-wc-payments-order-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -1930,9 +1930,6 @@ private function complete_order_processing( $order, $intent_status = null ) {
private function get_order_amount( $order ) {
$multi_currency_instance = WC_Payments_Multi_Currency();
$order_price = $order->get_total();
if ( ! $order_price ) {
return $order_price;
}

$formatted_price = $multi_currency_instance->get_backend_formatted_wc_price( $order_price, [ 'currency' => $order->get_currency() ] );
return WC_Payments_Explicit_Price_Formatter::get_explicit_price( $formatted_price, $order );
Expand Down
4 changes: 3 additions & 1 deletion includes/multi-currency/MultiCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use WCPay\MultiCurrency\Logger;
use WCPay\MultiCurrency\Notes\NoteMultiCurrencyAvailable;
use WCPay\MultiCurrency\Utils;
use WC_Payments_Features;

defined( 'ABSPATH' ) || exit;

Expand Down Expand Up @@ -1335,7 +1336,8 @@ public function is_initialized(): bool {
* @return string The formatted amount.
*/
public function get_backend_formatted_wc_price( float $amount, array $args = [] ): string {
if ( ! self::has_additional_currencies_enabled() ) {
// Return early if MC isn't enabled or merchant has a single currency.
if ( ! self::has_additional_currencies_enabled() || ! WC_Payments_Features::is_customer_multi_currency_enabled() ) {
return wc_price( $amount, $args );
}

Expand Down
24 changes: 24 additions & 0 deletions tests/unit/test-class-wc-payments-webhook-processing-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,10 @@ public function test_payment_intent_successful_and_completes_order() {
->expects( $this->exactly( 2 ) )
->method( 'save' );

$this->mock_order
->method( 'get_total' )
->willReturn( 15.00 );

$this->mock_order
->expects( $this->exactly( 2 ) )
->method( 'has_status' )
Expand Down Expand Up @@ -747,6 +751,10 @@ public function test_payment_intent_successful_and_completes_order_without_inten
->expects( $this->exactly( 2 ) )
->method( 'save' );

$this->mock_order
->method( 'get_total' )
->willReturn( 15.00 );

$this->mock_order
->expects( $this->exactly( 2 ) )
->method( 'has_status' )
Expand Down Expand Up @@ -939,6 +947,10 @@ public function test_payment_intent_successful_and_send_card_reader_receipt() {
)
->willReturn( false );

$this->mock_order
->method( 'get_total' )
->willReturn( 15.00 );

$this->mock_order
->expects( $this->once() )
->method( 'payment_complete' );
Expand Down Expand Up @@ -1040,6 +1052,10 @@ public function test_payment_intent_successful_and_save_mandate() {
[ '_intention_status', $intent_status ]
);

$this->mock_order
->method( 'get_total' )
->willReturn( 15.00 );

$this->mock_order
->expects( $this->exactly( 2 ) )
->method( 'save' );
Expand Down Expand Up @@ -1123,6 +1139,10 @@ public function test_payment_intent_fails_and_fails_order() {
->with( '_payment_method_id' )
->willReturn( 'pm_123123123123123' );

$this->mock_order
->method( 'get_total' )
->willReturn( 15.00 );

$this->mock_order
->expects( $this->exactly( 3 ) )
->method( 'has_status' )
Expand Down Expand Up @@ -1190,6 +1210,10 @@ public function test_payment_intent_without_charges_fails_and_fails_order() {
->with( '_payment_method_id' )
->willReturn( 'pm_123123123123123' );

$this->mock_order
->method( 'get_total' )
->willReturn( 15.00 );

$this->mock_order
->expects( $this->exactly( 3 ) )
->method( 'has_status' )
Expand Down

0 comments on commit 8b2da26

Please sign in to comment.