Paypal 与快速结帐以获取 BillingAgreementID

Posted

技术标签:

【中文标题】Paypal 与快速结帐以获取 BillingAgreementID【英文标题】:Paypal with express checkout to get BillingAgreementID 【发布时间】:2013-03-14 10:03:05 【问题描述】:

我正在与 paypal 合作,使用快速结帐来获取帐单协议 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 步中获得 BillingAgreentd:

第 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?

请帮助我。谢谢。

【问题讨论】:

【参考方案1】:

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

【讨论】:

以上是关于Paypal 与快速结帐以获取 BillingAgreementID的主要内容,如果未能解决你的问题,请参考以下文章

PayPal 快速结帐在 MVC .net 中以 html 形式返回响应

如何在 asp.net 中集成 Paypal Api 以进行快速结帐?

Paypal 快速结帐剩余销售税

Paypal 定期付款 - 快速结帐 APPID 被拒绝

Paypal 快速结帐支付更多(问题)

如何获取新的 PayPal Express Checkout UI