• User Newbie

    Paypal - aggiornamenti alla sicurezza

    Ciao a tutti, ho bisogno di un vostro aiuto/chiarimento su una mail inviata da Paypal riguardo alcuni aggiornamenti sulla sicurezza, ci sono diversi punti che fanno riferimento alla url per l'ipn che dovrà essere su protocollo HTTPS:

    [TABLE="class: cms_table"]

    [TD]"A partire da questa data, gli endpoint API Sandbox supporteranno solo il nuovo standard (HTTP/1.1, TLS 1.2 e i certificati SHA-256). Ciò significa che l'url sandbox.paypal.com accetterà solo HTTPS per i postback IPN."[/TD]
    [/TR]
    [/TABLE]

    Se ho capito bene, non ci sono modifiche da fare al codice php ma bisogna adeguare tutti i siti che utilizzano l'ipn di paypal su protocollo HTTPS, corretto? Avete ricevuto anche voi questa email?

    Qui in basso vi riporto il codice che uso in php per i messaggi IPN ricevuti da paypal (questo dovrebbe rimanere invariato):

    $raw_post_data = file_get_contents('php://input');

    $this->dump = var_export($raw_post_data, true);
    $raw_post_array = explode('&', $raw_post_data);
    $myPost = array();
    foreach ($raw_post_array as $keyval) {
    $keyval = explode('=', $keyval);
    if (count($keyval) == 2)
    $myPost[$keyval[0]] = urldecode($keyval[1]);
    }

    $req = 'cmd=_notify-validate';
    if (function_exists('get_magic_quotes_gpc')) {
    $get_magic_quotes_exists = true;
    }
    foreach ($myPost as $key => $value) {
    if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
    $value = urlencode(stripslashes($value));
    } else {
    $value = urlencode($value);
    //$value = urlencode(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
    }
    $req .= "&$key=$value";
    }
    try {
    $ch = curl_init(PAYPAL_URL);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Se c'è un proxy nel file di configurazione
    if (PROXY_CURL != "") {
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
    curl_setopt($ch, CURLOPT_PROXY, PROXY_CURL);
    }

    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 180);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    if (!($res = curl_exec($ch))) {
    $this->sendLog("Errore " . curl_error($ch) . " nella chiamata IPN a paypal");
    curl_close($ch);
    exit;
    }
    curl_close($ch);
    } catch (Exception $ex) {
    // NOTIFICO ERRORE
    }

    if (strcmp($res, "VERIFIED") == 0) {
    $item_name = $_POST['item_name'];
    $item_number = $_POST['item_number'];
    $payment_status = $_POST['payment_status'];
    $payment_amount = $_POST['mc_gross'];
    $payment_currency = $_POST['mc_currency'];
    $txn_id = $_POST['txn_id'];
    $receiver_email = $_POST['receiver_email'];
    $payer_email = $_POST['payer_email'];
    $CUSTOM = $_POST['custom'];
    $this->SaveOrder($IDORDINE, $payment_amount);
    } else if (strcmp($res, "INVALID") == 0) {
    $this->sendLog("INVALID");
    }

    Grazie in anticipo a chi si interessa al thread.
    Ciao,
    Luca


  • Admin

    In teoria mi sembra di capire che è un cambiamento lato loro che non influisce su di te.

    Quello che succederà è che andrà chiamata la versione https e non quella http che molto probabilmente farà un redirect e dunque invaliderà eventuali post.