如何在PayPal高级版中创建定期配置文件

时间:2013-08-12 12:08:34

标签: paypal

我已经使用paypal网站付款标准实施了定期付款。我遵循的步骤是初始SetExpressCheckout-> GetExpresscheckout-> DoExpressCheckout-> CreateReccuringPayments Profile。代码如下SetExpressCheckout

public static PayPalRedirect ExpressCheckout()
    {
        NameValueCollection values = new NameValueCollection();

        values["METHOD"] = "SetExpressCheckout";
        values["RETURNURL"] = PayPalSettings.ReturnUrl;
        values["CANCELURL"] = PayPalSettings.CancelUrl;
        values["PAYMENTACTION"] = "Sale";
        values["CURRENCYCODE"] = "USD";
        values["BUTTONSOURCE"] = "XYZ";
        values["USER"] = PayPalSettings.Username;
        values["PWD"] = PayPalSettings.Password;
        values["SIGNATURE"] = PayPalSettings.Signature;
        values["SUBJECT"] = "";
        values["VERSION"] = "51.0";
        values["AMT"] = PayPalSettings.OrderAmount;
        values["L_BILLINGTYPE0"] = "RecurringPayments";
        values["L_BILLINGAGREEMENTDESCRIPTION0"] = "abcd";

        values = Submit(values);

        string ack = values["ACK"].ToLower();

        if (ack == "success" || ack == "successwithwarning")
        {
            return new PayPalRedirect
            {
                Token = values["TOKEN"],
                Url = String.Format("https://{0}/cgi-bin/webscr?cmd=_express-checkout&token={1}",
                   PayPalSettings.CgiDomain, values["TOKEN"])
            };
        }
        else
        {
            throw new Exception(values["L_LONGMESSAGE0"]);
        }
    }

OnSuccess响应将触及我的成功网址。我使用以下代码创建了我的定期配置文件。

 public ActionResult Success(string token)
{
    bool isSuccess = false;
    GetExpressCheckout getExpressCheckout = new GetExpressCheckout();
    GetExpressCheckoutDetailsResponseType getExpressCheckoutResponse = getExpressCheckout.ECGetExpressCheckoutCode(token);

    if (getExpressCheckoutResponse.Ack == AckCodeType.Success)
    {
        ExpressCheckout expressCheckout = new ExpressCheckout();
        DoExpressCheckoutPaymentResponseType doExpressCheckoutResponse = expressCheckout.DoExpressCheckoutPayment
                                                    (
                                                        token,
                                                        getExpressCheckoutResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID,
                                                        PayPalSettings.OrderAmount,
                                                        PaymentActionCodeType.Sale,
                                                        CurrencyCodeType.USD
                                                    );

        if (doExpressCheckoutResponse.Ack == AckCodeType.Success)
        {
            //create Recurring Payment Profile
            CreateRecurringPaymentsProfile createRecurringPaymentsProfile = new CreateRecurringPaymentsProfile();
            CreateRecurringPaymentsProfileResponseType recurringPaymentProfileResponse = createRecurringPaymentsProfile.CreateRecurringPaymentsProfileCode(
                                                                                            token,
                                                                                            doExpressCheckoutResponse.Timestamp.AddDays(7),
                                                                                            PayPalSettings.OrderAmount,
                                                                                            1,
                                                                                            BillingPeriodType.Week,
                                                                                            CurrencyCodeType.USD
                                                                                            );
            if (recurringPaymentProfileResponse.Ack == AckCodeType.Success)
            {
                //Transaction is successfull. 
                //insert record database
            }
        }
    }

   }

在沙盒环境中一切正常。当我搬到现场时,我的客户说这不能在现场模式下工作。所以在询问时,据说他已经升级到PayPal高级版,我在现场使用的api凭证是paypal高级商业帐户。所以我的问题是:

1)我的代码是否与使用paypal高级凭据的代码相同? 2)在paypal中创建重复配置文件的步骤是否相同?我需要paypal快速结账和信用卡交易付款吗?

非常感谢任何帮助。

提前致谢

1 个答案:

答案 0 :(得分:1)

步骤略有不同。快速概述如下,您首先要对Payflow端点进行API调用以生成安全令牌。这也是您传递参数的地方,表明您要为Express Checkout设置定期付款。然后,一旦您获得令牌,您就会将买家重定向到Payflow托管页面以完成付款。完成此操作后,您可以使用为客户创建的bililng协议ID来创建定期结算配置文件。