To solve error in footbridge of payment MINT when cancelling payment

A time ago I wrote envelope how to form the footbridge of Redsys payment for WooCommerce, today I want to retake the subject to help to solve a problem you that you can find referred to the payment footbridge MINT.

The majority of stores online that I have developed has used banks that are under the Redsys company. This company that works with Banco Santander, Bankia, Bank of Sabadell and many more, has its own plugin for WooCommerce (and other platforms as Magento, Prestashop, etc.), that works perfectly. Nevertheless, sometimes, she appears a client who does not fulfill this premise and is called on to find other solutions that can give some problem.

Next I explain to you how to install the method of payment CECABANK WooCommerce and to solve a quite common problem.

To install gratuitous Virtual TPV for MINT

To date I have not found plugin official developed by MINT, reason why it is necessary to acuidar to solutions of third parties or to create plugin own with the documentation that contributes the company. In this case I decided to use plugin that you can find in GitHub and that it will help you to create this method of payment as if of any other outside.

In order to install you only must it follow the instructions that you will find in GitHub. Once installed and activated, in the adjustments of WooCommerce, under the eyelash To finalize purchase, a new called method will activate Footbridge CECABANK. It is enough with filling up the options with the data that it has facilitated to us in bank, to test pertinent in way tests and, once he is all correct one, to pass to the way production so that the users can pay by means of card.

Error when cancelling payment in the footbridge of MINT for WooCommerce

We already have our method of active payment and everything must work correctly, nevertheless a client notified me that when cancelling the payment, once we are in the footbridge of the bank, the order is processed as completed in spite of not carrying out the purchase. This is a very serious problem that must be solved immediately and, although I have not found a solution in Internet, is easy to solve at first sight.

First that we must understand it is how WooCommerce with the bank communicates to know if it must mark the phelp order as, cancelled, etc. and that is obtained by means of an answer URL sends the payment footbridge and that WooCommerce interprets. Summarizing, we can say that they exist two-way traffic that they notify the state of the payment: the one that says that everything is correct (URL_OK) and the one that says that the payment has not been completed (URL_NOK).

In this tutorial we are only going to correct the URL_NOK that is in charge to notify to WooCommerce that something fails. We will do it by means of the function get_cancel_order_url ().

Solving the error in the code of plugin

We are going to throw a look to the lines of the code that make reference to these directions:

        function get_ceca_args (to $order) \ {             $result = Array ();             $result [˜MerchantID™] = $this->merchand_id;             $result [˜AcquirerBIN™] = $this->acquirer_bin;             $result [˜TerminalID™] = $this->terminal_id; $result [˜URL_OK™] = $this->get_return_url (to $order); $result [˜URL_NOK™] = $this->get_return_url (to $order);             $result [˜Signature™] = $this->calculate_sign (to $order);             $result [˜Based™] = ˜SHA1™;             $result [˜Num_operaci³n™] = $order->id;             $result [˜Amount™] = $order->get_total () *100;             $result [˜TipoMoneda™] = $this->currency;             $result [˜Explaining™] = ˜2™;             $result [˜Pago_soportado™] = ˜SSL™;             $result [˜language™] = $this->language;             return $result;         }

As you can see in lines 7 and 8, both variables have the same value, ERROR. This S-value the one of the URL_OK, for that reason when cancelling the payment is processed as phelp. The solution? To assign the URL that marks as CANCELLED the payment the variable URL_NOK, that in WooCommerce we can obtain it thus:

            $result [˜URL_NOK™] = $order->get_cancel_order_url ();

With this modification of plugin we will obtain that when cancelling the payment is not marked as phelp in WooCommerce, but still lacks an adjustment more than we must do so that everything works correctly.

Error in the calculation of signature

