简体   繁体   English

使用托管页面通过Express Checkout和信用卡付款进行Paypal高级定期结算

[英]Paypal Advanced Recurring billing with Express Checkout and Credit card payment using hosted pages

In my application, I need to set recurring billing section using paypal advanced and I am using the payflow section to do the same. 在我的应用程序中,我需要使用paypal advanced设置定期计费部分,而我使用payflow部分来执行相同的操作。 I need both Pay with PayPal button process (Express Checkout process) and Credit card payment to create the recurring profile. 我需要使用PayPal按钮付款(快速结帐流程)和信用卡付款来创建重复配置文件。 My initial request is like this: 我最初的要求是这样的:

public static PayPalRedirectAdv PayFlow()
{

    NameValueCollection requestArray = new NameValueCollection()
    {

        {"PARTNER", "PayPal"},             // You'll want to change these 4
        {"VENDOR", "merchantname"},           // To use your own credentials
        {"USER", "username"},
        {"PWD", "abcdenfg"},
        {"TRXTYPE", "A"},
        {"AMT", "1.00"},
        {"CURRENCY", "USD"},
        {"CREATESECURETOKEN", "Y"},
        {"SECURETOKENID", "tokenId generated"},  
        {"RETURNURL", UrlReturn}, 
        {"CANCELURL", UrlCancel},
        {"ERRORURL", lUrlError},
        {"BILLINGTYPE","RecurringBilling"}

    };

    NameValueCollection resp = run_payflow_call(requestArray); // Will call the payflow end point via HttpWebRequest
    if (resp["RESULT"] == "0")
    {
        string mode = "TEST";
        return new PayPalRedirectAdv
        {
            Url = "https://payflowlink.paypal.com?SECURETOKEN=" + resp["SECURETOKEN"] + "&SECURETOKENID=" + resp["SECURETOKENID"] + "&MODE=" + mode
        };
    }
    else
    {
        return new PayPalRedirectAdv { Url = string.Empty };
    }
}

Once the process is completed, I have set the url to an IFrame and it is embedded in one of my views in my mvc project. 该过程完成后,我将URL设置为IFrame,并将其嵌入到我的mvc项目中的一个视图中。 When the IFrame is loaded, it has two issues. 加载IFrame时,有两个问题。

1) The page is redirected to the top level. 1)页面被重定向到顶层。 This means that the browser window is redirected to IFrame url. 这意味着浏览器窗口将重定向到IFrame网址。 I have chosen Layout C as my hosted checkout page. 我选择Layout C作为托管的结帐页面。 When I use credentials supplied in the demo project, the browser navigation is solved; 当我使用演示项目中提供的凭据时,浏览器导航已解决; ie Iframe correctly loaded in my view. 即iframe正确加载在我的看法。 Is there any setting in the Paypal manager settings to prevent this? 贝宝管理器设置中是否有任何设置可以防止这种情况发生? I tried to fix this by sandboxing top level navigation, but this won't allow me to redirect to paypal site by clicking the "Check out with Paypal" button. 我试图通过沙盒顶级导航来解决此问题,但这不允许我单击“使用Paypal退房”按钮来重定向到Paypal网站。

2) For a payment with a Credit card, once the transaction is successful, I will convert the existing transaction to a profile by: 2)对于使用信用卡付款,一旦交易成功,我将通过以下方式将现有交易转换为个人资料:

    "TRXTYPE=R&TENDER=C&PARTNER=PayPal&VENDOR=Acme&USER=Acme&PWD=a1b2c3d4&ACTION=A&PROFILENAME=RegularSubscription&ORIGID=<PNREF>&START=12012002&PAYPERIOD=
WEEK&TERM=12&OPTIONALTRX=S&OPTIONALTRXAMT=2.00&COMMENT1=First-time
customer&AMT=42.00"

This works fine and the recurring profile is created. 这工作正常,并创建了定期配置文件。

However, when I click on the "Check out with Paypal" button, this will take me to the Paypal page where I could login to Paypal using my Paypal credentials and then when I click the "paynow" button, it will deduct money from my account. 但是,当我单击“使用Paypal签出”按钮时,这将带我到Paypal页面,在这里我可以使用我的Paypal凭据登录到Paypal,然后当我单击“ paynow”按钮时,它将从我的帐户中扣除钱帐户。 This also has an PNERF value and when I used the same code above to convert the transaction to recurring profile by replacing Tender as P, but it shows me a response message that "the transaction id corresponding to this id is not found". 这也具有PNERF值,当我使用上面相同的代码通过将Tender替换为P来将事务转换为重复配置文件时,它向我显示了一条响应消息,“未找到与此ID对应的事务ID”。 The Paypal checkout process doesn't show any information about the user is going for a reccuring payment section. 贝宝(Paypal)结帐流程不会显示有关用户要进行递归付款的任何信息。

