• Login
  • Register
  • Zoek
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Filebase Entry
  • More Options

ICTscripters

Dé plek voor IT

Dé plek voor IT

Login

Geavanceerde opties
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Dé plek voor IT - ICTscripters
  2. Forum
  3. Scripting & programmeren
  4. PHP + SQL

Forum

  • Na 15 jaar terug van weggeweest: iCriminals.nl is terug (BETA)!

    Syntax 19 januari 2026 om 09:34
  • Developer Gezocht

    Mikevdk 10 januari 2026 om 18:57
  • Op zoek naar de legends

    Syntax 5 januari 2026 om 13:50
  • [FREE] WeFact Hosting module

    Jeroen.G 13 oktober 2025 om 14:09
  • Help testers nodig voor android app Urgent

    urgentotservices 26 september 2025 om 10:21
  • Versio vervanger

    Jeroen.G 25 augustus 2025 om 15:56
  • Afspraken systeem met planbeperking

    Lijno 1 augustus 2025 om 23:04
  • Partner Gezocht om meerdere NFT Collecties op Open Sea te Plaatsen

    NFT Art Designer 1 maart 2025 om 14:08

Marktplaats

  • Verschillende domeinen

    Syntax 8 februari 2026 om 09:57
  • 350 Nieuwe Domeinnamen Januari 2026

    shiga 1 februari 2026 om 14:21
  • 321 Nieuwe Domeinnamen December 2025

    shiga 1 januari 2026 om 10:26

