Jump to content

Callback confirm payment twice in MOIP


Recommended Posts

Hello I did a small script to work with gateway MOIP (pagamento direto), but one thing very strange is happening, the payment it's confirmed twice or more by WHMCS system, the full script is at: https://bitbucket.org/linknacional/moip_boleto_direto/src/master/modules/gateways/moip_whmcs_boleto_direto/callback/moip_whmcs_boleto_direto.php

The payment confirmation it's happening at same time, date, hour and seconds is the same.

I tried supporting from WHMCS team, but without success. Any help here will be very nice.

Below is the code wich getting payment duplication. I can't find why the payment is duplicating.

 if($status == "PAID"){
            try{
                foreach (Capsule::table('tblinvoices')->select('status')->where('id', '=', $invoiceId)->get() as $statusInvoice){
                    if($statusInvoice->status == "Unpaid" && $success == true){
                        addInvoicePayment($invoiceId,$transactionId,$paymentAmount,$paymentFee,$gatewayParams["name"]);
                        $status = false;
                        $success = false;
                    }
                }
            }catch (\Exception $e) {
                echo "I couldn't get invoice status. {$e->getMessage()}";
            }

        }

 

 

PS: attached the invoice transaction log.

 

THANKs in advance...

Screenshot from 2018-07-15 00-13-14.png

Edited by souzadavi
added new image attached
Link to comment
Share on other sites

I could be wrong but I have a feeling that this part of code is not correct.

foreach (Capsule::table('tblinvoices')->select('status')->where('id', '=', $invoiceId)->get() as $statusInvoice)

Why are you running the query in the foreach? This query always return a single record since you are selecting an unique ID. There can't be more than one record with the same ID in tblinvoices. Personally I would use ->first() instead of ->get() removing the foreach. Anyway I don't think that this is the cause the problem but it's a start.

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Didn't work, the gateway still confirmed twice or more by WHMCS system... very strange!!! the deal is there no answers from whmcs team.    :(

 

  if ($success) {
        if($status == "PAID"){
           try{
                $statusInvoice = Capsule::table('tblinvoices')->select('status')->where('id', '=', $invoiceId)->first();
                if($statusInvoice->status == "Unpaid" && $success == true){
                    addInvoicePayment($invoiceId,$transactionId,$paymentAmount,$paymentFee,$gatewayParams["name"]);
                    $status = false;
                    $success = false;
                }
            }catch (\Exception $e) {
                echo "I couldn't get invoice status. {$e->getMessage()}";
            }  
        }
    }

 

Link to comment
Share on other sites

The callback file give the log duplicated,  look couple of log in moip_wmcs_boleto_direto.txt..........

Yesterday a talk to the gateway payment, and they said the callback file is calling twice or more... they will try to fix it.... thanks for your attention Kian :)

 

-----------------------------------
Status: PAID Data: 26/06/2018 04:30:29Valor Adicionado na Invoice:10531
Adicionado o Pagamento
-----------------------------------
NAME GATEWAYArray
(
  remove the parameters []
)
Data: 26/06/2018 04:30:29
PAID1
-----------------------------------
Status: PAID Data: 26/06/2018 04:30:29Valor Adicionado na Invoice:10531
Adicionado o Pagamento
-----------------------------------
NAME GATEWAYArray
(
  remove the parameters []
)
Data: 26/06/2018 04:30:29
PAID1
-----------------------------------
Status: PAID Data: 28/06/2018 03:20:10Valor Adicionado na Invoice:10637
Adicionado o Pagamento
-----------------------------------
NAME GATEWAYArray
(
      remove the parameters []
)
Data: 28/06/2018 03:20:10
PAID1
-----------------------------------
Status: PAID Data: 28/06/2018 03:20:10Valor Adicionado na Invoice:10637
Adicionado o Pagamento
-----------------------------------
NAME GATEWAYArray
(
  remove the parameters []
)
Data: 28/06/2018 03:20:10
PAID1

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated