The premium Redsys plugin that you can find at WooCommerce.com includes its own API that you can use from any other plugin or theme for WordPress. This makes life easier for developers and gives them tools to express their ideas based on the premium plugin and Redsys.

The magic function created is WCRed() and through it, you can obtain a lot of information, which will increase in future versions.

WCRed()->get_order( $order_id );

It is used to get $order

WCRed()->get_ds_error();

Returns an Array() with all DS errors and what they are.

WCRed()->get_ds_response();

Returns an Array() with all DS response codes and what they mean.

WCRed()->get_msg_error();

Returns an Array() with all msg errors and what they mean.

WCRed()->is_ds_error( $error_code = null );

You must pass the error, and it returns true or false depending on whether it is a DS error or not.

WCRed()->is_ds_response( $error_code = null );

You must pass the message, and it returns true or false depending on whether it is a DS response or not.

WCRed()->is_msg_error( $error_code = null );

You must pass the msg, and it returns true or false depending on whether it is a msg error or not.

WCRed()->get_msg_error_by_code( $error_code = null );

You must pass the message, and it returns what it means if it is a msg error. If it is not, it returns false.

WCRed()->get_error_by_code( $error_code = null );

You must pass the DS error, and it returns what it means if it is a DS error. If it is not, it returns false.

WCRed()->get_response_by_code( $error_code = null );

You must pass the DS response, and it returns what it means if it is a DS message. If it is not, it returns false.

WCRed()->is_redsys_error( $error_code = null );

You pass the error or response, and it returns true or false depending on whether it is a Redsys error or not.

WCRed()->get_error( $error_code = null );

You pass the DS error, the msg error, or the DS response, and it returns what it means. It is not necessary to specify what it is. If it is none of the above, it returns false.

WCRed()->get_error_type( $error_code = null );

You pass the error, and it returns the type it is:

  • ds_error
  • ds_response
  • msg_error
WCRed()->get_currencies();

Returns an Array() with all the currencies of Redsys and their codes.

WCRed()->allowed_currencies();

Returns an Array() with the currencies allowed in Redsys. Being allowed does not mean they are active on the terminal.

WCRed()->get_redsys_languages();

Returns an array with the languages and their codes. The languages are not codes, that is, for example in the Array() is Español, English – Inglés, Català, Français – Frances, and each one related to its code in Redsys.

WCRed()->get_redsys_wp_languages();

Returns an Array() with all the language codes of WordPress, related to the code in Redsys.

WCRed()->get_orders_type();

Returns an Array() with the different payment methods of Redsys possible through the plugin.

WCRed()->get_lang_code( $lang = 'en' );

You pass the language code, and it returns the code of this in Redsys. You can pass both standardized code (es, fr, en, etc.), and WordPress code (es_ES, ca, en_US, en, en_GB).

If the language does not exist in Redsys, it will always return “2”, which is the code for English.

WCRed()->order_exist( $order_id );

You pass the order ID, and it tells you if the order exists, returning true or false.

WCRed()->post_exist( $post_id );

You pass the ID of the $POST, and it tells you if it exists. Note, it can be any Post, Post Type, or Custom Post Type, it only tells you if it exists.

WCRed()->is_redsys_order( $order_id, $type = null );

You can pass one parameter, or two. If you only pass the first parameter (the order ID), it will tell you if the order was made through Redsys in any of the payment methods that the plugin adds, returning true or false. If you pass along with the second parameter, it will respond true or false, depending on whether the payment was made through this specific type of payment.

The possible values for $type are:

  • redsys
  • masterpass
  • redsysbank
  • bizumredsys
  • iupay
  • insite
  • redsyspreauthorizations
WCRed()->get_gateway( $order_id );

You pass the order ID, and it returns the ID of the gateway with which it was paid. If the order ID does not exist, it returns false.

WCRed()->get_order_date( $order_id );

You pass the order ID, and it returns the payment date in Redsys. If there is no date, or it is not a Redsys payment, it returns false.

WCRed()->get_order_hour( $order_id );

You pass the order ID, and it returns the payment hour in Redsys. If there is no hour, or it is not a Redsys payment, it returns false.

WCRed()->get_order_auth( $order_id );

You pass the order ID, and it returns the authentication code of the payment in Redsys. If there is no code, or it is not a Redsys payment, it returns false.

WCRed()->get_status_pending();

Returns an Array() with the possible pending payment statuses that the Redsys and WooCommerce plugin adds.

apply_filters( 'redsys_status_pending', $status );

This filter found within WCRed()->get_status_pending() serves to easily add more statuses if necessary and for the function WCRed()->get_status_pending() to return the correct pending statuses.

WCRed()->is_paid( $order_id );

You pass the order ID, and it tells you if it is paid or not.

WCRed()->get_redsys_option( $option, $gateway );

You must pass the option you want to know about, and the ID of the gateway (whichever it is). It returns the value of the option.

WCRed()->is_gateway_enabled( $gateway );

You pass the gateway ID, and it returns true or false depending on whether it exists and is enabled or not.

WCRed()->check_if_token_is_valid( $token_id );

Checks if a token with the ID $token_id is valid (checks the expiration date of the card). If it is valid, it returns “true”, if it is not valid (expired date), it deletes it and returns false.

WCRed()->get_redsys_users_token();

Returns the Redsys token of the user identified on the site.

WCRed()->get_users_token_bulk( $user_id );

Returns the token of a user by ID. You must pass the value $user_id.

WCRed()->prepare_order_number( $order_id );

Prepares the order number to be sent to Redsys.

WCRed()->clean_order_number( $ordernumber );

Converts the order number sent to Redsys to the WooCommerce number.

WCRed()->redsys_amount_format( $total );

Converts the total to be paid into Redsys format.

WCRed()->set_txnid( $token_num, $redsys_txnid );

Saves the TXNID code. You must pass the token we want to relate it to and the TXNID.

WCRed()->get_txnid( $token_num );

Recovers the TXNID code, you must pass the token from which we want to recover it.

¡No te pierdas las novedades!

¡No hacemos spam! y te puedes dar de baja cuando quieras