0
votes

I am using PayPal Checkout in my website using the PayPal Integration Wizard and I want to disable the shipping details. What changes should I make in which file?

Updated This is my expresscheckout file and I have posted a portion from the paypalfunctions.php as well.

expresscheckout.php

<?php

require_once ("paypalfunctions.php");
 $_SESSION["Payment_Amount"] =  $_POST["Payment_Amount"];
// ==================================
// 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 = $_SESSION["Payment_Amount"];

//'------------------------------------
//' The currencyCodeType and paymentType 
//' are set to the selections made on the Integration Assistant 
//'------------------------------------
$currencyCodeType = "USD";
$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://localhost/Reg/Components/PayPal/billinghandler.php";

//'------------------------------------
//' 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 = "http://localhost/Reg/Portal/SecretaryProfile.php";

//'------------------------------------
//' 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;
}
?>

a portion from paypalfunctions.php

function hash_call($methodName,$nvpStr)
    {
        //declaring of global variables
        global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature;
        global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
        global $gv_ApiErrorURL;
        global $sBNCode;

        //setting the curl parameters.
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$API_Endpoint);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);

        //turning off the server and peer verification(TrustManager Concept).
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_POST, 1);

        //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
       //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php 
        if($USE_PROXY)
            curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); 

        //NVPRequest for submitting to server
        $nvpreq="METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode);

        //setting the nvpreq as POST FIELD to curl
        curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

        //getting response from server
        $response = curl_exec($ch);

        //convrting NVPResponse to an Associative Array
        $nvpResArray=deformatNVP($response);
        $nvpReqArray=deformatNVP($nvpreq);
        $_SESSION['nvpReqArray']=$nvpReqArray;

        if (curl_errno($ch)) 
        {
            // moving to display page to display curl errors
              $_SESSION['curl_error_no']=curl_errno($ch) ;
              $_SESSION['curl_error_msg']=curl_error($ch);

              //Execute the Error handling module to display errors. 
        } 
        else 
        {
             //closing the curl
            curl_close($ch);
        }

        return $nvpResArray;
    }
1
Post the portion of code that is generating the request here and I'll adjust it for you accordingly.Drew Angell
I downloaded the expresscheckout.php file and paypalfunctions.php and saved the other codes in billinghandler.php, paymentreview.php and paymentconfirm.php. Which portions of which files should be edited?Asma Zinneera Jabir
It's tough to say without seeing it all. I personally don't like the integration wizard PayPal provides. I built my own PHP SDK for PayPal that I've been using for years, and even their own integration engineers prefer it. You may want to take a look at that as it will make API calls very quick and easy for you. As for the current problem, I would guess it's probably in expresscheckout.php. Somewhere it should be building the API request parameters.Drew Angell
I have posted the expresscheckout.php and billinghandler.php as I thought its where the billing details are being provided. Nonetheless, I shall try the PHP SDK but for the time being could you please refer to it and guide me through this as it is urgent. Thanks.Asma Zinneera Jabir
This isn't nearly as clean as our SDK is, but it looks like you need to track down the CallMarkExpressCheckout() function. That must be where the API call is getting built, and you can see it's only being passed a few of the possible parameters. All that needs to be done is to add NOSHIPPING=1 to the API request, so if you track that down it would be a simple fix.Drew Angell

1 Answers

0
votes

Solved. In the hash_call function in the paypalfunctions.php file, the NVPRequest for submitting to server should be updated with passing NOSHIPPING=1 as a parameter as below.

//NVPRequest for submitting to server
$nvpreq="METHOD=" . urlencode($methodName) ."&NOSHIPPING=1" . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode);