Skip to content

Commit

Permalink
Merge pull request #306 from reepay/dev
Browse files Browse the repository at this point in the history
v 1.6.3 - Woocommerce zero payment fixes
  • Loading branch information
markusbrunke authored Jan 8, 2024
2 parents 055ae5d + 4425989 commit a9a5358
Show file tree
Hide file tree
Showing 16 changed files with 172 additions and 150 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
1 change: 1 addition & 0 deletions assets/images/svg/mobilepay.logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
22 changes: 16 additions & 6 deletions includes/Actions/Subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ public function update_failing_payment_method( WC_Subscription $subscription, WC
public function delete_resubscribe_meta( WC_Order $resubscribe_order ) {
if ( in_array( $resubscribe_order->get_payment_method(), self::PAYMENT_METHODS, true ) ) {
// Delete tokens.
delete_post_meta( $resubscribe_order->get_id(), '_payment_tokens' );
delete_post_meta( $resubscribe_order->get_id(), '_reepay_token' );
delete_post_meta( $resubscribe_order->get_id(), '_reepay_token_id' );
$resubscribe_order->delete_meta_data( '_payment_tokens' );
$resubscribe_order->delete_meta_data( '_reepay_token' );
$resubscribe_order->delete_meta_data( '_reepay_token_id' );
$resubscribe_order->save_meta_data();
}
}

Expand Down Expand Up @@ -256,7 +257,8 @@ public function save_subscription_payment_meta( WC_Subscription $subscription, s
// Add tokens.
foreach ( explode( ',', $meta_value ) as $reepay_token ) {
ReepayTokens::assign_payment_token( $subscription, $reepay_token );
update_post_meta( $subscription->get_id(), 'reepay_token', $reepay_token );
$subscription->update_meta_data( 'reepay_token', $reepay_token );
$subscription->save_meta_data();
}
}
}
Expand Down Expand Up @@ -362,6 +364,12 @@ public function scheduled_subscription_payment( float $amount_to_charge, WC_Orde
throw new Exception( $result->get_error_message(), $result->get_error_code() );
}

// Fix for subscriptions can create the invoice.
sleep( 5 );
if ( $renewal_order->get_status() === 'pending' ) {
sleep( 5 );
}

// Instant settle.
do_action( 'reepay_instant_settle', $renewal_order );
} catch ( Exception $e ) {
Expand Down Expand Up @@ -467,7 +475,7 @@ public function save_new_payment_method_option_html( string $html, WC_Payment_Ga
*/
public function create_sub_invoice( int $order_id, string $this_status_transition_from, string $this_status_transition_to, WC_Order $instance ) {
$renewal_order = wc_get_order( $order_id );
$renewal_sub = get_post_meta( $order_id, '_subscription_renewal', true );
$renewal_sub = $renewal_order->get_meta( '_subscription_renewal' );
$gateway = rp_get_payment_method( $renewal_order );
if ( ! empty( $renewal_sub ) && ! empty( $gateway ) ) {
$order_data = reepay()->api( $gateway )->get_invoice_data( $renewal_order );
Expand Down Expand Up @@ -498,7 +506,9 @@ public function create_sub_invoice( int $order_id, string $this_status_transitio
*/
public function sync_reepay_token_meta( int $meta_id, int $post_id, string $meta_key, $meta_value ) {
if ( 'reepay_token' === $meta_key ) {
update_post_meta( $post_id, '_reepay_token', $meta_value );
$order = wc_get_order( $post_id );
$order->update_meta_data( '_reepay_token', $meta_value );
$order->save_meta_data();
}
}
}
Loading

0 comments on commit a9a5358

Please sign in to comment.