简体   繁体   English

如何使用asp.net取消Paypal中的最后一个订阅

[英]how to cancel last subscription in paypal using asp.net

Hi i am using recurring paypal subscription button that works perfectly.But i want to know the way to cancel last subscription of same user. 您好,我使用的是完美运作的Paypal定期订阅按钮。但我想知道取消同一用户最后一次订阅的方法。

Explanation: 说明:

I have 1 user,3 users and 6 users plans. 我有1个用户,3个用户和6个用户计划。

I did the subscription part for all types now what i want: 我现在为所有类型做了订阅部分:

lets say user change from one user to three users and go to payment screen to upgrade Will the last subscription will end automatically or not. 假设用户从一个用户更改为三个用户,然后转到付款屏幕进行升级,则最后一个订阅是否会自动结束。

i found this code for cancel subscription: 我发现此代码可取消订阅:

<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=SGGGX43FAKKXN">

this is the code i use for subscription button that works perfectly: 这是我用于订阅按钮的代码,可以完美地工作:

 protected void btnsubscribe_Click(object sender, EventArgs e)
{
    decimal amt = 0;
    if (ddlPlanType.SelectedValue.ToString() != "6")
    {
        amt = Convert.ToDecimal(ddlPlanType.SelectedValue);
    }
    else
    {
        int userNo = 0;
        if (txtusers.Text.Trim() != "")
            userNo = Convert.ToInt32(txtusers.Text);
        amt = Convert.ToDecimal(ddlPlanType.Items[2].Value) + Convert.ToDecimal(10.95 * userNo);
    }
    int qty = Convert.ToInt32(rdoplantype.SelectedValue);
    StringBuilder sb = new StringBuilder();
    sb.Append("business=" + ConfigurationManager.AppSettings["paypalemail"].ToString());
    sb.Append("&return=" + ConfigurationManager.AppSettings["SuccessURL"].ToString());
    sb.Append("&cancel_return=" + Server.UrlEncode(ConfigurationManager.AppSettings["FailedURL"].ToString()));
    sb.Append("&button_subtype=services&upload=1&no_note=1&rm=2");
    sb.Append("&currency_code=USD&cmd=_xclick-subscriptions&src=1&modify=0&item_number=Standard&p3=1");
    if (qty == 1)
    {
        Server.UrlEncode(sb.AppendFormat("&t3={0}",  "M").ToString());
        Server.UrlEncode(sb.AppendFormat("&a3={0}", amt).ToString());
    }
    else if (qty == 12)
    {

        Server.UrlEncode(sb.AppendFormat("&t3={0}",  "Y").ToString());
        Server.UrlEncode(sb.AppendFormat("&a3={0}", amt*12).ToString());
    }
    Server.UrlEncode(sb.AppendFormat("&item_name={0}", ddlPlanType.SelectedItem.Text + " " + txtusers.Text).ToString());
    Response.Redirect(ConfigurationManager.AppSettings["PayPalUrl"].ToString() + sb.ToString());
    Response.Redirect("Success.aspx");
}

Does this code works for cancel last subscription? 此代码对取消上一次订阅有效吗?

<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=SGGGX43FAKKXN">

Thanks 谢谢

The code does not actually cancel the subscription. 该代码实际上并没有取消订阅。 This example was taken from the docuentation: 此示例摘自文档:

<A HREF="https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=alice%40mystore%2ecom"><IMG BORDER="0"SRC="https://www.paypalobjects.com/en_US/i/btn/btn_unsubscribe_LG.gif"></A>

It displays an "Unsubscribe" button image to the user that links to the subscription cancellation function on the PayPal website. 它向用户显示“取消订阅”按钮图像,该图像链接到PayPal网站上的取消订阅功能。 the user must log into their PayPal account to continue. 用户必须登录其PayPal帐户才能继续。 the email address or payer ID here: 此处的电子邮件地址或付款人ID:

cmd=_subscr-find&alias=alice%40mystore%2ecom

is identifying you as the subscription provider to be cancelled. 将您标识为要取消的订阅提供者。 they will have to click another "Unsubscribe" button here to complete the process. 他们将必须在此处单击另一个“取消订阅”按钮以完成该过程。

<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=SGGGX43FAKKXN">
    <img src="https://www.paypalobjects.com/en_US/i/btn/btn_unsubscribe_LG.gif" BORDER="0">
</a>

This HTML makes it very easy for us to create an Unsubscribe button and place it wherever we want. 此HTML使我们可以非常轻松地创建“取消订阅”按钮并将其放置在所需的位置。 Before we can use this, though, we need to make one change to the href attribute. 但是,在使用此功能之前,我们需要对href属性进行一次更改。 At the end of the URL for the href, you'll see alias=SGGGX43FAKKXN. 在href的网址末尾,您会看到alias = SGGGX43FAKKXN。 This alias parameter is defined by PayPal as “the secure merchant account ID of the subscription provider's PayPal account. PayPal将此别名参数定义为“订阅提供者的PayPal帐户的安全商家帐户ID。 This value is in the My business info section of your PayPal account profile.” Replace the value SGGGX43FAKKXN with your own ID. 该值位于您的PayPal帐户资料的“我的业务信息”部分。”用您自己的ID替换值SGGGX43FAKKXN。

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

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