Jump to content

Sandbox PayPal


Recommended Posts

Salut ,

 

J' ai créer ma Gateway PayPal Sandbox avec votre exemple.

je trouve pas toutes les variables=>"night_phone_a"," no_note" voir page ci joint.

 

A quoi coresponde les

name="bn" , name="rm" ?

 

Avez-vous un exemple pour la page calback.php pour que tous fonctionne correctement.

 

Merci Eric

 

Hi ,

 

I 've created my Gateway PayPal Sandbox with your example.

I think not all variables => "night_phone_a", "no_note" see next page joint.

 

Do you have an example page calback.php for all working properly.

 

What the coresponde

name = "bn" name = "rm"?

 

Eric thank you

<?php

function sandbox_config() {

$configarray = array(
    "FriendlyName" => array("Type" => "System", "Value"=>"PayPal Sandbox"),
    "email" => array ("FriendlyName" => "PayPal Sandbox Email", "Type" => "text", "Size" => "30", "Description" => "", ),
 "apiusername" => array ("FriendlyName" => "API Sandbox Username", "Type" => "text", "Size" => "30", "Description" => "API fields only required for reffunds", ),
 "apipassword" => array ("FriendlyName" => "API Sandbox Password", "Type" => "password", "Size" => "30", ),
 "apisignature" => array ("FriendlyName" => "PayPal Sandbox Signature", "Type" => "text", "Size" => "30", ), 
    );
return $configarray;
}

function sandbox_link($params) {

# Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

# Invoice Variables
$invoiceid = $params['invoiceid'];
$description = $params["description"];
   $amount = $params['amount']; # Format: ##.##
   $currency = $params['currency']; # Currency Code

# Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];

# System Variables
$companyname = $params['companyname'];
$systemurl = $params['systemurl'];
$currency = $params['currency'];
$company_domain = $params['$company_domain'];

# Enter your code submit to the gateway...

$code = '</form>
<form action="https://www.sandbox.paypal.com/fr/webapps/mpp/home" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="test.mail-business@mail.fr">
<input type="hidden" name="item_name" value="'.$description.'">
<input type="hidden" name="amount" value="'.$amount.'">
<input type="hidden" name="tax" value="0.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="address_override" value="0">
<input type="hidden" name="first_name" value="'.$firstname.'">
<input type="hidden" name="last_name" value="'.$lastname.'">
<input type="hidden" name="address1" value="'.$address1.'">
<input type="hidden" name="city" value="'.$city.'">
<input type="hidden" name="state" value="'.$state.'">
<input type="hidden" name="zip" value="'.$postcode.'">
<input type="hidden" name="country" value="'.$country.'">
<input type="hidden" name="night_phone_a" value="33">
<input type="hidden" name="night_phone_b" value="'.$phone.'">
<input type="hidden" name="charset" value="utf-8">
<input type="hidden" name="currency_code" value="'.$currency.'">
<input type="hidden" name="custom" value="'.$invoiceid.'">
<input type="hidden" name="return" value="http://www.mysite/clients/viewinvoice.php?id='.$invoiceid.'&paymentsuccess=true">
<input type="hidden" name="cancel_return" value="http://www.mysite/clients/viewinvoice.php?id='.$invoiceid.'&paymentfailed=true">
<input type="hidden" name="notify_url" value="http://www.mysite/clients/modules/gateways/callback/paypal.php">	//<=================================(sandbox.php un exemple?)
<input type="hidden" name="rm" value="2">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make a one time payment with PayPal">
</form>';

return $code;
}

//si dessous a supprimer si les remboursements sont inactif chez les banques

