lexik / LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system
MIT License
40 stars 47 forks source link

Problème d'identification du commerce. Accès refusé ! #86

Closed ShapesGraphicStudio closed 7 years ago

ShapesGraphicStudio commented 7 years ago

Hello,

I'm trying to connect with PayBox Test platform but I get : Problème d'identification du commerce. Accès refusé !

app/config/config.yml :

...
# Lexik Paybox Bundle
lexik_paybox:
    parameters:
        production: false
        site:        '********'
        rank:        '**'
        login:       '********'
        currencies:
            - '978'
        hmac:
            algorithm: SHA512
            key: '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF'

vendor/lexik/paybox-bundle/Controller/SampleController.php :

<?php

namespace Lexik\Bundle\PayboxBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
 * Class SampleController
 *
 * @package Lexik\Bundle\PayboxBundle\Controller
 *
 * @author Lexik <dev@lexik.fr>
 * @author Olivier Maisonneuve <o.maisonneuve@lexik.fr>
 */
class SampleController extends Controller
{
    /**
     * Index action creates the form for a payment call.
     *
     * @return Response
     */
    public function indexAction()
    {
        $paybox = $this->get('lexik_paybox.request_handler');
        $paybox->setParameters(array(
            'PBX_CMD'          => 'CMDWEBCAMHD'.time(),
            'PBX_DEVISE'       => '978',
            'PBX_PORTEUR'      => 'test@paybox.com',
            'PBX_RETOUR'       => 'Mt:M;Ref:R;Auto:A;Erreur:E',
            'PBX_TOTAL'        => '1000',
            'PBX_TYPEPAIEMENT' => 'CARTE',
            'PBX_TYPECARTE'    => 'CB',
            'PBX_EFFECTUE'     => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'success'), UrlGeneratorInterface::ABSOLUTE_PATH),
            'PBX_REFUSE'       => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'denied'), UrlGeneratorInterface::ABSOLUTE_PATH),
            'PBX_ANNULE'       => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'canceled'), UrlGeneratorInterface::ABSOLUTE_PATH),
            'PBX_RUF1'         => 'POST',
            'PBX_REPONDRE_A'   => $this->generateUrl('lexik_paybox_ipn', array('time' => time()), UrlGeneratorInterface::ABSOLUTE_PATH),
        ));

        return $this->render(
            'LexikPayboxBundle:Sample:index.html.twig',
            array(
                'url'  => $paybox->getUrl(),
                'form' => $paybox->getForm()->createView(),
            )
        );
    }

    /**
     * Return action for a confirmation payment page on which the user is sent
     * after he seizes his payment informations on the Paybox's platform.
     * This action might only containts presentation logic.
     *
     * @param Request $request
     * @param string  $status
     *
     * @return Response
     */
    public function returnAction(Request $request, $status)
    {
        return $this->render('LexikPayboxBundle:Sample:return.html.twig', array(
            'status'     => $status,
            'parameters' => $request->query,
        ));
    }
}

My form source code shows :

<form action="https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi" method="post">
<input type="hidden" name="PBX_ANNULE" value="/payment/return/canceled" />
<input type="hidden" name="PBX_CMD" value="CMD1501862323" />
<input type="hidden" name="PBX_DEVISE" value="978" />
<input type="hidden" name="PBX_EFFECTUE" value="/payment/return/success" />
<input type="hidden" name="PBX_HASH" value="SHA512" />
<input type="hidden" name="PBX_IDENTIFIANT" value="1686319" />
<input type="hidden" name="PBX_PORTEUR" value="test@paybox.com" />
<input type="hidden" name="PBX_RANG" value="32" />
<input type="hidden" name="PBX_REFUSE" value="/payment/return/denied" />
<input type="hidden" name="PBX_REPONDRE_A" value="/payment-ipn/1501862323" />
<input type="hidden" name="PBX_RETOUR" value="Mt:M;Ref:R;Auto:A;Erreur:E;Sign:K" />
<input type="hidden" name="PBX_RUF1" value="POST" />
<input type="hidden" name="PBX_SITE" value="1999888" />
<input type="hidden" name="PBX_TIME" value="2017-08-04T17:58:43+02:00" />
<input type="hidden" name="PBX_TOTAL" value="1000" />
<input type="hidden" name="PBX_TYPECARTE" value="CB" />
<input type="hidden" name="PBX_TYPEPAIEMENT" value="CARTE" />
<input type="hidden" name="PBX_HMAC" value="6AA01789164B30458DD38535B9902CD94501CA9D9DD057C48CFD1BFC653DE10F17104568A772264C571DFC8E394FAC1F49CBF2B660ACE0C3F43B393F6AA243EE" />
<input type="submit" />
</form>

