Skip to content

Commit

Permalink
Merge pull request #304 from reepay/dimaspolohov
Browse files Browse the repository at this point in the history
Dimaspolohov
  • Loading branch information
dimaspolohov authored Dec 1, 2023
2 parents 7b3a316 + a448965 commit 3214fa5
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
1 change: 1 addition & 0 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The Billwerk+ Payments plugin extends WooCommerce allowing you to take payments
See installation guide right here: https://docu.billwerk.plus/help/en/apps/woocommerce/setup-woocommerce-plugin.html

== Changelog ==
v 1.6.3 - Woocommerce zero payment fixes
v 1.6.2 - Fix user handle generate
v 1.6.1 - Card saving fixes, user creation fixes
v 1.6.0 - Lots of updates and fixes
Expand Down
18 changes: 0 additions & 18 deletions includes/Actions/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,6 @@ class Checkout {
*/
public function __construct() {
add_action( 'woocommerce_checkout_create_order_line_item', array( $this, 'action_checkout_create_order_line_item' ), 10, 4 );
add_filter( 'woocommerce_cart_needs_payment', array( $this, 'check_need_payment' ), 10 );
}

/**
* Count line item discount
*
* @param bool $need_payment need payment marker.
*
* @see WC_Cart::needs_payment
*
* @return bool
*/
public function check_need_payment( bool $need_payment ): bool {
if ( wcs_cart_have_subscription() ) {
return true;
}

return $need_payment;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion includes/Gateways/ReepayGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ public function process_payment( $order_id ) {
);
}

$have_sub = class_exists( WC_Reepay_Renewals::class ) && WC_Reepay_Renewals::is_order_contain_subscription( $order );
$have_sub = (class_exists( WC_Reepay_Renewals::class ) && WC_Reepay_Renewals::is_order_contain_subscription( $order )) || wcs_cart_have_subscription();

$only_items_lines = array();

Expand Down Expand Up @@ -1216,18 +1216,24 @@ public function process_session_charge( array $params, WC_Order $order ): array
$params
);
if ( is_wp_error( $result ) ) {
wc_add_notice( $result->get_error_message(), 'error' );

return array(
'result' => 'failure',
'message' => $result->get_error_message(),
);
}
} else {
wc_add_notice( $result->get_error_message(), 'error' );

return array(
'result' => 'failure',
'message' => $result->get_error_message(),
);
}
} else {
wc_add_notice( $result->get_error_message(), 'error' );

return array(
'result' => 'failure',
'message' => $result->get_error_message(),
Expand Down
15 changes: 15 additions & 0 deletions includes/OrderFlow/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Exception;
use Reepay\Checkout\LoggingTrait;
use Reepay\Checkout\Tokens\ReepayTokens;
use WC_Order_Item_Fee;
use WC_Subscriptions_Manager;
use WP_Error;
Expand Down Expand Up @@ -436,6 +437,20 @@ public function process( array $data ) {
$order = rp_get_order_by_session( $data['payment_method_reference'] );
if ( $order && order_contains_subscription( $order ) ) {
WC_Subscriptions_Manager::activate_subscriptions_for_order( $order );

if(! empty( $data['payment_method'] )){
try {
$token = ReepayTokens::reepay_save_token( $order, $data['payment_method'] );
ReepayTokens::assign_payment_token( $order, $token );
ReepayTokens::save_card_info_to_order( $order, $token->get_token() );

$order->payment_complete();
} catch ( Exception $e ) {
$order->add_order_note( $e->getMessage() );
$this->log( sprintf( 'WebHook: Token save error: %s', $e->getMessage() ) );
return;
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion includes/Tokens/ReepayTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public static function get_payment_token_subscription( WC_Subscription $subscrip
$token = $order->get_meta( '_reepay_token' );
if ( empty( $token ) ) {
$invoice_data = reepay()->api( $order )->get_invoice_data( $order );
if ( ! empty( $invoice_data ) ) {
if ( ! empty( $invoice_data ) && ! is_wp_error( $invoice_data ) ) {
if ( ! empty( $invoice_data['recurring_payment_method'] ) ) {
$token = $invoice_data['recurring_payment_method'];
} elseif ( ! empty( $invoice_data['transactions'] ) ) {
Expand Down
2 changes: 1 addition & 1 deletion reepay-woocommerce-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Get a plug-n-play payment solution for WooCommerce, that is easy to use, highly secure and is built to maximize the potential of your e-commerce.
* Author: Billwerk+
* Author URI: http://billwerk.plus
* Version: 1.6.2
* Version: 1.6.3
* Text Domain: reepay-checkout-gateway
* Domain Path: /languages
* WC requires at least: 3.0.0
Expand Down
8 changes: 4 additions & 4 deletions templates/meta-boxes/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class="reepay-admin-card-logo"/>
<span class='reepay-balance__currency'>
&nbsp;
</span>
<?php echo $order_data['authorized_amount'] ? rp_make_initial_amount( $order_data['authorized_amount'] - $order_data['settled_amount'], $order_data['currency'] ) . ' ' . get_woocommerce_currency_symbol() : $order_data['authorized_amount'] . ' ' . get_woocommerce_currency_symbol(); ?>
<?php echo $order_data['authorized_amount'] ? rp_make_initial_amount( $order_data['authorized_amount'] - $order_data['settled_amount'], $order_data['currency'] ) . ' ' . get_woocommerce_currency_symbol($order->get_currency()) : $order_data['authorized_amount'] . ' ' . get_woocommerce_currency_symbol($order->get_currency()); ?>
</span>
</li>
<li class="reepay-admin-section-li">
Expand All @@ -81,7 +81,7 @@ class="reepay-admin-card-logo"/>
<span class='reepay-balance__currency'>
&nbsp;
</span>
<?php echo rp_make_initial_amount( $order_data['authorized_amount'], $order_data['currency'] ) . ' ' . get_woocommerce_currency_symbol(); ?>
<?php echo rp_make_initial_amount( $order_data['authorized_amount'], $order_data['currency'] ) . ' ' . get_woocommerce_currency_symbol($order->get_currency()); ?>
</span>
</li>

Expand All @@ -93,7 +93,7 @@ class="reepay-admin-card-logo"/>
<span class='reepay-balance__currency'>
&nbsp;
</span>
<?php echo rp_make_initial_amount( $order_data['settled_amount'], $order_data['currency'] ) . ' ' . get_woocommerce_currency_symbol(); ?>
<?php echo rp_make_initial_amount( $order_data['settled_amount'], $order_data['currency'] ) . ' ' . get_woocommerce_currency_symbol($order->get_currency()); ?>
</span>
</li>
<li class="reepay-admin-section-li">
Expand All @@ -104,7 +104,7 @@ class="reepay-admin-card-logo"/>
<span class='reepay-balance__currency'>
&nbsp;
</span>
<?php echo rp_make_initial_amount( $order_data['refunded_amount'], $order_data['currency'] ) . ' ' . get_woocommerce_currency_symbol(); ?>
<?php echo rp_make_initial_amount( $order_data['refunded_amount'], $order_data['currency'] ) . ' ' . get_woocommerce_currency_symbol($order->get_currency()); ?>
</span>
</li>

Expand Down

0 comments on commit 3214fa5

Please sign in to comment.