Display error message if Pro Sites user credit card is declined or incorrect

Hello! I have been testing out the Pro Sites plugin and would like to know how I can display an error message to a user if he/she credit card is declined or incorrect. As of right now when I am testing it, the payment form just reappears without any notice to the user. For that reason, I would like to know how I can insert some custom php into the functions.php file or stripe-gateway.php file so that it can display this message. If you have any other discussions / code on this matter please let me know. Thank you :slight_smile:

  • James Morris

    Hello Rachel,

    I hope you are well today.

    Pro Sites does include error responses for various situations. For example, the following test was performed with an invalid card number.

    If you're not seeing something like the above, there may be an issue with your setup that's causing issues. May I have access to your site so I can run some tests?

    You can learn how to grant WPMU DEV Support Access at the following link:


    Please reply back here once you've enabled access so I will be notified.

    Best regards,

    James Morris

  • Rachel

    Hello James, I understand that it displays some error responses but if I enter in either an invalid credit card number, expiration date, and/or security code the page will just refresh and not provide the user any details why the transaction didn't process correctly. For that reason, I would like to insert some if / else statements so that if the card number, expiration date, and/or security code is incorrect it can display to the user what is going on. Please let me know how I can do this or any articles / code that you can provide me. Thank you :slight_smile:

  • James Morris

    Hello Rachel,

    Hmmm... I tested this using Stripe's credit card numbers that are designed to generate the errors you mentioned and all my tests produced the correct error responses. There's no articles or code snippets to provide because these are included in the plugin itself.

    If this is not working correctly on your site, there may be something that's interfering. Would you mind providing me access to your site so I can take a closer look and see why you're not getting the same results?

    Best regards,

    James Morris

  • Panos

    Hi Rachel ,

    Pro Sites does a first check before submit where it checks if the cc number is correct and if expiration date and ccv are valid, more precisely date is not set in the past and ccv contains a valid number of digits. At this point it doesn't check if date and ccv are correct for the specific cc number, this is done after submit.

    So if one of the above is wrong it won't submit and it should display a message for each case like in the following screenshot:

    In the screenshot above I have used an invalid cc numbe, a date set to past and only one digit in ccv so you see the according notifications.

    In case that the cc number is correct and date is not in past and ccv digits are in the set boundary the form should submit and this info will be validated for errors or fraud on stripe and will return a failure response. If it fails, pro site should display a message like the following:

    Could you please confirm if this is the part you are referring to ?

    Is the issue that you do not see this message at all or that you want it to contains further information?

    If you need more information displayed there, I would recommend against it for security reasons. However you can add this kind of information by editing file
    and replace line ~2093
    $psts->errors->add( 'general', __( 'The Stripe customer could not be created. Please try again.', 'psts' ) );
    with something like the following:

    $e_json = json_encode( $e );
    						$e_array = json_decode( $e_json );
    						$error_code = isset( $e_array->jsonBody->error->code ) ? $e_array->jsonBody->error->code : '';
    						$error_msg = isset( $e_array->jsonBody->error->message ) ? $e_array->jsonBody->error->message : '';
    						switch( $error_code ){
    							case 'expired_card' : $error_msg = __( 'Your card seems to be expired', 'psts' );break;
    							case 'incorrect_cvc' : $error_msg = __( 'Please check your CSV', 'psts' );break;
    						$error_msg_out = __( 'The Stripe customer could not be created.', 'psts' );
    						if( $error_code != '' ) $error_msg_out .= '<p>' . $error_msg . '</p>';
    						$error_msg_out .= '<p>' . __( 'Please try again', 'psts' ) . '</p>';
    						$psts->errors->add( 'general', $error_msg_out );


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.