473,854 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Express Checkout flow

50 New Member
hey im getting error in paypalfunction. php like (Parse error: syntax error, unexpected T_IF).

when i inserted this code to my shipping cart.

Expand|Select|Wrap|Line Numbers
  1. <form id="frm2" name="frm2" method="post" action="expresscheckout.php">
  2.   <input name="Button" type="button" class='button' value="Keep Shopping" onclick="window.open('../index.php','_self');"/>
  3.   <input type='image' name='submit' src='https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif' border='0' align='top' alt='PayPal'/>
  4.  
  5. <?php $_SESSION["Payment_Amount"]=$totalCost; ?>
  6. <input type="hidden" name="totalCost" value="<?php echo $_SESSION["Payment_Amount"]=$totalCost;  ?>" />
  7. </form>

when i click on the logo, it gives the error in paypalfunction. php like this Parse error: syntax error, unexpected T_IF in C:\wamp\www\tes t1\paypalfuncti ons.php on line 216
Im new to paypal.i have got the Merchant Login and password,and i have inserted password in the $API_Password filed.

plz help
Attached Files
File Type: txt New Text Document.txt (21.7 KB, 1531 views)
Jan 18 '10 #1
16 6847
Dormilich
8,658 Recognized Expert Moderator Expert
which is line 216?
Jan 18 '10 #2
sidhx
50 New Member
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     /********************************************
  3.     Payflow API Module
  4.  
  5.     Defines all the global variables and the wrapper functions 
  6.     ********************************************/
  7.     $PROXY_HOST = '127.0.0.1';
  8.     $PROXY_PORT = '808';
  9.  
  10.     $Env = "live";
  11.  
  12.     //'------------------------------------
  13.     //' Payflow API Credentials 
  14.     //'------------------------------------
  15.     $API_User="xxxxxxxx";
  16.     // Fill in the API_Password variable yourself, the wizard will not do this automatically
  17.     $API_Password="xxxxxx";
  18.     $API_Vendor="xxxxxxxx";
  19.     $API_Partner="PayPal";
  20.  
  21.     // BN Code
  22.     $sBNCode = "PF-ECWizard";
  23.  
  24.     /*    
  25.     ' Define the PayPal Redirect URLs.  
  26.     '     This is the URL that the buyer is first sent to do authorize payment with their paypal account
  27.     '     change the URL depending if you are testing on the sandbox or the live PayPal site
  28.     '
  29.     ' For the sandbox, the URL is https://www.sandbox.paypal.com/cgi-b...heckout&token=
  30.     ' For the live site, the URL is https://www.paypal.com/cgi-bin/websc...heckout&token=
  31.     */
  32.  
  33.     if ($Env == "pilot") 
  34.     {
  35.         $API_Endpoint = "https://pilot-payflowpro.paypal.com";
  36.         $PAYPAL_URL = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
  37.     }
  38.     else
  39.     {
  40.         $API_Endpoint = "https://payflowpro.paypal.com";
  41.         $PAYPAL_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
  42.     }
  43.  
  44.     $USE_PROXY = false;
  45.  
  46.     if (session_id() == "") 
  47.         session_start();
  48.  
  49.     /* An express checkout transaction starts with a token, that
  50.        identifies to PayPal your transaction
  51.        In this example, when the script sees a token, the script
  52.        knows that the buyer has already authorized payment through
  53.        paypal.  If no token was found, the action is to send the buyer
  54.        to PayPal to first authorize payment
  55.        */
  56.  
  57.     /*   
  58.     '-------------------------------------------------------------------------------------------------------------------------------------------
  59.     ' Purpose:     Prepares the parameters for the shortcut implementation of SetExpressCheckout
  60.     ' Inputs:  
  61.     '        paymentAmount:      Total value of the shopping cart
  62.     '        currencyCodeType:     Currency code value
  63.     '        paymentType:         paymentType has to be one of the following values: Sale or Order or Authorization
  64.     '        returnURL:            the page where buyers return to after they are done with the payment review on PayPal
  65.     '        cancelURL:            the page where buyers return to when they cancel the payment review on PayPal
  66.     '--------------------------------------------------------------------------------------------------------------------------------------------    
  67.     */
  68.     function CallShortcutExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL) 
  69.     {
  70.         //------------------------------------------------------------------------------------------------------------------------------------
  71.         // Construct the parameter string that describes SetExpressCheckout in the shortcut implementation
  72.  
  73.         $nvpstr = "&TENDER=P&ACTION=S";
  74.         if ("Sale" == $paymentType)
  75.         {
  76.             $nvpstr .= "&TRXTYPE=S";
  77.         }
  78.         elseif ("Authorization" == $paymentType)
  79.         {
  80.             $nvpstr .= "&TRXTYPE=A";
  81.         }
  82.         else //default to sale
  83.         {
  84.             $nvpstr .= "&TRXTYPE=S";
  85.         }
  86.         $nvpstr .= "&AMT=" . $paymentAmount;
  87.         $nvpstr .= "&CURRENCY=" . $currencyCodeType;
  88.         $nvpstr .= "&CANCELURL=" . $cancelURL;
  89.         $nvpstr .= "&RETURNURL=" . $returnURL;
  90.  
  91.         $_SESSION["currencyCodeType"] = $currencyCodeType;      
  92.         $_SESSION["PaymentType"] = $paymentType;
  93.  
  94.         // Each part of Express Checkout must have a unique request ID.
  95.         $unique_id = generateGUID();
  96.  
  97.         //'--------------------------------------------------------------------------------------------------------------- 
  98.         //' Make the API call to Payflow
  99.         //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.  
  100.         //' If an error occured, show the resulting errors
  101.         //'---------------------------------------------------------------------------------------------------------------
  102.         $resArray = hash_call($nvpstr,$unique_id);
  103.         $ack = strtoupper($resArray["RESULT"]);
  104.         if($ack=="0")
  105.         {
  106.             $token = urldecode($resArray["TOKEN"]);
  107.             $_SESSION['TOKEN']=$token;
  108.         }
  109.  
  110.         return $resArray;
  111.     }
  112.  
  113.     /*   
  114.     '-------------------------------------------------------------------------------------------------------------------------------------------
  115.     ' Purpose:     Prepares the parameters for the mark implementation of SetExpressCheckout
  116.     ' Inputs:  
  117.     '        paymentAmount:      Total value of the shopping cart
  118.     '        currencyCodeType:     Currency code value the PayPal API
  119.     '        paymentType:         paymentType has to be one of the following values: Sale or Order or Authorization
  120.     '        returnURL:            the page where buyers return to after they are done with the payment review on PayPal
  121.     '        cancelURL:            the page where buyers return to when they cancel the payment review on PayPal
  122.     '        shipToName:            the Ship to name entered on the merchant's site
  123.     '        shipToStreet:        the Ship to Street entered on the merchant's site
  124.     '        shipToCity:            the Ship to City entered on the merchant's site
  125.     '        shipToState:        the Ship to State entered on the merchant's site
  126.     '        shipToCountryCode:    the Code for Ship to Country entered on the merchant's site
  127.     '        shipToZip:            the Ship to ZipCode entered on the merchant's site
  128.     '        shipToStreet2:        the Ship to Street2 entered on the merchant's site
  129.     '        phoneNum:            the phoneNum  entered on the merchant's site
  130.     '--------------------------------------------------------------------------------------------------------------------------------------------    
  131.     */
  132.     function CallMarkExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, 
  133.                                       $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState,
  134.                                       $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum
  135.                                     ) 
  136.     {
  137.         //------------------------------------------------------------------------------------------------------------------------------------
  138.         // Construct the parameter string that describes SetExpressCheckout in the mark implementation
  139.  
  140.         $nvpstr = "&TENDER=P&ACTION=S";
  141.         if ("Sale" == $paymentType)
  142.         {
  143.             $nvpstr .= "&TRXTYPE=S";
  144.         }
  145.         elseif ("Authorization" == $paymentType)
  146.         {
  147.             $nvpstr .= "&TRXTYPE=A";
  148.         }
  149.         else //default to sale
  150.         {
  151.             $nvpstr .= "&TRXTYPE=S";
  152.         }
  153.         $nvpstr .= "&AMT=" . $paymentAmount;
  154.         $nvpstr .= "&CURRENCY=" . $currencyCodeType;
  155.         $nvpstr .= "&CANCELURL=" . $cancelURL;
  156.         $nvpstr .= "&RETURNURL" . $returnURL;
  157.         $nvpstr .= "&SHIPTOSTREET=" . $shipToStreet;
  158.         $nvpstr .= "&SHIPTOSTREET2=" . $shipToStreet2;
  159.         $nvpstr .= "&SHIPTOCITY=" . $shipToCity;
  160.         $nvpstr .= "&SHIPTOSTATE=" . $shipToState;
  161.         $nvpstr .= "&SHIPTOCOUNTRY=" . $shipToCountryCode;
  162.         $nvpstr .= "&SHIPTOZIP=" . $shipToZip;
  163.         $nvpstr .= "&ADDROVERRIDE=1";    // address override
  164.  
  165.         $_SESSION["currencyCodeType"] = $currencyCodeType;      
  166.         $_SESSION["PaymentType"] = $paymentType;
  167.  
  168.         // Each part of Express Checkout must have a unique request ID.
  169.         $unique_id = generateGUID();
  170.  
  171.         //'--------------------------------------------------------------------------------------------------------------- 
  172.         //' Make the API call to Payflow
  173.         //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.  
  174.         //' If an error occured, show the resulting errors
  175.         //'---------------------------------------------------------------------------------------------------------------
  176.         $resArray = hash_call($nvpstr,$unique_id);
  177.         $ack = strtoupper($resArray["RESULT"]);
  178.         if($ack=="0")
  179.         {
  180.             $token = urldecode($resArray["TOKEN"]);
  181.             $_SESSION['TOKEN']=$token;
  182.         }
  183.  
  184.         return $resArray;
  185.     }
  186.  
  187.     /*
  188.     '-------------------------------------------------------------------------------------------
  189.     ' Purpose:     Prepares the parameters for GetExpressCheckoutDetails.
  190.     '
  191.     ' Inputs:  
  192.     '        None
  193.     ' Returns: 
  194.     '        The NVP Collection object of the GetExpressCheckoutDetails response.
  195.     '-------------------------------------------------------------------------------------------
  196.     */
  197.     function GetShippingDetails( $token )
  198.     {
  199.         //'--------------------------------------------------------------
  200.         //' At this point, the buyer has completed authorizing the payment
  201.         //' through Payflow.  The function will call Payflow to obtain the details
  202.         //' of the authorization, incuding any shipping information of the
  203.         //' buyer.  Remember, the authorization is not a completed transaction
  204.         //' at this state - the buyer still needs an additional step to finalize
  205.         //' the transaction
  206.         //'--------------------------------------------------------------
  207.  
  208.         //'---------------------------------------------------------------------------
  209.         //' Build a second API request to Payflow, using the token as the
  210.         //'  ID to get the details on the payment authorization
  211.         //'---------------------------------------------------------------------------
  212.         $paymentType = $_SESSION['paymentType'];
  213.         $nvpstr = "&TOKEN=" . $token . "&TENDER=P&ACTION=G"
  214.         if ("Sale" == $paymentType)
  215.         {
  216.             $nvpstr .= "&TRXTYPE=S";
  217.         }
  218.         elseif ("Authorization" == $paymentType)
  219.         {
  220.             $nvpstr .= "&TRXTYPE=A";
  221.         }
  222.         else //default to sale
  223.         {
  224.             $nvpstr .= "&TRXTYPE=S";
  225.         }
  226.  
  227.         // Each part of Express Checkout must have a unique request ID.
  228.         $unique_id = generateGUID();
  229.  
  230.         //'---------------------------------------------------------------------------
  231.         //' Make the API call and store the results in an array.  
  232.         //'    If the call was a success, show the authorization details, and provide
  233.         //'     an action to complete the payment.  
  234.         //'    If failed, show the error
  235.         //'---------------------------------------------------------------------------
  236.         $resArray = hash_call($nvpstr,$unique_id);
  237.         $ack = strtoupper($resArray["RESULT"]);
  238.         if($ack == "0")
  239.         {    
  240.             $_SESSION['payer_id'] =    $resArray['PAYERID'];
  241.         } 
  242.         return $resArray;
  243.     }
  244.  
  245.     /*
  246.     '-------------------------------------------------------------------------------------------------------------------------------------------
  247.     ' Purpose:     Prepares the parameters for DoExpressCheckoutPayment.
  248.     '
  249.     ' Inputs:  
  250.     '        FinalPaymentAmt - the total transaction amount.
  251.     ' Returns: 
  252.     '        The NVP Collection object of the DoExpressCheckoutPayment response.
  253.     ' Note:
  254.     '       There are other optional parameters that can be passed to DoExpressCheckoutPayment that are not used here.
  255.     '       See Table 7.6 in http://www.paypal.com/en_US/pdf/PayflowPro_Guide.pdf for details on the optional parameters.
  256.     '--------------------------------------------------------------------------------------------------------------------------------------------    
  257.     */
  258.     function ConfirmPayment( $FinalPaymentAmt )
  259.     {
  260.         /* Gather the information to make the final call to
  261.            finalize the PayPal payment.  The variable nvpstr
  262.            holds the name value pairs
  263.            */
  264.  
  265.         //Format the other parameters that were stored in the session from the previous calls    
  266.         $token                 = $_SESSION['token'];
  267.         $paymentType         = $_SESSION['paymentType'];
  268.         $currencyCodeType     = $_SESSION['currencyCodeType'];
  269.         $payerID             = $_SESSION['payer_id'];
  270.  
  271.         $serverName         = $_SERVER['SERVER_NAME'];
  272.  
  273.         $nvpstr = "&TENDER=P&ACTION=D";
  274.         if ("Sale" == $paymentType)
  275.         {
  276.             $nvpstr .= "&TRXTYPE=S";
  277.         }
  278.         elseif ("Authorization" == $paymentType)
  279.         {
  280.             $nvpstr .= "&TRXTYPE=A";
  281.         }
  282.         else //default to sale
  283.         {
  284.             $nvpstr .= "&TRXTYPE=S";
  285.         }
  286.  
  287.         $nvpstr .= "&TOKEN=" . $token . "&PAYERID=" . $payerID . "&AMT=" . $FinalPaymentAmt;
  288.         $nvpstr .= '&CURRENCY=' . $currencyCodeType . '&IPADDRESS=' . $serverName;
  289.  
  290.         // Each part of Express Checkout must have a unique request ID.
  291.         // Save it as a session variable in order to avoid duplication
  292.         $unique_id = isset($_SESSION['unique_id']) ? $_SESSION['unique_id'] : generateGUID();
  293.         $_SESSION['unique_id'] = $unique_id;
  294.  
  295.          /* Make the call to PayPal to finalize payment
  296.             If an error occured, show the resulting errors
  297.             */
  298.         $resArray = hash_call($nvpstr,$unique_id);
  299.  
  300.         /* Display the API response back to the browser.
  301.            If the response from PayPal was a success, display the response parameters'
  302.            If the response was an error, display the errors received using APIError.php.
  303.            */
  304.         $ack = strtoupper($resArray["RESULT"]);
  305.  
  306.         return $resArray;
  307.     }
  308.  
  309.     /*
  310.     '-------------------------------------------------------------------------------------------------------------------------------------------
  311.     ' Purpose:     Prepares the parameters for direct payment (credit card) and makes the call.
  312.     '
  313.     ' Inputs:  
  314.     '        paymentType:         paymentType has to be one of the following values: Sale or Order
  315.     '        paymentAmount:      Total value of the shopping cart
  316.     '        creditCardType        Credit card type has to one of the following values: Visa or MasterCard or Discover or Amex or Switch or Solo 
  317.     '        creditCardNumber    Credit card number
  318.     '        expDate                Credit expiration date
  319.     '        cvv2                CVV2
  320.     '        firstName            Customer's First Name
  321.     '        lastName            Customer's Last Name
  322.     '        street                Customer's Street Address
  323.     '        city                Customer's City
  324.     '        state                Customer's State                
  325.     '        zip                    Customer's Zip                    
  326.     '        countryCode            Customer's Country represented as a PayPal CountryCode
  327.     '        currencyCode        Customer's Currency represented as a PayPal CurrencyCode
  328.     '        orderdescription    Short textual description of the order
  329.     '
  330.     ' Note:
  331.     '        There are other optional inputs for credit card processing that are not presented here.
  332.     '        For a complete list of inputs available, please see the documentation here for US and UK:
  333.     '        http://www.paypal.com/en_US/pdf/PayflowPro_Guide.pdf
  334.     '        https://www.paypal.com/en_GB/pdf/PP_...ationGuide.pdf
  335.     '        
  336.     ' Returns: 
  337.     '        The NVP Collection object of the Response.
  338.     '--------------------------------------------------------------------------------------------------------------------------------------------    
  339.     */
  340.     function DirectPayment( $paymentType, $paymentAmount, $creditCardType, $creditCardNumber, $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, $countryCode, $currencyCode, $orderdescription )
  341.     {
  342.         // Construct the parameter string that describes the credit card payment
  343.         $replaceme = array("-", " ");
  344.         $card_num = str_replace($replaceme,"",$creditCardNumber);
  345.  
  346.         $nvpstr = "&TENDER=C";
  347.         if ("Sale" == $paymentType)
  348.         {
  349.             $nvpstr .= "&TRXTYPE=S";
  350.         }
  351.         elseif ("Authorization" == $paymentType)
  352.         {
  353.             $nvpstr .= "&TRXTYPE=A";
  354.         }
  355.         else //default to sale
  356.         {
  357.             $nvpstr .= "&TRXTYPE=S";
  358.         }
  359.  
  360.         // Other information
  361.         $ipaddr = $_SERVER['REMOTE_ADDR'];
  362.  
  363.         $nvpstr .= '&ACCT='.$card_num.'&CVV2='.$cvv2.'&EXPDATE='.$expDate.'&ACCTTYPE='.$creditCardType.'&AMT='.$paymentAmount.'&CURRENCY='.$currencyCode;
  364.         $nvpstr .= '&FIRSTNAME='.$firstName.'&LASTNAME='.$lastName.'&STREET='.$street.'&CITY='.$city.'&STATE='.$state.'&ZIP='.$zip.'&COUNTRY='.$countryCode;
  365.         $nvpstr .= '&CLIENTIP='.$ipaddr.'&INVNUM='.$order_num.'&ORDERDESC='.$orderdescription;
  366.         // Transaction results (especially values for declines and error conditions) returned by each PayPal-supported
  367.         // processor vary in detail level and in format. The Payflow Verbosity parameter enables you to control the kind
  368.         // and level of information you want returned. 
  369.         // By default, Verbosity is set to LOW. A LOW setting causes PayPal to normalize the transaction result values. 
  370.         // Normalizing the values limits them to a standardized set of values and simplifies the process of integrating 
  371.         // the Payflow SDK.
  372.         // By setting Verbosity to MEDIUM, you can view the processor’s raw response values. This setting is more “verbose”
  373.         // than the LOW setting in that it returns more detailed, processor-specific information. 
  374.         // Review the chapter in the Developer's Guides regarding VERBOSITY and the INQUIRY function for more details.
  375.         // Set the transaction verbosity to MEDIUM.
  376.         $nvpstr .= '&VERBOSITY=MEDIUM';
  377.  
  378.         // The $unique_id field is storing our unique id that we'll use in the request id header.
  379.         $unique_id = date('ymd-H').rand(1000,9999);        
  380.  
  381.         '-------------------------------------------------------------------------------------------
  382.         ' Make the call to Payflow to finalize payment
  383.         ' If an error occured, show the resulting errors
  384.         '-------------------------------------------------------------------------------------------
  385.         $resArray = hash_call($nvpstr,$unique_id);
  386.  
  387.         return $resArray;
  388.     }
  389.  
  390.     /**
  391.       '-------------------------------------------------------------------------------------------------------------------------------------------
  392.       * hash_call: Function to perform the API call to Payflow
  393.       * @nvpStr is nvp string.
  394.       * returns an associtive array containing the response from the server.
  395.       '-------------------------------------------------------------------------------------------------------------------------------------------
  396.     */
  397.     function hash_call($nvpStr,$unique_id)
  398.     {
  399.         //declaring of global variables
  400.         global $API_Endpoint, $API_User, $API_Password, $API_Vendor, $API_Partner;
  401.         global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
  402.         global $gv_ApiErrorURL;
  403.         global $sBNCode;
  404.  
  405.  
  406.         //NVPRequest for submitting to server
  407.         $nvpreq = "USER=".$API_User.'&VENDOR='.$API_Vendor.'&PARTNER='.$API_Partner.'&PWD='.$API_Password . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode);
  408.  
  409.         $len = strlen($nvpreq);
  410.  
  411.         $headers[] = "Content-Type: text/namevalue";
  412.         $headers[] = "Content-Length: ".$len
  413.         // Set the server timeout value to 45, but notice below in the cURL section, the timeout
  414.         // for cURL is set to 90 seconds.  Make sure the server timeout is less than the connection.
  415.         $headers[] = "X-VPS-CLIENT-TIMEOUT: 45";
  416.         $headers[] = "X-VPS-REQUEST-ID:" . $unique_id;
  417.  
  418.         // set the host header
  419.         if ($Env == "pilot") 
  420.         {
  421.             $headers[] = "Host: pilot-payflowpro.paypal.com";
  422.         }
  423.         else
  424.         {
  425.             $headers[] = "Host: payflowpro.paypal.com";
  426.         }
  427.  
  428.         //setting the curl parameters.
  429.         $ch = curl_init();
  430.         curl_setopt($ch, CURLOPT_URL,$API_Endpoint);
  431.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  432.         curl_setopt($ch, CURLOPT_VERBOSE, 1);
  433.  
  434.         //turning off the server and peer verification(TrustManager Concept).
  435.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  436.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  437.  
  438.         curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  439.         curl_setopt($ch, CURLOPT_TIMEOUT, 90);         // times out after 90 secs
  440.         curl_setopt($ch, CURLOPT_POST, 1);
  441.  
  442.         //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
  443.         //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php 
  444.         if($USE_PROXY)
  445.             curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); 
  446.  
  447.  
  448.         //setting the nvpreq as POST FIELD to curl
  449.         curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
  450.  
  451.         //getting response from server
  452.         $response = curl_exec($ch);
  453.  
  454.         //convrting NVPResponse to an Associative Array
  455.         $nvpResArray=deformatNVP($response);
  456.         $nvpReqArray=deformatNVP($nvpreq);
  457.         $_SESSION['nvpReqArray']=$nvpReqArray;
  458.  
  459.         if (curl_errno($ch)) 
  460.         {
  461.             // moving to display page to display curl errors
  462.               $_SESSION['curl_error_no']=curl_errno($ch) ;
  463.               $_SESSION['curl_error_msg']=curl_error($ch);
  464.  
  465.               //Execute the Error handling module to display errors. 
  466.         } 
  467.         else 
  468.         {
  469.              //closing the curl
  470.               curl_close($ch);
  471.         }
  472.  
  473.         return $nvpResArray;
  474.     }
  475.  
  476.     /*'----------------------------------------------------------------------------------
  477.      Purpose: Redirects to PayPal.com site.
  478.      Inputs:  NVP string.
  479.      Returns: 
  480.     ----------------------------------------------------------------------------------
  481.     */
  482.     function RedirectToPayPal ( $token )
  483.     {
  484.         global $PAYPAL_URL;
  485.  
  486.         // Redirect to paypal.com here
  487.         $payPalURL = $PAYPAL_URL . $token;
  488.         header("Location: ".$payPalURL);
  489.     }
  490.  
  491.  
  492.     /*'----------------------------------------------------------------------------------
  493.      * This function will take NVPString and convert it to an Associative Array and it will decode the response.
  494.       * It is usefull to search for a particular key and displaying arrays.
  495.       * @nvpstr is NVPString.
  496.       * @nvpArray is Associative Array.
  497.        ----------------------------------------------------------------------------------
  498.       */
  499.     function deformatNVP($nvpstr)
  500.     {
  501.         $intial=0;
  502.          $nvpArray = array();
  503.  
  504.         while(strlen($nvpstr))
  505.         {
  506.             //postion of Key
  507.             $keypos= strpos($nvpstr,'=');
  508.             //position of value
  509.             $valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&'): strlen($nvpstr);
  510.  
  511.             /*getting the Key and Value values and storing in a Associative Array*/
  512.             $keyval=substr($nvpstr,$intial,$keypos);
  513.             $valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1);
  514.             //decoding the respose
  515.             $nvpArray[urldecode($keyval)] =urldecode( $valval);
  516.             $nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr));
  517.          }
  518.         return $nvpArray;
  519.     }
  520.  
  521.     function generateCharacter () {
  522.         $possible = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  523.         $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
  524.         return $char;
  525.     }
  526.  
  527.     function generateGUID () {
  528.         $GUID = generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter()."-";
  529.         $GUID = $GUID .generateCharacter().generateCharacter().generateCharacter().generateCharacter()."-";
  530.         $GUID = $GUID .generateCharacter().generateCharacter().generateCharacter().generateCharacter()."-";
  531.         $GUID = $GUID .generateCharacter().generateCharacter().generateCharacter().generateCharacter()."-";
  532.         $GUID = $GUID .generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter().generateCharacter();
  533.         return $GUID;
  534.     }
  535.  
  536. ?>
