souzadavi Posted July 15, 2018 Share Posted July 15, 2018 (edited) 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... Edited July 15, 2018 by souzadavi added new image attached 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted July 15, 2018 Share Posted July 15, 2018 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. 0 Quote Link to comment Share on other sites More sharing options...
souzadavi Posted July 16, 2018 Author Share Posted July 16, 2018 Kian, thanks to write back, is much better how you said. I changed the code like you said. I will wait to seed if there is any change.. But is very strange because I call only once. addInvoicePayment() thanks 0 Quote Link to comment Share on other sites More sharing options...
souzadavi Posted July 24, 2018 Author Share Posted July 24, 2018 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()}"; } } } 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted July 24, 2018 Share Posted July 24, 2018 (edited) Could it be that the callback is called two times? Try to take a look at moip_whmcs_boleto_direto_debug.txt and Utilities > Logs > Modules Logs and post here the result of a payment. Edited July 24, 2018 by Kian 0 Quote Link to comment Share on other sites More sharing options...
souzadavi Posted July 25, 2018 Author Share Posted July 25, 2018 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 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.