【问题标题】:Disable Shipping details option in PayPal Checkout在 PayPal Checkout 中禁用配送详情选项
【发布时间】:2015-11-23 15:51:27
【问题描述】:

我正在使用PayPal Integration Wizard 在我的网站中使用 PayPal Checkout 我想禁用运输细节。我应该在哪个文件中进行哪些更改?

更新 这是我的 expresscheckout 文件,我也发布了 paypalfunctions.php 中的一部分。

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

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;
    }

【问题讨论】:

  • 在此处发布生成请求的代码部分,我会相应地为您调整。
  • 我下载了 expresscheckout.php 文件和 paypalfunctions.php 并将其他代码保存在 billinghandler.php、paymentreview.php 和 paymentconfirm.php 中。应该编辑哪些文件的哪些部分?
  • 不看就很难说。我个人不喜欢 PayPal 提供的集成向导。我构建了自己的PHP SDK for PayPal,我已经使用了多年,甚至他们自己的集成工程师也更喜欢它。您可能想看看它,因为它会使 API 调用对您来说非常快速和容易。至于当前的问题,我猜它可能在 expresscheckout.php 中。它应该在某个地方构建 API 请求参数。
  • 我已经发布了 expresscheckout.php 和 billinghandler.php,因为我认为它是提供账单详细信息的地方。尽管如此,我还是会尝试使用 PHP SDK,但由于紧急,请您暂时参考并指导我完成此操作。谢谢。
  • 这不像我们的 SDK 那样干净,但看起来您需要跟踪 CallMarkExpressCheckout() 函数。这一定是构建 API 调用的地方,您可以看到它只传递了一些可能的参数。所需要做的就是将 NOSHIPPING=1 添加到 API 请求中,因此如果您跟踪它,这将是一个简单的修复。

标签: paypal payment-gateway paypal-sandbox


【解决方案1】:

解决了。在 paypalfunctions.php 文件中的hash_call 函数中,用于提交到服务器的 NVPRequest 应更新为传递 NOSHIPPING=1 作为参数,如下所示。

//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);

【讨论】:

    猜你喜欢
    • 2011-05-16
    • 2015-04-22
    • 2017-04-17
    • 2021-06-06
    • 2017-09-06
    • 2018-02-07
    • 2014-04-24
    • 2012-05-30
    • 2023-03-25
    相关资源
    最近更新 更多