in this at the function named GetShippingDeta ils( $token )
at the line if ("Sale" == $paymentType) here it is giving error
as Parse error: syntax error, unexpected T_IF
Jan 18 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
line 213 is missing a semi-colon.

EDIT: please post in future not the whole code, the GetShippingDeta ils() function would have been enough.

rule of thumb: "unexpected T_*" means in 99% of the cases, that there is a basic syntax error like: missing semi-colon, missing (concatenation) operator, etc.
Jan 18 '10 #4
sidhx
50 New Member
error shows in line no. 214
Jan 18 '10 #5
Dormilich
8,658 Recognized Expert Moderator Expert
did you correct what I pointed out?
Jan 18 '10 #6
sidhx
50 New Member
yes Dormilich its in the line no. 214
Jan 18 '10 #7
Dormilich
8,658 Recognized Expert Moderator Expert
did you correct what I pointed out?!
Jan 18 '10 #8
sidhx
50 New Member
ok i corrected it but now i have error in Parse error: syntax error, unexpected T_STRING in on line 382
Jan 18 '10 #9
Dormilich
8,658 Recognized Expert Moderator Expert
correct, that whole comment is not a comment. compare it to the other comments and make the necessary adjustments.
Jan 18 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

11
7255
by: Robert Bowen | last post by:
Hello all. I have been given mock-ups (in static HTML) of some pages for a site I am working on. The client would like these pages to look exactly as they do now. The problem is that the content is dynamic, it comes from a database. My question -- with CSS (because with HTML tables I don't think it's possible) how can I make my text "flow" in two columns? eg. If there are 100 lines of content, I would like 50 to be in the 1st column, and...
2
321
by: Don Wash | last post by:
Hi There! How do I manipulate folders in Outlook Express (Not Outlook)? I need to read messages in the mail folders as well as newsgroups. I've search on the net but all I found is how to send mails using Outlook Express. But what I need is to read messages :P Please provide some pointers to VB.NET or C# example.
9
1767
by: Alvin Bruney [MVP] | last post by:
Exceptions must not be used to control program flow. I intend to show that this statement is flawed. In some instances, exceptions may be used to control program flow in ways that can lead to improved code readability and performance. Consider an application that must eliminate duplicates in a list. using system.collections;
0
1327
by: Mohan | last post by:
Hi, I am C# .NET learner. I wanted to do the checkout/CheckIn of the files which are under clearcase source control. Please let me know the procedure to checkout a file programmatically using C# libraries.
0
1413
by: kellyonlyone | last post by:
E-XD++ MFC Library Enterprise Edition V9.80 is released (100% Source Code)! ("The only Flow/Diagramming Kits that provides full source code of components for MFC and ActiveX in a single package!") -------------------------------------------------------------------------------- May 2, 2006 For more information (press only) please contact: Paul Chi UCanCode Software, Inc. Phone: (86) 755-26737501
1
7305
by: jecha | last post by:
I'm implementing a shopping cart but am having a problem in checking out a person who has added item in his/her shopping busket.The code for the checkout.php script is given below <? require_once('functions.inc.php'); session_start(); do_html_header("Checkout"); $cart = $_SESSION; if($cart&&array_count_values($cart)) { display_cart($cart,false,0); display_checkout_form($HTTP_POST_VARS);
15
4311
gregerly
by: gregerly | last post by:
Hello, I once again turn to this community of genius' for some help with a problem. I've got a shopping cart (which is working well so far) that I will be implementing all kinds of AJAX functionality on. However, first I want to make sure it works if javascript is not available. So when your on the shopping cart page, you can update the quantities then click Update Cart, which would update the totals, and refresh the shopping cart page,...
5
3888
by: =?Utf-8?B?SmltIFJvZGdlcnM=?= | last post by:
My question is simple: How does one debug ASP Classic with Microsoft Visual Web Developer Express 2005 ("VWD")? Looming in the back of anyone's mind when you see a posting like this on any newsgroup is "didn't this guy read the docs?" Frankly, I "sort of did" a number of times. I feel the days of "things that are intuitively obvious" to use long ago gave way to "things that are clear after a 'Hello World'" example. And those
1
1968
by: rockdale | last post by:
Checkout the link http://www.aim.com/aimexpress.adp and click the lunch aimexpress. they are written by ASPX. I am wondering do they use AJAX only or do they use some fancy javascript with RPC? Anybody knows? I am trying to achieve the same thing on my web application by using AJAX, but when the conversation box is refreshing, you can not scroll the scroll bar,
6
2629
omerbutt
by: omerbutt | last post by:
hi I nee d a little guidance regarding google checkout i searched it on google and it took me too a page where it asked me to login through google account and after logging in it was asking for my credit card info i dont want this i want the manual for configuring my site with google checkout can any1 help or send a link where i can get the manual ....... lookkng forward to markus gits Dormilich and acoder for help :( regards, Omer Aslam
0
9901
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11024
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7914
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5940
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4153
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.