function sandbox_refund($params) {

   # Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

   # Invoice Variables
$transid = $params['transid']; # Transaction ID of Original Payment
$amount = $params['amount']; # Format: ##.##
   $currency = $params['currency']; # Currency Code

   # Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];

# Card Details
$cardtype = $params['cardtype'];
$cardnumber = $params['cardnum'];
$cardexpiry = $params['cardexp']; # Format: MMYY
$cardstart = $params['cardstart']; # Format: MMYY
$cardissuenum = $params['cardissuenum'];

# Perform Refund Here & Generate $results Array, eg:
$results = array();
$results["status"] = "success";
   $results["transid"] = "12345";

# Return Results
if ($results["status"]=="success") {
	return array("status"=>"success","transid"=>$results["transid"],"rawdata"=>$results);
} elseif ($gatewayresult=="declined") {
       return array("status"=>"declined","rawdata"=>$results);
   } else {
	return array("status"=>"error","rawdata"=>$results);
}

}
//$display_errors = true;
?>

Link to comment
Share on other sites

Hi,

The new code:

 

my site=>Sandbox OK

return NOOK

 

Merci,Eric

 

function sandbox_config() {

$configarray = array(
    "FriendlyName" => array("Type" => "System", "Value"=>"PayPal Sandbox"),
    "email" => array ("FriendlyName" => "PayPal Sandbox Email", "Type" => "text", "Size" => "40", "Description" => "", ),
  "forceonetime" => array ("FriendlyName" => "Force One Time Payments", "Type" => "yesno", "Size" => "25", "Description" => "Never show the subscription payment button", ),
   "forcesubscriptions" => array ("FriendlyName" => "Force Subscriptions", "Type" => "yesno", "Size" => "25", "Description" => "Hide the one time payment button when a subscription can be created", ),
   "requireshipping" => array ("FriendlyName" => "Require Shipping Address", "Type" => "yesno", "Size" => "25", "Description" => "Tick this box to request a shipping address from a user on PayPal's site", ),
   "overrideaddress" => array ("FriendlyName" => "Client Address Matching", "Type" => "yesno", "Size" => "25", "Description" => "Tick this box to force using client profile information entered into WHMCS at PayPal", ),
 "apiusername" => array ("FriendlyName" => "API Sandbox Username", "Type" => "text", "Size" => "40", "Description" => "API fields only required for reffunds", ),
 "apipassword" => array ("FriendlyName" => "API Sandbox Password", "Type" => "password", "Size" => "40", ),
 "apisignature" => array ("FriendlyName" => "API Sandbox Signature", "Type" => "text", "Size" => "70", ), 
    );
return $configarray;
}

function sandbox_link($params) {

# Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

# Invoice Variables
$invoiceid = $params['invoiceid'];
$description = $params["description"];
   $amount = $params['amount']; # Format: ##.##
   $currency = $params['currency']; # Currency Code

# Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];

# System Variables
$companyname = $params['companyname'];
$systemurl = $params['systemurl'];
$currency = $params['currency'];
$company_domain = $params['company_domain'];

# Enter your code submit to the gateway...

$code = '</form>
<form action="https://www.sandbox.paypal.com/fr/webapps/mpp/home" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="eric.duborjaltestbu@orange.fr">
<input type="hidden" name="item_name" value="'.$description.'">
<input type="hidden" name="amount" value="'.$amount.'">
<input type="hidden" name="tax" value="0.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="address_override" value="0">
<input type="hidden" name="first_name" value="'.$firstname.'">
<input type="hidden" name="last_name" value="'.$lastname.'">
<input type="hidden" name="address1" value="'.$address1.'">
<input type="hidden" name="city" value="'.$city.'">
<input type="hidden" name="state" value="'.$state.'">
<input type="hidden" name="zip" value="'.$postcode.'">
<input type="hidden" name="country" value="'.$country.'">
<input type="hidden" name="night_phone_a" value="33">
<input type="hidden" name="night_phone_b" value="'.$phone.'">
<input type="hidden" name="charset" value="utf-8">
<input type="hidden" name="currency_code" value="'.$currency.'">
<input type="hidden" name="custom" value="'.$invoiceid.'">
<input type="hidden" name="return" value="http://www.mysite/clients/viewinvoice.php?id='.$invoiceid.'&paymentsuccess=true">
<input type="hidden" name="cancel_return" value="http://www.mysite/clients/viewinvoice.php?id='.$invoiceid.'&paymentfailed=true">
<input type="hidden" name="notify_url" value="http://www.mysite/clients/modules/gateways/callback/sandbox.php">
<input type="hidden" name="bn" value="WHMCS_ST">
<input type="hidden" name="rm" value="2">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make a one time payment with PayPal">
</form>';

return $code;
}

