dansmaculotte/monetico-php

Closed Thread

Closed this issue · 9 comments

Closed Thread

Hi,

MAC field is a generated string from payment information and security key.
Could you detail your usage ?

MAC is generated by generateSeal method.
To understant of Monetico works you should read their documentation.

You don't have to use directly the generateSeal method.
You don't have to use getUsableKey either, but to answer to your question it is needed every time it is used MAC for generation and MAC validation.

It comes from Monetico, they want your security formated that way to generate seal and to validate seal. I didn't produce this code, it comes from their code example.

Hi !
Monetico send everything to your CGI URL in POST.
So to get the vars, you just have to write $_POST['bincb'].

First, you must regenerate the monetico object (like the exemple given) :

use DansMaCulotte\Monetico\Monetico;

$monetico = new Monetico(
    'EPT_CODE',
    'SECURITY_KEY',
    'COMPANY_CODE',
    'RETURN_URL',
    'RETURN_SUCCESS_URL',
    'RETURN_ERROR_URL'
);

Then, you build the data array, like this :

$data = [
                    'date' => $_POST['date'],
                    'amount' => $_POST['montant'],
                    'reference' => $_POST['reference'],
                    'MAC' => $_POST['MAC'],
                    'texte-libre' => $_POST['texte-]ibre'),
                    'code-retour' => $_POST['code-]etour'),
                    'cvx' => $_POST['cvx'],
                    'vld' => $_POST['vld'],
                    'brand' => $_POST['brand'],
                    'status3ds' => $_POST['status3ds'],
                    'numauto' => $_POST['numauto'],
                    'originecb' => $_POST['originecb'],
                    'bincb' => $_POST['bincb'],
                    'hpancb' => $_POST['hpancb'],
                    'ipclient' => $_POST['ipclient'],
                    'originetr' => $_POST['originetr'],
                    'veres' => $_POST['veres'] ?: "",
                    'pares' => $_POST['pares'] ?: ""
                ];

You create a Response object :

$response = new \DansMaCulotte\Monetico\Payment\Response($data);

You validate the seal :

$result = $monetico->validateSeal($response);

You generate the expected receipt :

$receipt = new \DansMaCulotte\Monetico\Payment\Receipt($result);

If you want to do specific stuff, now you just have to test the response code :

if ('payetest' == $response->returnCode || 'paiement' == $response->returnCode) {
  // do stuff if payment is ok
}
else {
  // do other stuff if payment went wrong
}

Print the receipt value just by doing this :

echo $receipt;
die;

And you are done :D

Totally. It's not the best system to work with. A lot of things must be sent directly to the bank.
Your work MUST BE online so their server can call it. If you are on localhost, they cannot reach it and they cannot deploy your account into production mode.

Put your website online for the payment tests and once your payment system is okay, ask for production deployment (make sure you made 3 test payments with correct receipts as the doc ask). Wait for the approval and once you got it, put the website offline and keep working on localhost.
Everything will be ready for the "real launch" ;)

Thanks for answering @LupusVII ! @Ganduras You can use ngrok or localtunnel to make it work locally. I use ngrok !

Hi @LupusVII,

In your code, MAC is received from post?
I've submit the form but Monetico says the MAC is not correct.
Please explain in detail.

Hi @lovecoding-git
There is not a lot more to explain. Monetico says send you a POST request on the URL set up (last time I did it, I had to tell them the URL by email, there is no field to set up it in there backend).
I think you do not have an issue with this step but maybe with the previous one? When you generate the payment form?

Also, it might be best to create a new issue than reopening an old one :)