ZoukLover Posted April 10, 2019 Share Posted April 10, 2019 Dear, After the customer pays an invoice the bank sends a txt file that I can read I have created the following code and pu ton modules/gateways/callback/module_name.php. A cron task is run every 5 minutes for this file $data = array( 'datepaid' => $fileData[0], 'status' => 'Paid', 'paymentmethod' => 'simo', 'notes' => '', ); $update = Capsule::table('tblinvoices')->where('reference_number', '=',$fileData[1])->update($data); $invoice_id = Capsule::table('tblinvoices')->where('tblinvoices.reference_number',$fileData[1])->first(); $montante_pago=$fileData[2]; $transactionId = date("Ymdhms"); addInvoicePayment($invoice_id->id,$transactionId, $montante_pago, '0', 'simo'); logTransaction('simo',array('transactionId'=>$transactionId,'amount'=>$montante_pago,'fee'=>'0','invoiceid'=>$invoice_id->id),"Successful"); The invoice is marked as paid normally and a transaction is registered. I have 2 questions? 1 - How do I avoid having duplicated transactions? I believe I need to use another transaction_id 2 - How do I unsuspend the service after checking the customer has paid all invoices from this service? Kind Regards 0 Quote Link to comment Share on other sites More sharing options...
0 steven99 Posted April 10, 2019 Share Posted April 10, 2019 1> Don't do the first query where you update, as you're effectively doing the same thing addinvoicepayment does and that may not fire hooks and other events where the addinvoicepayment would. 2> For automated unsuspend, WHMCS admin -> Setup menu -> Automation settings -> Automatic Module Functions section -> check "Enable Unsuspension" . 0 Quote Link to comment Share on other sites More sharing options...
0 Kian Posted April 10, 2019 Share Posted April 10, 2019 8 hours ago, ZoukLover said: 1 - How do I avoid having duplicated transactions? I believe I need to use another transaction_id As soon as you "use" a file delete it so that it can't be processed twice. Anyway there could be more than this. Maybe I'm paranoid but usually Gateways give you an unique hash or something similar that can be "resolved" to make sure that transactions are unique and legit. I mean what if someone starts uploading fabricated files to cheat you and register tons of domains? 0 Quote Link to comment Share on other sites More sharing options...
0 ZoukLover Posted April 11, 2019 Author Share Posted April 11, 2019 3 hours ago, steven99 said: 1> Don't do the first query where you update, as you're effectively doing the same thing addinvoicepayment does and that may not fire hooks and other events where the addinvoicepayment would. 2> For automated unsuspend, WHMCS admin -> Setup menu -> Automation settings -> Automatic Module Functions section -> check "Enable Unsuspension" . Dear, Thanks for the reply I have removed the first query and it is working. But still not unsuspending the service as needed. I will wait for the next payment to see how it goes The automated unsuspension setting it already activated Regards 0 Quote Link to comment Share on other sites More sharing options...
0 steven99 Posted April 11, 2019 Share Posted April 11, 2019 Check the activity logs for any errors relating to unsuspending the service. The module log under utilities -> logs may also help. 0 Quote Link to comment Share on other sites More sharing options...
Question
ZoukLover
Dear,
After the customer pays an invoice the bank sends a txt file that I can read
I have created the following code and pu ton modules/gateways/callback/module_name.php.
A cron task is run every 5 minutes for this file
$data = array(
'datepaid' => $fileData[0],
'status' => 'Paid',
'paymentmethod' => 'simo',
'notes' => '',
);
$update = Capsule::table('tblinvoices')->where('reference_number', '=',$fileData[1])->update($data);
$invoice_id = Capsule::table('tblinvoices')->where('tblinvoices.reference_number',$fileData[1])->first();
$montante_pago=$fileData[2];
$transactionId = date("Ymdhms");
addInvoicePayment($invoice_id->id,$transactionId, $montante_pago, '0', 'simo');
logTransaction('simo',array('transactionId'=>$transactionId,'amount'=>$montante_pago,'fee'=>'0','invoiceid'=>$invoice_id->id),"Successful");
The invoice is marked as paid normally and a transaction is registered.
I have 2 questions?
1 - How do I avoid having duplicated transactions? I believe I need to use another transaction_id
2 - How do I unsuspend the service after checking the customer has paid all invoices from this service?
Kind Regards
Link to comment
Share on other sites
4 answers to this question
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.