Link to comment
Share on other sites

La solution:

la page sandbox.php à déposer dans

votre dossier Whmcs/modules/gateways

 

<?php
//votre dossier Whmcs/modules/gateways/
include("../../dbconnect.php");
function sandbox_config() {

$configarray = array(
    "FriendlyName" => array("Type" => "System", "Value"=>"PayPal Sandbox"),
    "email" => array ("FriendlyName" => "PayPal Sandbox Email", "Type" => "text", "Size" => "40", "Description" => "", ),
 "email-erreur" => array ("FriendlyName" => "Email réception d'erreurs", "Type" => "text", "Size" => "40", "Description" => "Mail qui reçois les erreurs", ),
  "forceonetime" => array ("FriendlyName" => "Force One Time Payments", "Type" => "yesno", "Size" => "25", "Description" => "Never show the subscription payment button", ),
   "forcesubscriptions" => array ("FriendlyName" => "Force Subscriptions", "Type" => "yesno", "Size" => "25", "Description" => "Hide the one time payment button when a subscription can be created", ),
   "requireshipping" => array ("FriendlyName" => "Require Shipping Address", "Type" => "yesno", "Size" => "25", "Description" => "Tick this box to request a shipping address from a user on PayPal's site", ),
   "overrideaddress" => array ("FriendlyName" => "Client Address Matching", "Type" => "yesno", "Size" => "25", "Description" => "Tick this box to force using client profile information entered into WHMCS at PayPal", ),
 "apiusername" => array ("FriendlyName" => "API Sandbox Username", "Type" => "text", "Size" => "40", "Description" => "API fields only required for reffunds", ),
 "apipassword" => array ("FriendlyName" => "API Sandbox Password", "Type" => "password", "Size" => "40", ),
 "apisignature" => array ("FriendlyName" => "API Sandbox Signature", "Type" => "text", "Size" => "70", ), 
    );
return $configarray;
}

function sandbox_link($params) {
//on vas chercher les  valeurs dans la base
$sql = "SELECT `setting`,`value`\n"
    . "FROM `tblpaymentgateways` \n"
    . "WHERE `gateway`=\"sandbox\"";

 $result = mysql_query($sql);

 $tableau=array();

        while($row=mysql_fetch_array($result)){
           $tableau[$row['setting']] = $row['value'];
        }

		$bosapipassword			=  $tableau["apipassword"];
		$bosapisignature		=  $tableau["apisignature"];
		$bosapiusername			=  $tableau["apiusername"];
		$bosconvertto			=  $tableau["convertto"];
		$bosemail				=  $tableau["email"];
		$bosforceonetime		=  $tableau["forceonetime"];
		$bosforcesubscriptions	=  $tableau["forcesubscriptions"];
		$bosname 				=  $tableau["name"];
		$bosoverrideaddress		=  $tableau["overrideaddress"];
		$bosrequireshipping		=  $tableau["requireshipping"];
		$bostype 				=  $tableau["type"];
		$bosvisible 			=  $tableau["visible"];


		# Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

# Invoice Variables
$invoiceid = $params['invoiceid'];
$description = $params["description"];
   $amount = $params['amount']; # Format: ##.##
   $currency = $params['currency']; # Currency Code

# Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];

# System Variables
$companyname = $params['companyname'];
$systemurl = $params['systemurl'];
$currency = $params['currency'];
$company_domain = $params['company_domain'];
$retour_accept   = $params["systemurl"] . "/viewinvoice.php?id=".$invoiceid."&paymentsuccess=true";
   $retour_cancel   = $params["systemurl"] . "/viewinvoice.php?id=".$invoiceid."&paymentfailed=true";
   $retour_calback = $params["systemurl"] . "/modules/gateways/callback/sandbox.php";


$code = '
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="'.$bosemail.'">
<input type="hidden" name="item_name" value="'.$description.'">
<input type="hidden" name="amount" value="'.$amount.'">
<input type="hidden" name="tax" value="0.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="address_override" value="0">
<input type="hidden" name="first_name" value="'.$firstname.'">
<input type="hidden" name="last_name" value="'.$lastname.'">
<input type="hidden" name="address1" value="'.$address1.'">
<input type="hidden" name="city" value="'.$city.'">
<input type="hidden" name="state" value="'.$state.'">
<input type="hidden" name="zip" value="'.$postcode.'">
<input type="hidden" name="country" value="'.$country.'">
<input type="hidden" name="night_phone_a" value="33">
<input type="hidden" name="night_phone_b" value="'.$phone.'">
<input type="hidden" name="charset" value="utf-8">
<input type="hidden" name="currency_code" value="'.$currency.'">
<input type="hidden" name="custom" value="'.$invoiceid.'">
<input type="hidden" name="return" value="'.$retour_accept.'">
<input type="hidden" name="cancel_return" value="'.$retour_cancel.'">
<input type="hidden" name="notify_url" value="'.$retour_calback.'">
<input type="hidden" name="rm" value="2">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make a one time payment with PayPal">
</form>';
return $code;
}

//si dessous a supprimer si les remboursements sont inactif chez les banques
function sandbox_refund($params) {

   # Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

   # Invoice Variables
$transid = $params['transid']; # Transaction ID of Original Payment
$amount = $params['amount']; # Format: ##.##
   $currency = $params['currency']; # Currency Code

   # Variable sClient dans la base de donnée
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];

# Card Details
$cardtype = $params['cardtype'];
$cardnumber = $params['cardnum'];
$cardexpiry = $params['cardexp']; # Format: MMYY
$cardstart = $params['cardstart']; # Format: MMYY
$cardissuenum = $params['cardissuenum'];

# Perform Refund Here & Generate $results Array, eg:
$results = array();
$results["status"] = "success";
   $results["transid"] = "12345";

# Return Results
if ($results["status"]=="success") {
	return array("status"=>"success","transid"=>$results["transid"],"rawdata"=>$results);
} elseif ($gatewayresult=="declined") {
       return array("status"=>"declined","rawdata"=>$results);
   } else {
	return array("status"=>"error","rawdata"=>$results);
}

}
?>

 

et la page du même nom qui va dans

votre dossier Whmcs/modules/gateways/calback/

 

qui s'appelle également sandbox.php

attention aux infos en haut de page

 


<?php
//votre dossier Whmcs/modules/gateways/calback/

//1. Log in to developer.paypal.com
//2. Click Dashboard, Click Accounts under Sandbox
//3. Click the email you are using for business account so it opens
//4. Click Profile (should pop up a window)
//5. Click Settings
//6. Make sure Payment Review is clicked Off

# Required File Includes
include("../../../dbconnect.php");
include("../../../includes/functions.php");
include("../../../includes/gatewayfunctions.php");
include("../../../includes/invoicefunctions.php");
//on verif toujour ce qui arrive
function verif($string)
{
	// On regarde si le type de string est un nombre entier (int)
	if(ctype_digit($string))
	{
		$string = intval($string);
	}
	// Pour tous les autres types
	else
	{
		$string = addcslashes($string, '%_');
	}

	return $string;
}

$gatewaymodule = "sandbox"; # Enter your gateway module name here replacing template

