IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Apache Discussion :

[OpenSSL] _s-xclick pour Paypal


Sujet :

Apache

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre chevronné Avatar de rikemSen
    Homme Profil pro
    Analyste Développeur Web - Fizzup.com
    Inscrit en
    Décembre 2007
    Messages
    387
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Analyste Développeur Web - Fizzup.com
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 387
    Par défaut [OpenSSL] _s-xclick pour Paypal
    Bonjour,

    Environnement: XP SP3 / wampserver / Apache2.2.11 / php5.2.9-2 / PHP Version 5.2.9-2

    Mon problème est le suivant: Le cryptage d'un bouton se fait sur mon serveur ovh mais pas en local sous wamp.

    Code php qui utilise SSL:
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    <?php
    #Scrypt traduit et modifie par maniT4c
    #Retrouvez le scrypt d'origine sur http://www.stellarwebsolutions.com/en/articles/paypal_button_encryption_php.php
     
    #Defini le chemin de la racine pour OpenSSL
    putenv("HOME=~");
     
    # chemin vers la clef privee
    //$MY_KEY_FILE = "./prvkey.pem";
    $MY_KEY_FILE = "./Clef_privee.pem";
     
    # chemin vers le certificat public
    $MY_CERT_FILE = "./Certificat_public.pem";
     
    # chemin vers le certificat public de paypal
    //$PAYPAL_CERT_FILE = "./paypal_cert_pem.txt";
    $PAYPAL_CERT_FILE = "./paypal_cert_pem.txt";
     
    # chemin vers openssl sur votre serveur
    //$OPENSSL = "../../../bin/apache/Apache2.2.11/conf/";
    //$OPENSSL = './bin/';
    //$OPENSSL = '../../../bin/php/php5.2.9-2/extras/openssl';
    $OPENSSL = './openssl/bin/';
     
    $form = array('cmd' => '_xclick',//indique a paypal qu'il s'agit d'un bouton payer maintenant
    		'business' => 'xxx@hotmail.fr',//adresse du vendeur (qui doit recevoir le paiement)
    		'item_name' => '5 kilo de mandarine',  //nom de la commande
    		'item_number' => '1', //numero de la commande
    		'currency_code' => 'EUR', //Devise
    		'tax' => '0.00', //taxes
    		'amount' => '10', //montant a payer
    		'lc' => 'FR', //langue de l'interface paypal
    		'bn' => 'PP-BuyNowBF', 
        'cert_id' => 'E55S8YH7ZTV5x', //identifiant de certificat donné par paypal
        'custom' => '',//variable permettant de recevoir diverses informations sur la page de retour
        'invoice' => '1',//valeur unique empechant les paiements accidentels (doit être differente pour chaque paiement)
        'charset' => 'utf-8',//Definit le charset utilisez
        'no_shipping' => '1', //Le client n'est pas invite a rentrer son adresse
        'cpp_header_image' => 'http://images.paypal.com/images/x-click-but01.gif',//Adresse de l'image se trouvant en haut de la page de paiement (750x90px maxi) dans l'ideal cette image soit se trouver sur un serveur securisé pour eviter d'avoir un message indiquant que certaine parti de la page ne sont pas écurisée.
    		'return' => 'http://localhost/mydir/user/',//Adresse de retour lorsque l'utilisateur clique sur retouner a la boutique
    		'cancel_return' => 'http://localhost/mydir/user/',//Adresse de retour pour les annulations
    		'no_note' => '1',//Empeche l'utilisateur de rajouter des commentaires a son paiement.
    		'notify_url' => 'http://localhost/mydir/user/ipn.php'//Url appelee par paypal lors du paiement, cette page permettra le traitement des commandes payees.
    	);
     
    //Cette fonction encrypte le formulaire il n'est pas necessaire de comprendre son fonctionnement
    function paypal_encrypt($hash){
     
    	global $MY_KEY_FILE;
    	global $MY_CERT_FILE;
    	global $PAYPAL_CERT_FILE;
    	global $OPENSSL;
     
    	if (!file_exists($MY_KEY_FILE)) {
    		echo "ERROR: MY_KEY_FILE $MY_KEY_FILE not found\n";
    	}
    	if (!file_exists($MY_CERT_FILE)) {
    		echo "ERROR: MY_CERT_FILE $MY_CERT_FILE not found\n";
    	}
    	if (!file_exists($PAYPAL_CERT_FILE)) {
    		echo "ERROR: PAYPAL_CERT_FILE $PAYPAL_CERT_FILE not found\n";
    	}
    	if (!file_exists($OPENSSL)) {
    		echo "ERROR: OPENSSL $OPENSSL not found\n";
    	}
     
    	//Assign Build Notation for PayPal Support
    	$hash['bn']= 'StellarWebSolutions.PHP_EWP';
     
    	$openssl_cmd = $OPENSSL.' smime -sign -signer $MY_CERT_FILE -inkey '.$MY_KEY_FILE .
                    '-outform der -nodetach -binary | $OPENSSL smime -encrypt ' .
                    '-des3 -binary -outform pem '.$PAYPAL_CERT_FILE;
     
    	$descriptors = array(
            	0 => array("pipe", "r"),
    		1 => array("pipe", "w"),
    	);
     
    	$process = proc_open($openssl_cmd, $descriptors, $pipes);
     
    	if (is_resource($process)) {
    		foreach ($hash as $key => $value) {
    			if ($value != "") {
    				//echo "Adding to blob: $key=$value\n<br />";
    				fwrite($pipes[0], "$key=$value\n");
    			}
    		}
    		fflush($pipes[0]);
            	fclose($pipes[0]);
     
    		$output = "";
    		while (!feof($pipes[1])) {
    			$output .= fgets($pipes[1]);
    		}
    		//echo "outpout=".$output;
    		fclose($pipes[1]); 
    		$return_value = proc_close($process);
    		return $output;
    	}
    	return "ERROR";
    };
     
    	//on enregistre le formulaire crypte dans une variable
    	$encrypted = paypal_encrypt($form);
     
    ?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
      <head>
        <title>Paiement Paypal</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Language" content="fr" />
      </head>
      <body>
          <form target="paypal" action="https://www.sandbox.paypal.com/fr/cgi-bin/webscr" method="post">
          <input type="hidden" name="cmd" value="_s-xclick">
          <input type="hidden" name="encrypted" value="<?php echo $encrypted; ?>">
          <input type="image" src="http://images.paypal.com/images/x-click-but01.gif"
          name="submit" alt="Effectuez vos paiements via PayPal : une solution rapide, gratuite
          et sécurisée">
        </form>
      </body>
    </html>

    Résultat source en local:
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
      <head>
        <title>Paiement Paypal</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Language" content="fr" />
      </head>
      <body>
          <form target="paypal" action="https://www.sandbox.paypal.com/fr/cgi-bin/webscr" method="post">
     
          <input type="hidden" name="cmd" value="_s-xclick">
          <input type="hidden" name="encrypted" value="">
          <input type="image" src="http://images.paypal.com/images/x-click-but01.gif"
          name="submit" alt="Effectuez vos paiements via PayPal : une solution rapide, gratuite
          et sécurisée">
        </form>
      </body>
    </html>

    Sur ovh:
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
      <head>
        <title>Paiement Paypal</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Language" content="fr" />
      </head>
      <body>
          <form target="paypal" action="https://www.sandbox.paypal.com/fr/cgi-bin/webscr" method="post">
     
          <input type="hidden" name="cmd" value="_s-xclick">
          <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----
    MIIIhQYJKoZIhvcNAQcDoIIIdjCCCHICAQAxggE6MIIBNgIBADCBnjCBmDELMAkG
    A1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExETAPBgNVBAcTCFNhbiBKb3Nl
    MRUwEwYDVQQKEwxQYXlQYWwsIEluYy4xFjAUBgNVBAsUDXNhbmRib3hfY2VydHMx
    FDASBgNVBAMUC3NhbmRib3hfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwu
    Y29tAgEAMA0GCSqGSIb3DQEBAQUABIGARqjUUVZXuy5DvPjR4RSwF2V5FxtP4zWv
    xMdfj/5wTsL1HChCng+3GyIVnUMUojbhrfmMSfHqsbF1nGWlcoO11mH0z1Yx28Qq
    6s2pjLhQBWUfwCOEbGidtINdImtVJuW7RPUxHBrk7osIBsps0bKDWshHIj4Hb3/4
    ACNIr/fMLa0wggctBgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECOTlSrVy1DmegIIH
    CBtm586ADX8wLuW2NlI7Z0SfX9x022jn21MQPs4+lZ/hxml1CPRgjm/YQTJ/aGCz
    VL22kibsUDSW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qKHg9na2jAIcHvZE19y64jlD0tx6ESOUtFZQ69757/i
    dY3HaG2TubcsXsGJqtosQpFi0cQe4cnwXjkCvpIrm5he5/itJrwhHACV1G50UKrV
    IwjNWvqmoLwqeIcAVi9xl22wzxAHFKB+MwMylNxMaWo2NCE5zxntOSCZYyaLvaPc
    0J4Qe29fZJbvmvAOQgJDFrTvApiYNBBQMC/D16sYLZMJb2X3ccvm6ySf/btPPRLi
    kvPAhkIH/eZKf8822qmUFQMAtBPAqu3vNPHTH+TmM1GHSzrMlsrRGjaoFCSYTQZ4
    7NRzAHgF+/WdfQ8LUrGgWCSF6KGIrIi13qoi5krMtSsj5y/wr6utdi4zMkXy5VO4
    wahhHNoKX+bNr90qhy7w8RomO4p4nSN/A+m6zLnusxkhU8rPbeas/dr4aTR7qYV9
    uiCuH48Y7oZu3OrzzfGizeFUpuvffE73DTnCH1ki9JPRYJr9aLXvllZ9dQTw09MU
    /bA2B32Bc1CyXaJr6w4lT55SwPYwe9MYVvzzMJlefZeR/3ahVXfzGxyeTp08gXR4
    MdKZz19Yi5KOHFg/XMkJr78oVOAT6me3/qnx+DrnT1aSn38EBKpCVLOz58HlJpps
    Ss5tTxXH966yy9BYtFcMTevyd0VtsxyD5qU7oN/jLsH5dRrBTICwDvcRMLKKW5yp
    C5k2EIpFzCmx51vNcKIkxskcE0GRFs079g9g3a80OmrvRGpn2g47jgL9F/+izuBg
    rsfw5JneD4hNTQ8OrxTMJTuBceQuirTRiibOmOOwM5DLACLwOv7HoXrqcEPpLAuRX
    tD0gWhXBoJNfSZ7w61JlWnem29XvFeyVQHNZMAUOqmJKzy0hBBt/MV9zebJ/Mmt7
    QABg/PSAr+IuM3/7kvquM0QVFBGHa7KjopWO7hXbbZopWKRo8GJ6xN8fTpYnG6Cl
    9MW0owgRLe73Z35XluWNjehaIByfxWl0Ug1eIlVNhze9EF11dZRsXzJ3i+gSRMb5
    IAS/SjjNwEDtEnrRYh8LjAesyzN7rtF0VHcL7zr6TPr/26mqBfbbBsiP7V+JcxKn
    2x7qQmbVm84R1Yyqfd+knL86jjzw6CT+uTjZan/hrlK75GgjlKyGQqHjJqofCK2t
    EMC+SGv0ImqlJVNHYHQ9eAdGDhtd7TXKWQywkpfsFvaSuTLzsKYDm8xb65Kxeg5q
    HTxEYDj7Cw53XsLWpINaOIRw+HScHqRaaBgVzMLM/mZT3/G2JE0UIwm6pBkVNhKq
    eeB80DaIgaP7T11+9eTWFGMKEwMnW95YaA==
    -----END PKCS7-----
    ">
          <input type="image" src="http://images.paypal.com/images/x-click-but01.gif"
          name="submit" alt="Effectuez vos paiements via PayPal : une solution rapide, gratuite
          et sécurisée">
        </form>
      </body>
    </html>

    _______________________
    Configuration de apache: le mod_ssl est activé et openssl est bien installé.

    Il me détecte bien openssl mais ne veut en aucun cas faire le cryptage.

    Quelqu'un pourrait t'il m'éclairer s'il vous plait?

  2. #2
    Rédacteur
    Avatar de _Mac_
    Profil pro
    Inscrit en
    Août 2005
    Messages
    9 601
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 9 601
    Par défaut
    A mon avis, c'est ta commande de chiffrement qui pose problème : elle utilise des pipes, ce qui n'est pas très compatible Windows. Il faut que tu procèdes autrement.

  3. #3
    Membre chevronné Avatar de rikemSen
    Homme Profil pro
    Analyste Développeur Web - Fizzup.com
    Inscrit en
    Décembre 2007
    Messages
    387
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Analyste Développeur Web - Fizzup.com
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 387
    Par défaut
    Humm. Merci de la réponse.

    Auriez-vous une piste à suivre à me donner s'il vous plait? Parce que j'avoue ne pas savoir comment faire...

  4. #4
    Rédacteur
    Avatar de _Mac_
    Profil pro
    Inscrit en
    Août 2005
    Messages
    9 601
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 9 601
    Par défaut
    Aucune idée, je ne connais pas bien la commande openssl. Je dirais qu'il faut décomposer la commande en deux :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $OPENSSL.' smime -sign -signer $MY_CERT_FILE -inkey '.$MY_KEY_FILE .
                    '-outform der -nodetach -binary
    puis
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $OPENSSL smime -encrypt ' .
                    '-des3 -binary -outform pem '.$PAYPAL_CERT_FILE
    et voir comment un peut combiner les deux. Sûrement en passant par un fichier temporaire plutôt qu'un pipe.

  5. #5
    Membre chevronné Avatar de rikemSen
    Homme Profil pro
    Analyste Développeur Web - Fizzup.com
    Inscrit en
    Décembre 2007
    Messages
    387
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Analyste Développeur Web - Fizzup.com
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 387
    Par défaut
    => Je vais changer de solution. Systeme D.

  6. #6
    Nouveau candidat au Club
    Profil pro
    Inscrit en
    Juin 2010
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2010
    Messages : 2
    Par défaut
    Bonjour,

    Je rencontre actuellement le même soucis, cependant, dans le sens inverse !
    En local le formulaire est crypté, mais pas sur le serveur.

    J'utilise le même code PHP que Radicaldreamer et ai le même HTML généré.
    La seule différence est l'adresse du openssl. Si je met la même que Radicaldreamer, j'ai une erreur m'indiquant que le fichier est introuvable.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    $MY_KEY_FILE = "../**********prvkey.pem";
    $MY_CERT_FILE = "../*******pubcert.pem";
    $PAYPAL_CERT_FILE = "../paypal_cert_pem.txt";
     
    $OPENSSL = "/usr/bin/openssl";
    $openssl_cmd = $OPENSSL.' smime -sign -signer $MY_CERT_FILE -inkey '.$MY_KEY_FILE .
    '-outform der -nodetach -binary | $OPENSSL smime -encrypt ' .
    '-des3 -binary -outform pem '.$PAYPAL_CERT_FILE;
    Le serveur de production est un mutualisé OVH sous Linux.
    Je suis également sous Linux en local.

    En cas d'idée je suis preneur !
    Merci

Discussions similaires

  1. Réponses: 0
    Dernier message: 18/05/2009, 10h18
  2. [PayPal] Aide/conseil pour paypal
    Par worldhugo dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 2
    Dernier message: 27/04/2009, 18h14
  3. JS de calcul de tarifs d'envoi pour paypal
    Par 01001111 dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 03/02/2009, 08h53
  4. [PayPal] Passage d'informaiton par la méthode POST
    Par Akim13 dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 1
    Dernier message: 26/04/2008, 20h23
  5. OpenSSL/OpenLDAP Problème pour la création de certificat
    Par shaun_the_sheep dans le forum Réseau
    Réponses: 4
    Dernier message: 07/10/2005, 13h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo