Skip to content

Commit

Permalink
Merge pull request #40 from peterwilsoncc/fix/38-failed-order-status
Browse files Browse the repository at this point in the history
Set order status to failed for testing failed recurring payments.
  • Loading branch information
PanosSynetos authored May 22, 2024
2 parents 87107d0 + 554d535 commit 7ebed98
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions includes/class-wc-gateway-dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,9 @@ public function init_form_fields() {
public function process_payment( $order_id ) {

$payment_result = $this->get_option( 'result' );
$order = wc_get_order( $order_id );

if ( 'success' === $payment_result ) {
$order = wc_get_order( $order_id );

$order->payment_complete();

// Remove cart
Expand All @@ -149,6 +148,7 @@ public function process_payment( $order_id ) {
);
} else {
$message = __( 'Order payment failed. To make a successful payment using Dummy Payments, please review the gateway settings.', 'woocommerce-gateway-dummy' );
$order->update_status( 'failed', $message );
throw new Exception( $message );
}
}
Expand All @@ -166,8 +166,7 @@ public function process_subscription_payment( $amount, $order ) {
if ( 'success' === $payment_result ) {
$order->payment_complete();
} else {
$message = __( 'Order payment failed. To make a successful payment using Dummy Payments, please review the gateway settings.', 'woocommerce-gateway-dummy' );
throw new Exception( $message );
$order->update_status( 'failed', __( 'Subscription payment failed. To make a successful payment using Dummy Payments, please review the gateway settings.', 'woocommerce-gateway-dummy' ) );
}
}
}

0 comments on commit 7ebed98

Please sign in to comment.