$GATEWAY = getGatewayVariables($gatewaymodule);
if (!$GATEWAY["type"]) die("Module Not Activated"); # Checks gateway module is active before accepting callback


$sql = "SELECT `setting`,`value`\n"
    . "FROM `tblpaymentgateways` \n"
    . "WHERE `gateway`=\"sandbox\"";

 $result = mysql_query($sql);

 $tableau=array();

        while($row=mysql_fetch_array($result)){
           $tableau[$row['setting']] = $row['value'];
        }
	 	//on reprend nos variables paypal
		$bosapipassword			=  $tableau["apipassword"];
		$bosapisignature		=  $tableau["apisignature"];
		$bosapiusername			=  $tableau["apiusername"];
		$bosconvertto			=  $tableau["convertto"];
		$bosemail				=  $tableau["email"];
		$boemailerreur			=  $tableau["email-erreur"];
		$bosforceonetime		=  $tableau["forceonetime"];
		$bosforcesubscriptions	=  $tableau["forcesubscriptions"];
		$bosname 				=  $tableau["name"];
		$bosoverrideaddress		=  $tableau["overrideaddress"];
		$bosrequireshipping		=  $tableau["requireshipping"];
		$bostype 				=  $tableau["type"];
		$bosvisible 			=  $tableau["visible"];

		# les variables du client
		$firstname = $params['clientdetails']['firstname'];
		$lastname = $params['clientdetails']['lastname'];
		$email = $params['clientdetails']['email'];
		$address1 = $params['clientdetails']['address1'];
		$address2 = $params['clientdetails']['address2'];
		$city = $params['clientdetails']['city'];
		$state = $params['clientdetails']['state'];
		$postcode = $params['clientdetails']['postcode'];
		$country = $params['clientdetails']['country'];
		$phone = $params['clientdetails']['phonenumber'];

// CONFIG: Enable debug mode. This means we'll log requests into 'ipn.log' in the same directory.
// Especially useful if you encounter network errors or other intermittent problems with IPN (validation).
// Set this to 0 once you go live or don't require logging.
define("DEBUG", 0);//laisser a 0 sinon on va creer un fichier de debug

// Set to 0 once you're ready to go live
define("USE_SANDBOX", 1);//ne pas toucher


define("LOG_FILE", "./ipn.log");//nom du fichier qui va se creer


// Read POST data
// reading posted data directly from $_POST causes serialization
// issues with array data in POST. Reading raw POST data from input stream instead.
$raw_post_data = file_get_contents('php://input');
$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]);
}
// read the post from PayPal system and add 'cmd'
$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);
}
$req .= "&$key=$value";
}

// Post IPN data back to PayPal to validate the IPN data is genuine
// Without this step anyone can fake IPN data

if(USE_SANDBOX == true) {
$paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
} else {
$paypal_url = "";//https://www.paypal.com/cgi-bin/webscr <<<<<<<=== adresse de production si define en dessus   USE_SANDBOX", 0
}

$ch = curl_init($paypal_url);
if ($ch == FALSE) {
return FALSE;
}
//les variables de retour paypal il y en a plein d'autre 
$status = verif($_POST["payment_status"]);//Completed fin de paiement
$invoiceid = verif($_POST["custom"]);//ID de la commande
$transid = verif($_POST["txn_id"]);//numero de transaction paypal
$amount = verif($_POST["mc_gross"]);//prix
$fee = verif($_POST["mc_fee"]); // valeur
$payment_date= verif($_POST["payment_date"]);//la date du paiement
$receiver_email = verif($_POST['receiver_email']);//notre adresse mail du compte qui recoit

$sqla = "SELECT `amount`\n"
    . "FROM `tblinvoiceitems` \n"
    . "WHERE `invoiceid`= ".$invoiceid." ";
  $resulta = mysql_query($sqla);