Any idea on what I could have wrong here please ?

Best regards, David

ShapesGraphicStudio commented 7 years ago

Seems like the problem came from :

'PBX_EFFECTUE'     => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'success'), UrlGeneratorInterface::ABSOLUTE_PATH),
'PBX_REFUSE'       => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'denied'), UrlGeneratorInterface::ABSOLUTE_PATH),
'PBX_ANNULE'       => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'canceled'), UrlGeneratorInterface::ABSOLUTE_PATH),
...
'PBX_REPONDRE_A'   => $this->generateUrl('lexik_paybox_ipn', array('time' => time()), UrlGeneratorInterface::ABSOLUTE_PATH),

Which returned : MYchoix_pagepaiement_ip.cgi[5.5.19][20649]: ERROR: Le format de PBX_ANNULE n'est pas accepté : /payment/return/canceled MYchoix_pagepaiement_ip.cgi[5.5.19][20649]: ERROR: Le format de PBX_EFFECTUE n'est pas accepté : /payment/return/success MYchoix_pagepaiement_ip.cgi[5.5.19][20649]: ERROR: Le format de PBX_REFUSE n'est pas accepté : /payment/return/denied MYchoix_pagepaiement_ip.cgi[5.5.19][20649]: ERROR: Le format de PBX_REPONDRE_A n'est pas accepté : /payment-ipn/1501864280

So I changed code to :

'PBX_EFFECTUE'     => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'success'), UrlGeneratorInterface::ABSOLUTE_URL),
'PBX_REFUSE'       => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'denied'), UrlGeneratorInterface::ABSOLUTE_URL),
'PBX_ANNULE'       => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'canceled'), UrlGeneratorInterface::ABSOLUTE_URL),
...
'PBX_REPONDRE_A'   => $this->generateUrl('lexik_paybox_ipn', array('time' => time()), UrlGeneratorInterface::ABSOLUTE_URL),

With the help from : http://api.symfony.com/2.3/Symfony/Component/Routing/Generator/UrlGeneratorInterface.html

Hope I'm right and that it may help others. Best regards, David

acidjames commented 7 years ago

Hi David,

in your last reply, i can't seem to find a difference in the second code you pasted.

i've edited your first post with *** because i don't remember if those were the demo-platform credentials (just as a security, never post your login or rank)

anyway, my configuration is based on 2 files :

config_prod.yml : this file contains my paybox production credentials config_dev.yml : this file contains the paybox demo credentials

i think it's by default on symfony2, when you go to app_dev.php it loads config_dev.yml and the other one for production obviously, are you familiar with that ?

acidjames commented 7 years ago

Here is my config_dev.yml with the good demo credentials

lexik_paybox:
    parameters:
        # Site number provided by the bank
        site:  '1999888'
        # Rank number provided by the bank
        rank:  '32'
        # Customer's login provided by Paybox
        login: '2'
        hmac:
            # Key used to compute the hmac hash, provided by Paybox
            key: '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF'
ShapesGraphicStudio commented 7 years ago

Hi, thanks for the answer.

In my code, I changed : UrlGeneratorInterface::ABSOLUTE_PATH to : UrlGeneratorInterface::ABSOLUTE_URL

So now the generateUrl part starts with http:// or https:// like PayBox support asked, otherwise I had : Le format de PBX_ANNULE n'est pas accepté.

I posted the credentials because they were from the PayBox test platform, I thought they might not be right, but that was not the problem.

acidjames commented 7 years ago

Thanks David

That was my mistake in the documentation, i've commited your suggestion in 92d55f80bad30a4bfca1ca9fdb4ea347025c59ce

Take care