I am not going to extend since the solution is very similar to the previous section. To the changed salary the value of URL_NOK, we must make it agree in the signature that is generated to process the payment. If we go away some lines more above in the code of plugin we will be able to find a function that generates the signature: calculate_sign (). We correct the code so that it is thus:

        function calculate_sign (to $order) \ {             //Clave_encriptacion+MerchantID+AcquirerBIN+TerminalID+Num_operaci³n+Importe+             //TipoMoneda+Exponente+ œSHA1 +URL_OK+URL_NOK             $signature_str = $this->password                 . $this->merchand_id                 . $this->acquirer_bin                 . $this->terminal_id                 . $order->id                 . $order->get_total () *100                 . $this->currency                 . ˜2SHA1™                 . $this->get_return_url (to $order)                 . $order->get_cancel_order_url ();             return sha1 ($signature_str);         }

This we will have ended. If everything has gone well you will be able to verify that the button to cancel now works as must: it cancels the payment and correctly is notified it to WooCommerce.

If you have followed the steps and even so you have doubts or is something fails, you do not doubt in letting a commentary to be able to make use to you.

Commentaries

  • average payment it says:

    Dear friend,

    The Url's that you indicate are simply the Url's of navigator to whom MINT notifies the answer of the payment. It does not do any more¦

    URL_OK > MINT will send by navigator a POST with the Array of values for the accepted answer.
    URL_NOK > MINT will send by navigator a POST the Array of values for the denied answer.

    According to we only observed you consider the Url's of answer by navigator to change the states of the order with reference to the payment.

    In plugins of payment of the different CMS always you must control the states of the order by the URL of callback since if petase the navigator, in the way of the bank or processor of the transaction made the commerce, the operation would have been received but the client would not detect it. With the possibility that the client tried it again and caused a duplicate.

    Greetings,

    • Wewokc he says:

      Hello,

      Indeed we are changing the answer URL since the problem is that, once we are in the footbridge, if we pressed the button to cancel, MINT sends an answer to him to the commerce of which the payment has been realised well when in fact the payment has been cancelled. As comment in the article, the URL_OK and the URL_NOK is identical, when they would have to be different if not equivocal me. The rest of the operative one does plugin correctly and it is not necessary to modify it.

      Thanks for the contribution, if you think that would be to have something in account is more thanked for info 🙂
      A greeting!

      • centinel it says:

        Hello Carlos,

        And if when you press the button œTo cancel in the footbridge, MINT sends the answer to the commerce and before being received by the commerce peta the navigator of the client?

        Redsys saves this subject with one third URL of return in which it sends a POST with the answer of the transaction in Callback for example by CURL, of servant to servant without happening through navigator. Of that form, although pete the navigator of the client, always will be the correct state in the file of the account of the client.

        MINT not as it solves this and if you have considered it, but you the comment just in case¦

        Greetings,
        Centinel

        • Wewokc he says:

          Hello Centinel,

          It is the first time that I am with a client who uses MINT and I do not know how she works in that aspect. I used this plugin and they notified the problem that arose when cancelling the payment. As I could not find no solution to this subject in particular I decided to create the post for that him outside help.

          So far they have not returned to pass incidences to me with the TPV, so so far it is worth 🙂 to me Would be necessary to look at the documentation but as one is a footbridge that rarely is going to return to use I cannot spend the time to him that would need.

          Thanks to happen to you again!
          A greeting.

          • Jesºs Guti©rrez he says:

            Hello Carlos.

            I do not know as plugin works that, but basing me on your post I comment the following thing to you.

            As Centinel says well, those urls that it is using plugin are not the correct ones to mark a conducted operation as. What passes if the user when is to him the screen of the tpv-virtual one of œdoes operation conducted correctly instead of giving the button to continue close the navigator and it doesn't give back the control to the commerce? Then I understand that the operation will be conducted but woocomerce will not have marked it as œrealised.

            For it is the URL of callback or as we called it œcommunication URL online that in addition it is a URL that plugin says that you must form

            For The comunication address the TPV is should sees something like:
            http://yourdomain.com/?wc-api=wc_gateway_ceca

            or

            https://yourdomain.com/?wc-api=wc_gateway_ceca

            This URL or communication is a call of servant to servant without the user interacts in anything and that he is only made when the operation has been realised correctly. This call is the one that must order to mark the operation in woocomerce as œrealised and not the other.

            For any consultation on the matter we are to your disposition in the email [email protected].

            Technical support TPV-Virtual Cecabank

          • Wewokc he says:

            Hello Jesus,

            You are right both all the. Recently I was with this same problem that you comment.

            Thanks for your contribution. Happy year!

  • Robert he says:

    Good,
    I have a store with woocommerce and making the changes that you propose it is resolute the problem of calculation of the signature, but when I cancel in the footbridge MINT it gives back me woocommerce as if she had made the purchase satisfactorily, osseous it does not take the URL_NOK but the URL_OK and the order deberia is processed as OK when to indicate that the transaction has been cancelled.

    Agradeceria if you could give me your opinion on the matter you,

    Gracias

  • Hello Carlos,
    to thank for this article to you in Spanish, the solution that the author in github (https://github.com/juanmirod/woocommerce-ceca-gateway/blob/master/woocommerce-ceca-gateway.php) offers is the following form:

    $result [˜URL_OK™] = $this->get_return_url (to $order);
    $result [˜URL_NOK™] = get_permalink (woocommerce_get_page_id (˜checkout™));

    Due to my little knowledge of WooCommerce not if it is just like your you propose.
    Podrias to indicate to me if it is a been worth equal solution of or you consider yours better?

    For some days a problem has arisen me and is that in spite of being realised the payment it indicates as not finalized the purchase.

    A greeting.

    • Wewokc he says:

      Hello Victorio,

      I advise to you that you follow what says the author of plugin, since I see that it has updated it months in the last. I have slope to update the article but I am with other projects for a long time that they prevent me to update the blog.

      Perhaps the problem you have it in the communication that is sent from tpv to woocommerce, is something that you must have formed from the panel of the bank. Right now I do not have by hand the panel but in the documentation you will find info (point 6):
      https://comercios.ceca.es/docs_constpv/img/manual_comercios.pdf

      The URL that you must put you specific the author of plugin in the instructions:
      https://github.com/juanmirod/woocommerce-ceca-gateway

      If you have done all this would have to work correctly.
      I hope that thus it is.

      A greeting!

It lets a commentary

To subscribe to me!

No, thanks.