Paypal API

  • J.Rijdes
  • 28 november 2012 om 17:27
  • J.Rijdes
    Elite members
    Ontvangen Reacties
    37
    Berichten
    1.581
    • 28 november 2012 om 17:27
    • #1

    Hallo,

    Ik heb voor het upgraden van packages een Paypal API.
    Werkt gewoon tot toebehoren. Alleen als op de pagina komt na de betaling (Return URL) krijg ik een error, maar de package wordt wel toegevoegd. Hoe zorg ik dat die error verdwijnt?

    Code
    Error : This transaction cannot be processed. The amount to be charged is zero.
    Array
    (
        [TIMESTAMP] => 2012%2d11%2d28T16%3a21%3a41Z
        [CORRELATIONID] => 89923af7f3542
        [ACK] => Failure
        [VERSION] => 76%2e0
        [BUILD] => 4181146
        [L_ERRORCODE0] => 10525
        [L_SHORTMESSAGE0] => Invalid%20Data
        [L_LONGMESSAGE0] => This%20transaction%20cannot%20be%20processed%2e%20The%20amount%20to%20be%20charged%20is%20zero%2e
        [L_SEVERITYCODE0] => Error
    )
    Success
    
    
    Your Transaction ID :3HD13476S0937414R
    Payment Received! Your product will be sent to you very soon!
    You will be redicted to the dashboard.
    Toon Meer

    Script:

    PHP
    <?php
    session_start();
    include_once("config.php");
    include_once("paypal.class.php");
    ?>
    		<!-- Here goes the content. -->
    		<section id="content" class="container_12 clearfix" data-sort="true">
    					<div class="grid_12">
    				<div class="box">
    				<div class="header"><h2>Paypal Checkout</h2></div>
    					<div class="content">
    				<?php
    
    
    if($_GET) //Post Data received from product list page.
    {
    	//Mainly we need 4 variables from an item, Item Name, Item Price, Item Number and Item Quantity.
    	$ItemName = mysql_real_escape_string($_GET["itemname"]); //Item Name
    	$ItemPrice = mysql_real_escape_string($_GET["itemprice"]); //Item Price
    	$ItemNumber = mysql_real_escape_string($_GET["itemnumber"]); //Item Number
    	$ItemQty = mysql_real_escape_string($_GET["itemQty"]); // Item Quantity
    	$ItemTotalPrice = ($ItemPrice*$ItemQty); //(Item Price x Quantity = Total) Get total amount of product; 
    
    
    	//Data to be sent to paypal
    	$padata = 	'&CURRENCYCODE='.urlencode($PayPalCurrencyCode).
    				'&PAYMENTACTION=Sale'.
    				'&ALLOWNOTE=1'.
    				'&PAYMENTREQUEST_0_CURRENCYCODE='.urlencode($PayPalCurrencyCode).
    				'&PAYMENTREQUEST_0_AMT='.urlencode($ItemTotalPrice).
    				'&PAYMENTREQUEST_0_ITEMAMT='.urlencode($ItemTotalPrice). 
    				'&L_PAYMENTREQUEST_0_QTY0='. urlencode($ItemQty).
    				'&L_PAYMENTREQUEST_0_AMT0='.urlencode($ItemPrice).
    				'&L_PAYMENTREQUEST_0_NAME0='.urlencode($ItemName).
    				'&L_PAYMENTREQUEST_0_NUMBER0='.urlencode($ItemNumber).
    				'&AMT='.urlencode($ItemTotalPrice).				
    				'&RETURNURL='.urlencode($PayPalReturnURL ).
    				'&CANCELURL='.urlencode($PayPalCancelURL);	
    		
    		//We need to execute the "SetExpressCheckOut" method to obtain paypal token
    		$paypal= new MyPayPal();
    		$httpParsedResponseAr = $paypal->PPHttpPost('SetExpressCheckout', $padata, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);
    		
    		//Respond according to message we receive from Paypal
    		if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"]))
    		{
    					
    				// If successful set some session variable we need later when user is redirected back to page from paypal. 
    				$_SESSION['itemprice'] =  $ItemPrice;
    				$_SESSION['totalamount'] = $ItemTotalPrice;
    				$_SESSION['itemName'] =  $ItemName;
    				$_SESSION['itemNo'] =  $ItemNumber;
    				$_SESSION['itemQTY'] =  $ItemQty;
    				
    				if($PayPalMode=='sandbox')
    				{
    					$paypalmode 	=	'.sandbox';
    				}
    				else
    				{
    					$paypalmode 	=	'';
    				}
    				//Redirect user to PayPal store with Token received.
    			 	$paypalurl ='https://www'.$paypalmode.'.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='.$httpParsedResponseAr["TOKEN"].'';
    				header('Location: '.$paypalurl);
    			 
    		}else{
    			//Show error message
    			echo '<div style="color:red"><b>Error : </b>'.urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]).'</div>';
    			echo '<pre>';
    			print_r($httpParsedResponseAr);
    			echo '</pre>';
    		}
    
    
    }
    
    
    //Paypal redirects back to this page using ReturnURL, We should receive TOKEN and Payer ID
    if(isset($_GET["token"]) && isset($_GET["PayerID"]))
    {
    	//we will be using these two variables to execute the "DoExpressCheckoutPayment"
    	//Note: we haven't received any payment yet.
    	
    	$token = $_GET["token"];
    	$playerid = $_GET["PayerID"];
    	
    	//get session variables
    	$ItemPrice 		= $_SESSION['itemprice'];
    	$ItemTotalPrice = $_SESSION['totalamount'];
    	$ItemName 		= $_SESSION['itemName'];
    	$ItemNumber 	= $_SESSION['itemNo'];
    	$ItemQTY 		=$_SESSION['itemQTY'];
    	
    	$padata = 	'&TOKEN='.urlencode($token).
    						'&PAYERID='.urlencode($playerid).
    						'&PAYMENTACTION='.urlencode("SALE").
    						'&AMT='.urlencode($ItemTotalPrice).
    						'&CURRENCYCODE='.urlencode($PayPalCurrencyCode);
    	
    	//We need to execute the "DoExpressCheckoutPayment" at this point to Receive payment from user.
    	$paypal= new MyPayPal();
    	$httpParsedResponseAr = $paypal->PPHttpPost('DoExpressCheckoutPayment', $padata, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);
    	
    	//Check if everything went ok..
    	if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) 
    	{
    			echo '<h1>Success</h2>';
    			echo 'Your Transaction ID :'.urldecode($httpParsedResponseAr["TRANSACTIONID"]);
    			
    				/*
    				//Sometimes Payment are kept pending even when transaction is complete. 
    				//May be because of Currency change, or user choose to review each payment etc.
    				//hence we need to notify user about it and ask him manually approve the transiction
    				*/
    				
    				if('Completed' == $httpParsedResponseAr["PAYMENTSTATUS"])
    				{
    					echo '<div style="color:green">Payment Received! Your product will be sent to you very soon!<br>You will be redicted to the dashboard. </div><meta http-equiv="refresh" content="4;URL=dashboard.php" />';
    				}
    				elseif('Pending' == $httpParsedResponseAr["PAYMENTSTATUS"])
    				{
    					echo '<div style="color:red">Transaction Complete, but payment is still pending! You need to manually authorize this payment in your <a target="_new" href="http://www.paypal.com">Paypal Account</a></div>';
    				}
    
    
    				$transactionID = urlencode($httpParsedResponseAr["TRANSACTIONID"]);
    				$nvpStr = "&TRANSACTIONID=".$transactionID;
    				$paypal= new MyPayPal();
    				$httpParsedResponseAr = $paypal->PPHttpPost('GetTransactionDetails', $nvpStr, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);
    
    
    				if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
    					
    					
    					#### SAVE BUYER INFORMATION IN DATABASE ###
    					$buyerName = $httpParsedResponseAr["FIRSTNAME"].' '.$httpParsedResponseAr["LASTNAME"];
    					$buyerEmail = $httpParsedResponseAr["EMAIL"];
    					$buyerCountry = $httpParsedResponseAr['COUNTRYCODE'];
    					$buyerStatus = $httpParsedResponseAr['PAYMENTSTATUS'];
    					$user_id = $user_info['id'];
    					
    					mysql_query("INSERT INTO orders 
    					(BuyerName,BuyerEmail,TransactionID,ItemNumber,ItemAmount,ItemQTY,Country,Status,Date)
    					VALUES 
    					('$buyerName','$buyerEmail','$transactionID','$ItemNumber','$ItemTotalPrice','$ItemQTY','$buyerCountry','$buyerStatus','.NOW().')");
    					
    					mysql_query("UPDATE users SET pack_id = '$ItemNumber' WHERE id = '$user_id'");
    		
    		
    				} else  {
    					echo '<div style="color:red"><b>GetTransactionDetails failed:</b>'.urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]).'</div>';
    					echo '<pre>';
    					print_r($httpParsedResponseAr);
    					echo '</pre>';
    
    
    				}
    	
    	}else{
    			echo '<div style="color:red"><b>Error : </b>'.urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]).'</div>';
    			echo '<pre>';
    			print_r($httpParsedResponseAr);
    			echo '</pre>';
    	}
    }
    ?>
    </div><!-- End of .content -->
    					
    				</div><!-- End of .box -->
    			</div><!-- End of .grid_4 -->
    					</section><!-- End of #content -->
    Toon Meer