while($rowprix=mysql_fetch_array($resulta)){
           $prix_client_depart = $rowprix['amount'];
        }

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //false pour eviter les erreur ou normalement 1
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);//0 pour eviter les erreur normalement 2 mais les fonction ne fonctionne pas sur mon serveur pas de ssl pour le moment
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);

if(DEBUG == true) {
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
}

// CONFIG: Optional proxy configuration
//curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);

// Set TCP timeout to 30 seconds
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);//pour pas planter on coupe si le temps et trop long
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));

// CONFIG: Please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path
// of the certificate as shown below. Ensure the file is readable by the webserver.
// This is mandatory for some environments.

//$cert = __DIR__ . "./cacert.pem";
//curl_setopt($ch, CURLOPT_CAINFO, $cert);

$res = curl_exec($ch);
if (curl_errno($ch) != 0) // cURL error
{
if(DEBUG == true) { 
error_log(date('[Y-m-d H:i e] '). "Can't connect to PayPal to validate IPN message: " . curl_error($ch) . PHP_EOL, 3, LOG_FILE);
}
curl_close($ch);
exit;

} else {
// Log the entire HTTP response if debug is switched on.
if(DEBUG == true) {
error_log(date('[Y-m-d H:i e] '). "HTTP request of validation request:". curl_getinfo($ch, CURLINFO_HEADER_OUT) ." for IPN payload: $req" . PHP_EOL, 3, LOG_FILE);
error_log(date('[Y-m-d H:i e] '). "HTTP response of validation request: $res" . PHP_EOL, 3, LOG_FILE);

// Split response headers and payload
list($headers, $res) = explode("\r\n\r\n", $res, 2);
}
curl_close($ch);
}

// si iPN ok on fais des verifications
//on peut surement faire encore d'autre verifs
if (strcmp ($res, "VERIFIED") == 0) {
//ID dans la base de donnée ou pas?
$invoiceid = checkCbInvoiceID($invoiceid,$GATEWAY["sandbox"]);
	//ci-dessous verif du nunero de transaction paypal
	checkCbTransID($transid); 

	//on verif notre adresse mail vendeur
		if($bosemail!=$receiver_email){//si erreur on envoi un mail
		 mail($boemailerreur, 'IPN', "erreur de mail\r\n Verified IPN: $req ");
			}else{//on continu les verifs
				if(	$prix_client_depart!=$amount){//erreur de prix on envoi un mail
					 mail($boemailerreur, 'IPN', "erreur de prix\r\n Verified IPN: $req ");
						}else{//on continu les verif
							if ($status=="Completed") {
  									 # Successful
  									 addInvoicePayment($invoiceid,$transid,$amount,$fee,$gatewaymodule); # Apply Payment to Invoice: invoiceid, transactionid, amount paid, fees, modulename
					 			 logTransaction($GATEWAY["name"],$_POST,"Successful"); # Save to Gateway Log: name, data array, status
							}else {
								mail($boemailerreur, 'IPN', "erreur status\r\n Verified IPN: $req ");
								# Unsuccessful
  									logTransaction($GATEWAY["name"],$_POST,"Unsuccessful"); # Save to Gateway Log: name, data array, status
								}
							}
				}
if(DEBUG == true) {
error_log(date('[Y-m-d H:i e] '). "Verified IPN: $req ". PHP_EOL, 3, LOG_FILE);
}
		}

else if (strcmp ($res, "INVALID") == 0) {mail($boemailerreur, 'IPN', "erreur IPN \r\n erified IPN: $req ");
// log for manual investigation
// Add business logic here which deals with invalid IPN messages
if(DEBUG == true) {
error_log(date('[Y-m-d H:i e] '). "Invalid IPN: $req" . PHP_EOL, 3, LOG_FILE);
}
}

?>

 

 

CHEZ MOI TOUT FONCTIONNE

POUR MES BESOINS

 

Dites moi si pour vous ça marche!!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated