Skip to content

Commit

Permalink
Merge pull request #305 from reepay/dimaspolohov
Browse files Browse the repository at this point in the history
v 1.6.3 - Woocommerce zero payment fixes
  • Loading branch information
dimaspolohov authored Dec 28, 2023
2 parents 3214fa5 + a12e64e commit 7007816
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 121 deletions.
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.
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 7007816

Please sign in to comment.