Visualizzazione dei risultati da 1 a 7 su 7

Discussione: Paypall Integration

Hybrid View

  1. #1
    Moderatore di CMS L'avatar di kalosjo
    Registrato dal
    Jul 2001
    residenza
    In culo alla luna
    Messaggi
    1,999

    Paypall Integration

    Premetto che:
    1) ho studiato la guida di paypal per l'integrazione dei pagamenti
    2) ho letto e controllato le funzioni già da loro sviluppate per implementare il pagamento
    3) ho compreso, o credo di aver compreso (a questo punto), il funzionamento

    Non mi funziona...........

    La storia è semplice.

    Dal sito fanno un ordine.
    Io prendo solo il totale (mi serve gestire solo quello su Paypal)

    Poi faccio la seguente:
    Mando il mio ammontare al file expresscheckout.php, che inoltro;
    codice:
    <?php
    
    require_once ("paypalfunctions.php");
    // ==================================
    // PayPal Express Checkout Module
    // ==================================
    
    //'------------------------------------
    //' The paymentAmount is the total value of 
    //' the shopping cart, that was set 
    //' earlier in a session variable 
    //' by the shopping cart page
    //'------------------------------------
    $paymentAmount = $_POST["importototale"];
    //'------------------------------------
    //' The currencyCodeType and paymentType 
    //' are set to the selections made on the Integration Assistant 
    //'------------------------------------
    $currencyCodeType = "EUR";
    $paymentType = "Sale";
    
    //'------------------------------------
    //' The returnURL is the location where buyers return to when a
    //' payment has been succesfully authorized.
    //'
    //' This is set to the value entered on the Integration Assistant 
    //'------------------------------------
    $returnURL = "http://blablabla";
    
    //'------------------------------------
    //' The cancelURL is the location buyers are sent to when they hit the
    //' cancel button during authorization of payment during the PayPal flow
    //'
    //' This is set to the value entered on the Integration Assistant 
    //'------------------------------------
    $cancelURL = "bliblibli";
    
    //'------------------------------------
    //' Calls the SetExpressCheckout API call
    //'
    //' The CallShortcutExpressCheckout function is defined in the file PayPalFunctions.php,
    //' it is included at the top of this file.
    //'-------------------------------------------------
    $resArray = CallShortcutExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
    $ack = strtoupper($resArray["ACK"]);
    if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
    {
    	RedirectToPayPal ( $resArray["TOKEN"] );
    } 
    else  
    {
    	//Display a user friendly Error on the page using any of the following error information returned by PayPal
    	$ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
    	$ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
    	$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
    	$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
    	
    	echo "SetExpressCheckout API call failed. ";
    	echo "Detailed Error Message: " . $ErrorLongMsg;
    	echo "Short Error Message: " . $ErrorShortMsg;
    	echo "Error Code: " . $ErrorCode;
    	echo "Error Severity Code: " . $ErrorSeverityCode;
    }
    ?>
    Dove il file paypalfunctions.php è il seguente:
    codice:
     
    <?php
    	/********************************************
    	PayPal API Module
    	 
    	Defines all the global variables and the wrapper functions 
    	********************************************/
    	$PROXY_HOST = '127.0.0.1';
    	$PROXY_PORT = '808';
    
    	$SandboxFlag = false;
    
    	//'------------------------------------
    	//' PayPal API Credentials
    	//' Replace <API_USERNAME> with your API Username
    	//' Replace <API_PASSWORD> with your API Password
    	//' Replace <API_SIGNATURE> with your Signature
    	//'------------------------------------
    
    	$API_UserName="piripiripiripiri";
    	$API_Password="poroporoporo";
    	$API_Signature="purupurupuru";
    
    	// BN Code 	is only applicable for partners
    	$sBNCode = "PP-ECWizard";
    
    
    	/*	
    	' Define the PayPal Redirect URLs.  
    	' 	This is the URL that the buyer is first sent to do authorize payment with their paypal account
    	' 	change the URL depending if you are testing on the sandbox or the live PayPal site
    	'
    	' For the sandbox, the URL is       https://www.sandbox.paypal.com/websc...heckout&token=
    	' For the live site, the URL is        https://www.paypal.com/webscr&cmd=_e...heckout&token=
    	*/
    	
    	if ($SandboxFlag == true) 
    	{
    		$API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
    		$PAYPAL_URL = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
    	}
    	else
    	{
    		$API_Endpoint = "https://api-3t.paypal.com/nvp";
    		$PAYPAL_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
    	}
    
    	$USE_PROXY = false;
    	$version="93";
    
    	if (session_id() == "") 
    		session_start();
    
    	/* An express checkout transaction starts with a token, that
    	   identifies to PayPal your transaction
    	   In this example, when the script sees a token, the script
    	   knows that the buyer has already authorized payment through
    	   paypal.  If no token was found, the action is to send the buyer
    	   to PayPal to first authorize payment
    	   */
    
    	/*   
    	'-------------------------------------------------------------------------------------------------------------------------------------------
    	' Purpose: 	Prepares the parameters for the SetExpressCheckout API Call.
    	' Inputs:  
    	'		paymentAmount:  	Total value of the shopping cart
    	'		currencyCodeType: 	Currency code value the PayPal API
    	'		paymentType: 		paymentType has to be one of the following values: Sale or Order or Authorization
    	'		returnURL:			the page where buyers return to after they are done with the payment review on PayPal
    	'		cancelURL:			the page where buyers return to when they cancel the payment review on PayPal
    	'--------------------------------------------------------------------------------------------------------------------------------------------	
    	*/
    	function CallShortcutExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL) 
    	{
    		//------------------------------------------------------------------------------------------------------------------------------------
    		// Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
    		
    		$nvpstr="&PAYMENTREQUEST_0_AMT=". $paymentAmount;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType;
    		$nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
    		$nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType;
    		
    		$_SESSION["currencyCodeType"] = $currencyCodeType;	  
    		$_SESSION["PaymentType"] = $paymentType;
    
    		//'--------------------------------------------------------------------------------------------------------------- 
    		//' Make the API call to PayPal
    		//' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.  
    		//' If an error occured, show the resulting errors
    		//'---------------------------------------------------------------------------------------------------------------
    	    $resArray=hash_call("SetExpressCheckout", $nvpstr);
    		$ack = strtoupper($resArray["ACK"]);
    		if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
    		{
    			$token = urldecode($resArray["TOKEN"]);
    			$_SESSION['TOKEN']=$token;
    		}
    		   
    	    return $resArray;
    	}
    
    	/*   
    	'-------------------------------------------------------------------------------------------------------------------------------------------
    	' Purpose: 	Prepares the parameters for the SetExpressCheckout API Call.
    	' Inputs:  
    	'		paymentAmount:  	Total value of the shopping cart
    	'		currencyCodeType: 	Currency code value the PayPal API
    	'		paymentType: 		paymentType has to be one of the following values: Sale or Order or Authorization
    	'		returnURL:			the page where buyers return to after they are done with the payment review on PayPal
    	'		cancelURL:			the page where buyers return to when they cancel the payment review on PayPal
    	'		shipToName:		the Ship to name entered on the merchant's site
    	'		shipToStreet:		the Ship to Street entered on the merchant's site
    	'		shipToCity:			the Ship to City entered on the merchant's site
    	'		shipToState:		the Ship to State entered on the merchant's site
    	'		shipToCountryCode:	the Code for Ship to Country entered on the merchant's site
    	'		shipToZip:			the Ship to ZipCode entered on the merchant's site
    	'		shipToStreet2:		the Ship to Street2 entered on the merchant's site
    	'		phoneNum:			the phoneNum  entered on the merchant's site
    	'--------------------------------------------------------------------------------------------------------------------------------------------	
    	*/
    	function CallMarkExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, 
    									  $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState,
    									  $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum
    									) 
    	{
    		//------------------------------------------------------------------------------------------------------------------------------------
    		// Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
    		
    		$nvpstr="&PAYMENTREQUEST_0_AMT=". $paymentAmount;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType;
    		$nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
    		$nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType;
    		$nvpstr = $nvpstr . "&ADDROVERRIDE=1";
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTONAME=" . $shipToName;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTREET=" . $shipToStreet;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTREET2=" . $shipToStreet2;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOCITY=" . $shipToCity;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTATE=" . $shipToState;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=" . $shipToCountryCode;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOZIP=" . $shipToZip;
    		$nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOPHONENUM=" . $phoneNum;
    		
    		$_SESSION["currencyCodeType"] = $currencyCodeType;	  
    		$_SESSION["PaymentType"] = $paymentType;
    
    		//'--------------------------------------------------------------------------------------------------------------- 
    		//' Make the API call to PayPal
    		//' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.  
    		//' If an error occured, show the resulting errors
    		//'---------------------------------------------------------------------------------------------------------------
    	    $resArray=hash_call("SetExpressCheckout", $nvpstr);
    		$ack = strtoupper($resArray["ACK"]);
    		if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
    		{
    			$token = urldecode($resArray["TOKEN"]);
    			$_SESSION['TOKEN']=$token;
    		}
    		   
    	    return $resArray;
    	}
    fine prima parte, continua dopo
    Scusate i puntini di sospensione...... La verità è che non ho argomenti....

  2. #2
    Ciao Kalosjo,
    ho provato a mandarti un messaggio privato ma non va, non capisco il perchè..

    ti chiedevo:

    Io ho sempre utilizzato il vecchio metodo di pagamento con paypal però mi serve avere un redirect quando il cliente paga e mi è stato detto da Paypal che l'unico servizio che lo fa è appunto Express Checkout.
    Mi spieghi in linee generali come devo muovermi per integrarlo nel mio sito?

    Fammi sapere.

    Grazie mille.

  3. #3
    ok, ho risolto la prima parte.
    Mi trovo nella tua stessa situazione, non viene completata la transazione.

    Come faccio a fare quello che hai indicato??
    Dopo che il flusso torna dal servizio paypal, bisogna chiudere la transazione nel proprio sito richiamando le due funzioni GetExpressCheckout (PayPal restituisce da questa chiamata un PayerID) e DoExpressCheckout (la transazione viene completata nel tuo sito).

    La struttura di queste funzioni è ben spiegata nel loro sito. Quello che non era ben spiegato è che devono essere utilizzate tutti nello stesso "flusso".

    Dove sono?
    Come le richiamo?
    Devo passare qualche valore?

  4. #4

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.