PayPal - Crypter un bouton dynamiquement
Posté : 15 févr. 2010, 22:04
Bonjour, je travail sur un projet " Vente en ligne ", je suis nouveau sur ce forum, je sais pas vraiment si c'est le bon endroit pour exposer mon problème, mais le voici :
Je veut réalisé des bouton PayPal crypté, j'ai suivi les explications suivante :
# Tutorial Paypal : Présentation
# Tutorial Paypal : Création des comptes de Tests
# Tutorial Paypal : Création du Bouton HTML ‘Acheter Maintenant’
# Tutorial Paypal : La récupération des données par IPN
# Tutorial Paypal : Cryptage dynamique en php des boutons Paypal
Sur ce lien : http://www.entreprise-epi.fr/2008/03/cr ... ns-paypal/
( C'est très bien expliqué, d'ailleurs bravo à l'auteur de l'article ), j'ai voulu optimiser le code de base j'obtiens donc 2 fichiers :
notify.php et btn.php ( ou ithem.php )
Le contenu du fichier notify.php fonctionne parfaitement, j'ai réalisé une série de test et tout fonctionne
Par contre le fichier btn.php à quelques soucis : [url]http://www.%20Vente%20en%20ligne.com/test/btn.php[/url]
Quand je clique sur le bouton crypté j'ai le message suivant sur le site de PayPal :
Je veut réalisé des bouton PayPal crypté, j'ai suivi les explications suivante :
# Tutorial Paypal : Présentation
# Tutorial Paypal : Création des comptes de Tests
# Tutorial Paypal : Création du Bouton HTML ‘Acheter Maintenant’
# Tutorial Paypal : La récupération des données par IPN
# Tutorial Paypal : Cryptage dynamique en php des boutons Paypal
Sur ce lien : http://www.entreprise-epi.fr/2008/03/cr ... ns-paypal/
( C'est très bien expliqué, d'ailleurs bravo à l'auteur de l'article ), j'ai voulu optimiser le code de base j'obtiens donc 2 fichiers :
notify.php et btn.php ( ou ithem.php )
Le contenu du fichier notify.php fonctionne parfaitement, j'ai réalisé une série de test et tout fonctionne
Par contre le fichier btn.php à quelques soucis : [url]http://www.%20Vente%20en%20ligne.com/test/btn.php[/url]
Quand je clique sur le bouton crypté j'ai le message suivant sur le site de PayPal :
Voici le code source du fichier btn.php :Nous ne sommes pas en mesure de traiter cette transaction en raison d'un problème concernant l'adresse email PayPal fournie par le vendeur. Veuillez contacter le vendeur afin de résoudre ce problème. Si ce paiement concerne une annonce eBay, vous pouvez contacter le vendeur par l'intermédiaire du lien Poser une question au vendeur dans la page de l'annonce. Lorsque vous disposez de l'adresse email correcte, vous pouvez effectuer le paiement à l'adresse http://www.paypal.com.
<?php
//-->> DEMMARRAGE D'UNE SESSION
session_start();
####################################################################
## PROVISOIRE ## V
####################################################################
if(!isset($_SESSION['espace_membre']))
{
$_SESSION['espace_membre'] = "0091";
}
####################################################################
## A MODIFIER ## V
####################################################################
$situation_de_test = "OUI"; // OUI ou NON
$montant = "29.99"; // Pas de virgule juste un point !!
$cycle = "1"; // quantité
$unite_cycle = "M"; // D (jours), W (semaines), M (mois), Y (ans)
$nom_produit = " Vente en ligne pendant 1 Mois";
$code_produit = "1M";
$taxe = "0.00"; // 0 -> Pas de taxe ( par exemple la TVA )
####################################################################
## PARAMETRES GENERALES ## -
####################################################################
$monaie = "EUR";
$frais_de_port = "0.00"; // 0 -> Pas de frais de port
$avis = "0"; // 0 ou 1 -> Demander l'avis des clients
$id_acheteur = $_SESSION['espace_membre']; // Identifiant du client
$bouton = "_xclick-subscriptions"; // Type de bouton ( dans ce cas c'est un abonnement)
$langue = "FR";
$page_paiement_accepte = "http://www. Vente en ligne.com/test/finpaiement.php"; // Si le paiement est accepté
$page_paiement_annule = "http://www. Vente en ligne.com/test/annuler.php"; // Si le paiement n'est pas accepté
####################################################################
## TEST / REEL ## -
####################################################################
if($situation_de_test == "OUI")
{
$paypaltype = '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
$cac = "b_1266149529_biz@ Vente en ligne.com";
$page_ipn = "http://www. Vente en ligne.com/test/notify.php?situation_de_test=OUI";
}
else
{
$paypaltype = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
$cac = "service.client@ Vente en ligne.com";
$page_ipn = "http://www. Vente en ligne.com/test/notify.php?situation_de_test=NON";
}
//-->> DATE
$date_us = date("Y-m-d");
$date_fr = date("d-m-Y");
$heure = date("H:i:s");
####################################################################
## A PARTIR D'ICI, NE PAS MODIFIER ## X
####################################################################
putenv("HOME=~");
$MY_KEY_FILE = "/homez.323/ Vente en ligne/www/test/9f71d63e4dac3a6f7c41b0058479a280-prvkey.pem";
$MY_CERT_FILE = "/homez.323/ Vente en ligne/www/test/9f71d63e4dac3a6f7c41b0058479a280-pubcert.pem";
$PAYPAL_CERT_FILE = "/homez.323/ Vente en ligne/www/test/paypal_cert_pem.pem";
$OPENSSL = "/usr/bin/openssl";
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";
}
$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 != "")
{
fwrite($pipes[0], "$key=$value\n");
}
}
fflush($pipes[0]);
fclose($pipes[0]);
$output = "";
while (!feof($pipes[1]))
{
$output .= fgets($pipes[1]);
}
fclose($pipes[1]);
$return_value = proc_close($process);
return $output;
}
return "ERROR";
};
function paypal_button($nom_produit,$montant,$id_acheteur,$heure,$date_us,$date_fr,$cac,$code_produit,$cycle,$unite_cycle,$id_acheteur)
{
$form = array('cmd' => '_xclick-subscriptions', // bouton paypal abonnement
'business' => ''.$cac.'', // adresse de votre compte paypal
'cert_id' => 'BYMFYZCEEREN6', // clef
'item_name' => ''.$nom_produit.'', // nom du forfait
'a3' => ''.$montant.'', // tarif
'p3' => ''.$cycle.'', // 1 ou 3
't3' => ''.$unite_cycle.'', // M ou A
'shipping' => '0.00', //Frais de port
'no_shipping' => '0',
'return' => 'http://www. Vente en ligne.com/test/finpaiement.php',
'notify_url' => 'http://www. Vente en ligne.com/test/notify.php',
'cancel_return' => 'http://www. Vente en ligne.com/test/annuler.php',
'no_note' => '0',
'custom' => ''.$id_acheteur.'-*-'.$code_produit.'-*-'.$date_us.'-*-'.$date_fr.'-*-'.$heure.'-*-'.$montant.'',
'currency_code' => 'EUR',
'tax' => '0.00',
'lc' => 'FR'
);
$encrypted = paypal_encrypt($form);
return $encrypted;
}
echo''.$paypaltype.'
<input type="hidden" name="cmd" value="'.$bouton.'">
<input name="encrypted" type="hidden" value="'; echo paypal_button($nom_produit,$montant,$id_acheteur,$heure,$date_us,$date_fr,$cac,$code_produit,$cycle,$unite_cycle,$id_acheteur); echo'" />
<input class="button68" type="submit" value="S\'abonner" />
</form>
';
?>
Un sincère Merci à vous tous