Jump to content
  • 0

Process payment received from txt file


ZoukLover

Question

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

  • 0

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" . 

Link to comment
Share on other sites

  • 0
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?

Link to comment
Share on other sites

  • 0
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

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
Answer this question...

×   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