1
votes

I tried to install Paypal on my Symfony web site.

This is my code:

class PayementController extends Controller
{
    function paypalAction($prixTotal){

        $cancelRoute = $this->generateUrl('billeterie_pay_paypal_cancel', array(), true);

        $returnRoute = $this->generateUrl('billeterie_pay_paypal_return', array(), true);

        $params = array(
            'METHOD' => 'SetExpressCheckout',
            'VERSION' => '76.0',
            'USER' => 'seller123456798_api1.gmail.com',
            'SIGNATURE' => 'AFcWxV21C7fd0v3bYYYRCpSSRl31Aqq5fPDuu-qIHvMKNlMc7oPZk2dK',
            'PASSWORD' => 'QVVQD74PBGQ3CR3X',
            'RETURNURL' => $returnRoute,
            'CANCELURL' => $cancelRoute,
            'LOCALECODE' => 'FR',
            'PAYMENTREQUEST_0_AMT' => $prixTotal,
            'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR'
        );
        $params = http_build_query($params);
        $endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
        $curl = curl_init();
        curl_setopt_array($curl, array(
            CURLOPT_URL => $endpoint,
            CURLOPT_POST => 1,
            CURLOPT_POSTFIELDS => $params,
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => false,
            CURLOPT_VERBOSE => 1
        ));
        $response = curl_exec($curl);
        $responseArray = array();
        parse_str($response, $responseArray);
        var_dump($responseArray);
        curl_close($curl);
        die();
    }

    function paypalCancelAction(){
        $session = $request->getSession();
        $session->getFlashBag()->add('alert', "Payement annulé !");
        $url = $this->get('router')->generate('billeterie');
        return new RedirectResponse($url);
    }

    function paypalReturnAction(){
        $session = $request->getSession();
        $session->getFlashBag()->add('alert', "Payement annulé !");
        $url = $this->get('router')->generate('billeterie');
        return new RedirectResponse($url);
    }
}

But when I go on this page I get this error message:

array(9) { ["TIMESTAMP"]=> string(20) "2016-04-27T15:40:34Z" ["CORRELATIONID"]=> string(13) "20d63d09b7a52" ["ACK"]=> string(7) "Failure" ["VERSION"]=> string(4) "76.0" ["BUILD"]=> string(8) "21669447" ["L_ERRORCODE0"]=> string(5) "10002" ["L_SHORTMESSAGE0"]=> string(14) "Security error" ["L_LONGMESSAGE0"]=> string(28) "Security header is not valid" ["L_SEVERITYCODE0"]=> string(5) "Error" }

PS : I know I don't have to share API & Mail but since this is only a school projet I don't really care.

I'm trying it on a local wamp server.

1

1 Answers

1
votes

I'm trying it on a local wamp server.

You can't. When Your website call Paypal, Paypal try to call your website. If it's in your wampserver, Paypal can't call your website. So it's a failure.

Try this in a webserver :)

EDIT:: And don't put your login / password into your code ;)