Also, I followed Express Checkout with recurring billing to do the task, but I got BAID as null in the DoExpressCheckout step. 另外,我在Express Checkout之后进行了重复计费以完成任务,但是在DoExpressCheckout步骤中,BAID为空。

I need both pay with paypal and pay with credit options on my site, so what parameters should I use to accomplish this? 我在网站上既需要使用Paypal进行支付,又需要使用信用选项进行支付,那么应该使用哪些参数来完成此任务?

Thanks in advance. 提前致谢。

string strUsername = "<<paypal_username>>";
    string strPassword = "<<paypal_password>>";
    string strSignature = "<<paypal_signature>>";
    string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword + "&SIGNATURE=" + strSignature;

    string strNVPSandboxServer = "https://api-3t.sandbox.paypal.com/nvp";
    string strAPIVersion = "2.3";
    //4456193676582624                                                                   4025609244685781
    string strNVP = strCredentials + "&METHOD=DoDirectPayment" +
        "&CREDITCARDTYPE=VISA" +
         "&ACCT=<<CARDNO>>" +
         "&EXPDATE=<<EXPDATE>>" +
         "&CVV2=<<CVV>" +
         "&AMT=<<AMOUNT>>" +
         "&FIRSTNAME=<<CUST_NAME>>" +
         "&LASTNAME=<<CUST_LASTNAME>>" +
         "&CURRENCYCODE=<<CURRENCY_CODE>>" +
         "&IPADDRESS=<<USER_IP>>" +
         "&STREET=<<ADDRESS>>" +
         "&CITY=<<CITY>>" +
         "&STATE=<<STATE>>" +
         "&COUNTRY=<<COUNTRY>>" +
         "&ZIP=<<XIPCODE>>" +
         "&COUNTRYCODE=<<COUNTRY>>" +
         "&PAYMENTACTION=SALE" +
         "&L_NAME0=item1&L_DESC0=test1description&L_AMT0=1&L_QTY0=1" +
         "&L_NAME1=item2&L_DESC1=test2description&L_AMT1=2&L_QTY1=2" +
         "&L_NAME2=item3&L_DESC2=test3description&L_AMT2=3&L_QTY2=3" +
         "&VERSION=" + strAPIVersion;
    //strNVP = Server.UrlEncode(strNVP);
    try
    {
        //Create web request and web response objects, make sure you using the correct server (sandbox/live)
        HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer);
        wrWebRequest.Method = "POST";
        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();

        string result = Server.UrlDecode(responseData);

        string[] arrResult = result.Split('&');
        Hashtable htResponse = new Hashtable();
        string[] responseItemArray;
        foreach (string responseItem in arrResult)
        {
            responseItemArray = responseItem.Split('=');
            htResponse.Add(responseItemArray[0], responseItemArray[1]);
        }

        string strAck = htResponse["ACK"].ToString();

        if (strAck == "Success" || strAck == "SuccessWithWarning")
        {
            string strAmt = htResponse["AMT"].ToString();
            string strCcy = htResponse["CURRENCYCODE"].ToString();
            string strTransactionID = htResponse["TRANSACTIONID"].ToString();
            //ordersDataSource.InsertParameters["TransactionID"].DefaultValue = strTransactionID;

            string strSuccess = "Thank you, your order for: $" + strAmt + " " + strCcy + " has been processed.";
            Response.Write(strSuccess);
            //successLabel.Text = strSuccess;
        }
        else
        {
            string strErr = "Error: " + htResponse["L_LONGMESSAGE0"].ToString();
            string strErrcode = "Error code: " + htResponse["L_ERRORCODE0"].ToString();
            //errLabel.Text = strErr;
            //errcodeLabel.Text = strErrcode;
            return;
        }
    }
    catch (Exception ex)
    {
        // do something to catch the error, like write to a log file.
        Response.Write("error processing");
    }`enter code here`

try to use this code....no DLL needed to request for paypal payment. 尝试使用此代码。...不需要DLL来请求贝宝付款。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM