asp.net - 具有快速结账功能的 Paypal 获取 BillingAgreementID

标签 asp.net paypal paypal-sandbox paypal-nvp

我正在与使用快速结帐的 paypal 合作以获取计费协议(protocol) ID。

我遵循了这个指南:

https://www.x.com/developers/paypal/documentation-tools/how-authorize-and-run-reference-transaction-express-checkout

在我执行“SetExpressCheckout”时的第一步: 以下是代码

public string SetExpressCheckout(string Amount)
    {
        string returnURL = "http://localhost:50325/ReviewOrder.aspx" + "?amount=" + Amount + "&PAYMENTREQUEST_0_CURRENCYCODE=USD";
        string cancelURL = returnURL.Replace("ReviewOrder", "ExpCheckOut");
        string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword + "&SIGNATURE=" + strSignature;
        string strNVP = strCredentials;
        strNVP += "&PAYMENTREQUEST_0_PAYMENTACTION=AUTHORIZATION&&PAYMENTREQUEST_0_AMT=25" + "&L_BILLINGTYPE0=MerchantInitiatedBilling" + "&RETURNURL=" + returnURL;
        strNVP += "&CANCELURL=" + cancelURL;
        strNVP += "&METHOD=SetExpressCheckout&VERSION=" + strAPIVersion + "&DESC=test EC payment" +"&NOSHIPPING=0" ;
        //Create web request and web response objects, make sure you using the correct server (sandbox/live)
        HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer);
        //Set WebRequest Properties
        wrWebRequest.Method = "POST";
        // write the form values into the request message
        StreamWriter requestWriter = new StreamWriter(wrWebRequest.GetRequestStream());
        requestWriter.Write(strNVP);
        requestWriter.Close();
        // Get the response.
        HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
        StreamReader responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream());
        // and read the response
        string responseData = responseReader.ReadToEnd();
        responseReader.Close();
        return responseData;
    }

响应是:

    TOKEN=EC-09082530FY878870B&
    TIMESTAMP=2013-03-25T00:45:56Z&
    CORRELATIONID=3d33037174d55&
    ACK=SuccessWithWarning&
    VERSION=86&
    BUILD=5479129&
    L_ERRORCODE0=11452&
    L_SHORTMESSAGE0=Merchant not enabled for reference transactions&
    L_LONGMESSAGE0=Merchant not enabled for reference transactions&
    L_SEVERITYCODE0=Warning

如何在第 3 步中获得 BillingAgreeentd:

第 3 步的代码是:

public string GetBillingAgreementID()
    {
        string returnURL = "http://localhost:50325/ReviewOrder.aspx" + "?amount=" + Amount + "¤cy=USD";
        string cancelURL = returnURL.Replace("ReviewOrder", "ExpCheckOut");
        string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword + "&SIGNATURE=" + strSignature;
        string strNVP = strCredentials;
        strNVP += "&RETURNURL=" + returnURL;
        strNVP += "&CANCELURL=" + cancelURL;
        strNVP += "&METHOD=CreateBillingAgreement&VERSION=" + strAPIVersion + "&TOKEN=" + Session["Token"];
        //Create web request and web response objects, make sure you using the correct server (sandbox/live)
        HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer);
        //Set WebRequest Properties
        wrWebRequest.Method = "POST";
        // write the form values into the request message
        StreamWriter requestWriter = new StreamWriter(wrWebRequest.GetRequestStream());
        requestWriter.Write(strNVP);
        requestWriter.Close();
        // Get the response.
        HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
        StreamReader responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream());
        // and read the response
        string responseData = responseReader.ReadToEnd();
        responseReader.Close();
        return responseData;
    }

响应是:

 TIMESTAMP=2013-03-25T00:51:34Z&
 CORRELATIONID=854e6beed1e82&
 ACK=Failure&
 VERSION=86&
 BUILD=5479129&
 L_ERRORCODE0=11455&
 L_SHORTMESSAGE0=Buyer did not accept billing agreement&
 L_LONGMESSAGE0=Buyer did not accept billing agreement&
 L_SEVERITYCODE0=Error

如何获取 BillingAgreemntId? 是因为“L_SHORTMESSAGE0=Merchant not enabled for reference transactions”这条来自“SetExpressCheckout”的消息我无法获得 BillingAgreementID 吗?

请帮我解决这个问题。谢谢。

最佳答案

如果这是真实账户,您需要联系 PayPal 并请求在该账户上启用此功能。如果您需要在沙盒上启用它,您需要联系 PayPal MTS 并在您的沙盒帐户上启用它。

关于asp.net - 具有快速结账功能的 Paypal 获取 BillingAgreementID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15606074/

相关文章:

php - 错误 #520009 - 账户被限制

php - 我如何在为 wordpress 中的 woocommerce 商店选择货币的支付选项之间切换?

php - PayPal IPN HTTP 错误 400 - PHP - 使用 PayPal GIT 代码

php - 在缓存中找不到 Paypal 沙盒访问 token

Paypal 沙盒 'DoDirectPayment' 错误代码 10501

javascript - Asp.net Bower安装plotly.js不起作用

mysql - 无法加载文件或程序集 'MySql.Data, Version=6.8.3.0"或其依赖项之一。该系统找不到指定的文件

Android:使用替代支付服务

asp.net - SQL select 返回值到变量

asp.net - 我可以向 MVC 5 中的 Identity 2.0 生成的默认表添加新字段吗