Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set order status to failed for testing failed recurring payments. #40

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' ) );
}
}
}