473,382 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Express Checkout flow

50
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\test1\paypalfunctions.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, 1527 views)
Jan 18 '10 #1
16 6818
Dormilich
8,658 Expert Mod 8TB
which is line 216?
Jan 18 '10 #2
sidhx
50
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 GetShippingDetails( $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 Expert Mod 8TB
line 213 is missing a semi-colon.

EDIT: please post in future not the whole code, the GetShippingDetails() 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
error shows in line no. 214
Jan 18 '10 #5
Dormilich
8,658 Expert Mod 8TB
did you correct what I pointed out?
Jan 18 '10 #6
sidhx
50
yes Dormilich its in the line no. 214
Jan 18 '10 #7
Dormilich
8,658 Expert Mod 8TB
did you correct what I pointed out?!
Jan 18 '10 #8
sidhx
50
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 Expert Mod 8TB
correct, that whole comment is not a comment. compare it to the other comments and make the necessary adjustments.
Jan 18 '10 #10
Markus
6,050 Expert 4TB
You are not writing BASIC here. Comment syntax is different.

Expand|Select|Wrap|Line Numbers
  1. /**
  2.  * Multi line comment
  3.  */
  4. // Single line comment #1
  5. # Single line comment #2
  6.  
Jan 18 '10 #11
sidhx
50
ok i got the minor error but now i get error in line no. 415 ($headers[] = "X-VPS-CLIENT-TIMEOUT: 45";) plz help me

im new to this,i just wanted to integrate express checkout flow in my page.

advanced thanks for supportting me.
Jan 19 '10 #12
sidhx
50
hey i just left ; sorry for it.
what does this function do curl_init()
Jan 19 '10 #13
sidhx
50
NOW I am getting this SetExpressCheckoutDetails API call failed. Error Message: Invalid amountError Code: 4
Jan 19 '10 #14
Dormilich
8,658 Expert Mod 8TB
curl_init()

the API error, I guess you made the wrong input. please refer to the API to correct the value.
Jan 19 '10 #15
sidhx
50
now it showing this SetExpressCheckoutDetails API call failed. Error Message: Invalid vendor accountError Code: 26
Jan 19 '10 #16
Dormilich
8,658 Expert Mod 8TB
sorry, I don’t know the details of this API, but any requirements/errors should be mentioned in the API documentation.
Jan 19 '10 #17

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

Similar topics

11
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...
2
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...
9
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...
0
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...
0
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!")...
1
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 <?...
15
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...
5
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...
1
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?...
6
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.