Participate now!

Heb je nog geen account? Registreer je nu en word deel van onze community!

Maak een account aan Login

ICT Nieuws

  • Fijne feestdagen

    tcbhome 28 december 2025 om 13:55
  • Kritieke update voor Really Simple Security-plug-in

    K.Rens 16 november 2024 om 16:12
  • ING Nederland streeft naar ondersteuning van Google Pay tegen eind februari

    K.Rens 2 november 2024 om 16:09

Blogs

  • Functioneel ontwerp

    Dees 28 december 2014 om 12:38
  • Access Control List implementatie in PHP/MySQL - deel 1/2

    FangorN 28 december 2018 om 12:35
  • Access Control List implementatie in PHP/MySQL - deel 2/2

    FangorN 29 december 2018 om 12:37

Gebruikers die dit topic bekijken

  • 1 Gasten
  1. Marktplaats
  2. Design
  3. Voorwaarden
  4. Ons team
  5. Leden
  6. Geschiedenis
  7. Regels
  8. Links
  9. Privacy Policy
ICTscripters ©2005 - 2026 , goedkope hosting door DiMoWeb.com, BE0558.915.582
Sponsors: Beste kattenhotel provincie Antwerpen | Beste Zetes eid kaartlezer webshop
Style: Nexus by cls-design
Stylename
Nexus
Manufacturer
cls-design
Licence
Commercial styles
Help
Supportforum
Visit cls-design