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.
Explanation:
I have 1 user,3 users and 6 users plans.
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("¤cy_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:
<IMG BORDER="0"SRC="https://www.paypalobjects.com/en_US/i/btn/btn_unsubscribe_LG.gif">
It displays an "Unsubscribe" button image to the user that links to the subscription cancellation function on the PayPal website. the user must log into their PayPal account to continue. the email address or payer ID here:
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. Before we can use this, though, we need to make one change to the href attribute. At the end of the URL for the href, you’ll see alias=SGGGX43FAKKXN. This alias parameter is defined by PayPal as “the secure merchant account ID of the subscription provider’s PayPal account. This value is in the My business info section of your PayPal account profile.” Replace the value SGGGX43FAKKXN with your own ID.
Related
I want to build Up/down voting system for several articles retrieved from database, but i want to add cookie for each article to limit number of votes so cookie will expires in one day, but i don't know where to add the appropriate code.
more details:
<script>
function vote(id, value) { // function vote with 2 arguments: article ID and value (+1 or -1) depending if you clicked on the arrow up or down
var dataFields = { 'id': id, 'value': value }; // We pass the 2 arguments
$.ajax({ // Ajax
type: "POST",
dataType: "text",//This for indicate that you'r expecting a text response from server
url: "WebService.asmx/updateVotes",
data: dataFields,
timeout: 3000,
success: function (dataBack) {
if(
$('#number' + id).html(dataBack);// div "number" with the new number
$('#arrow_up' + id).html('<div class="arrow_up_voted"></div>'); // We replace the clickable "arrow up" by the not clickable one
$('#arrow_down' + id).html('<div class="arrow_down_voted"></div>'); // We replace the clickable "arrow down" by the not clickable one
$('#message' + id).html('<div id="alertFadeOut' + id + '" style="color: green">Thank you for voting</div>'); // Diplay message with a fadeout
$('#alertFadeOut' + id).fadeOut(1100, function () {
$('#alertFadeOut' + id).text('');
});
},
error: function () {
$('#number' + id).text('Problem!');
}
});
}
</script>
the above code is a script calling ajax method to increase number of votes per one every time user click on the up arrow and decrease conversely.
public string updateVotes(string id,int value)
{
System.Threading.Thread.Sleep(500); // delay for 2.5 seconds Network latency
post p = db.posts.Find(int.Parse(id));
// assign new values
p.totalVotes += value;
db.Entry(p).State = System.Data.EntityState.Modified;
db.SaveChanges();
string dataBack =p.totalVotes.ToString();
return dataBack;
}
This is the webmethod.
Now i tried to think loudly and i code the following function to ewxamine if the cookie is null or not.
public bool enableVoting()
{
HttpCookie cookie = Request.Cookies["enableVote"];
if (Request.Cookies["enableVote"] != null)
{
return true;
}
else
{
return false;
}
}
i know it's wrong but at least i tried.
also where to add a for each loop to add cookie whenever user vote for article.?
foreach(post p in db.posts){
HttpCookie cookie = new HttpCookie("enableVote"+p.ID);
cookie.Value = "article:"+p.ID;
cookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie);
}
A suggestion. Don't use cookies for this. They are easily manipulated. Clear browser history and you can vote again.. and again.. and again.
Instead, create a Vote table in your database and add a record with the ip of the voter and the id of the post they voted for along with a timestamp.
This way you can easily count the votes and when someone votes you do a quick check on how long ago that IP last voted for that article (or any article).
Also with a vote table in your database you can easily catch bots that are up or downvoting everything, and limit the number of votes a single ip can make on any article (no more than 1 or two votes every few minutes maybe).
If your worried about multiple people behind the same IP not being able to vote you can include the browser name and only count unique ip and browser version as a vote. This is fairly unique. It can also be manipulated but its a little bit harder for the normal user.
Update:
I use this code for the purpose of getting a somewhat unique key in one of my MVC projects. The user can switch browsers and vote again, but it takes a bit of effort and its more of a pain than just clearing browser history.
I combine the IP, browser, and Country into a string and use that as a vote key.
public class UserInfo
{
public String ip { get; private set; }
public String browser { get; private set; }
public String country { get; private set; }
public UserInfo(HttpRequestBase Request)
{
ip = Request.UserHostAddress;
browser = Request.Browser.Platform + " " + Request.Browser.Type + "/" + Request.Browser.Id + " " + Request.Browser.Version;
country = "";
if (Request.UserLanguages.Length > 0)
country += " - " + Request.UserLanguages.ElementAt(0);
}
}
I'm using this system here: http://filepublicator.com/ to check if the user has any previously uploaded files (try to upload something and close browser and go there again, it will be in the list).
I've been making a custom user handler for Jessecar's SteamBot, which is unrelated to the problem I'm having, but essentially what I've done, is I've made it so you can set the bot to play a specific game by App ID, and I've been using this to idle on games for Steam Trading Cards, the only issue is, the only way I can check if it's finished, is by checking its inventory and how many cards are supposed to drop, which isn't too much of a hassle, but the main reason I created this was for efficiency, and doing this every time kind of defeats the purpose of it.
Because of this, I tried getting data from the badge page for the bot on the game that it's playing, this is what I have so far...
else if (message.StartsWith(".updateidle"))
{
var webGet = new HtmlWeb();
var SteamID64 = Bot.SteamClient.SteamID.ConvertToUInt64();
string htmlget = "http://www.steamcommunity.com/profiles/" + SteamID64 + "/gamecards/" + newgame;
var doc = webGet.Load(htmlget);
HtmlNode hoursNode = doc.DocumentNode.SelectSingleNode("//div[#class=\"badge_title_stats_playtime\"]");
string hours = Regex.Match(hoursNode.InnerText, #"[0-9\.,]+").Value;
var cards = doc.DocumentNode.SelectSingleNode("div[#class='badge_title_stats_drops']/span").InnerText;
if (hours == string.Empty)
{
hours = "0.0";
}
Bot.SteamFriends.SendChatMessage(OtherSID, type, "I have been idling for " + hours + " hours on game " + newgame + " and have " + cards + " card drops remaining.");
}
Getting the hours works fine, if the bot has no time on that game, it doesn't appear, so I just check if it's empty then set it to 0.0, however, with the cards, it appears as either "No card drops remaining" or " card drops remaining" which it doesn't get either, I tried using the same method as the hours and only get it if it's a number, and it still returns with "0", same result goes for this...
I also tried again with doing a check if the string is empty, because that could mean there is no card drops remaining, as there would be no numbers, and I also had a look online for methods of getting span data inside a div, or span data general, and neither methods worked, they'd just return with "0". And if you can't already tell, I do have the HTML Agility Pack.
So building in my previous answer, that I have decided not to edit, since the followup here is gonna be large. I amusing both Selenium and Html Agility Pack for this. First I log in using Selenium(I am using Mono btw). After that I type in authorize my pc manually(if yours is already authorized then skip this step) and then go to the console and press any key to proceed with getting card info. I will gather the card info for all games in this case. I can't identify which game still has card drops as it has not been implemented yet.
class MainClass
{
public static void Main(string[] args)
{
string userName = "username";
string password ="password";
string steamProfile = "steamprofile";
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
using (var driver = new FirefoxDriver())
{
// Go to the home page
driver.Navigate().GoToUrl("https://store.steampowered.com//login/?redir=0");
// Get the page elements
var userNameField = driver.FindElementById("input_username");
var userPasswordField = driver.FindElementById("input_password");
//var loginButton = driver.FindElementById("login_btn_signin");
var loginButton = driver.FindElementByXPath("//button[#class='btnv6_blue_hoverfade btn_medium']");
// Type user name and password
userNameField.SendKeys(userName);
userPasswordField.SendKeys(password);
// and click the login button
loginButton.Click();
System.Threading.Thread.Sleep(5000);
//Type authorization code and enter manually.
System.Console.ReadKey();
driver.Navigate().GoToUrl("http://steamcommunity.com/profiles/"+steamProfile+"/badges");
driver.GetScreenshot().SaveAsFile(#"screen.png", ImageFormat.Png); //Debuggin purposes, as I was first using PhantomJS
htmlDoc.LoadHtml(driver.PageSource);
Console.Clear();
}
HtmlNodeCollection col = htmlDoc.DocumentNode.SelectNodes("//span[#class='progress_info_bold']");
foreach (HtmlNode n in col)
{
Console.WriteLine(n.InnerText);
}
}
}
}
The output in my case
5 of 29 tasks completed
No card drops remaining
No card drops remaining
No card drops remaining
4 card drops remaining
3 card drops remaining
This code also gives you the badge progress. You must figure out yourself how to filter your data in Html Agility Pack(read up on xpath). I also recommend that you use Selenium, since you can start a steamgame from your webpage using it.
remember that the xpath I gave you in my first answer and is also used in the code above finds ALL("//") the that has a class that equals "progress_info_bold".
You need to be more specific about what nodes to pick. I highly disencourage you from ever using regex to try and navigate the innertext or innerhtml of an htmldocument.
To find the HTmlNodes regarding if there is anymore cards to drop. try using this xpath:
"//span[#class='progress_info_bold']"
These nodes will either contain the text:
"No card drops remaining"
or
number+" card drops remaining"
I want to manage the booking policy of a room, maximum duration of a meeting for example. Do someone has idea how do you do that via Managed API?
The managed API cannot police max duration but what you need todo is validate the entry before you submit a reservation...
public override bool IsNoOverTimeLimit(Reservation reservation)
{
return reservation.End.Subtract(reservation.Start).TotalMinutes <= 120;
}
if(!IsNoOverTimeLimit)
{
var errorMsg = new Label();
var fontSize = FontUnit.Point(10);
errorMsg.Font.Size = fontSize;
errorMsg.Text = "Reservation time is limited to " + ((float)30 / 60).ToString(CultureInfo.InvariantCulture) + " hours at a time.<br /> ";
placeHolder.Controls.Add(errorMsg);
}
My version is way more complicated than this but you get the point. Just simply check the reservation before you submit and if over time limit, return to page with some pretty warning..
I have tried to find answers on following questions for at least one hour but with no success.
I have WPF project (C#) and I have webBrowser control to navigate to my Facebook page http://www.facebook.com/TennisHelper and I want to do next few things:
I want to avoid login by creating user settings in my application which will contain email and password, but I don't know how to do that with C# Facebook SDK,
I want to make able for my user to post textual posts on that page via textBox control,
I want to make able for my user to post photos from his computer directly to that page, but with not creating new albums. Just to post image on page wall.
I was searching Google for all those problems but with no success
Let me know actually what is your requirement.I think your first requirement is to add a facebook login(or register with facebook page) button in your Website login page.
step1:You need to register a new facebook application on facebook.
step 2:install facebook c# sdk .You can either download the zip file manually or install it using nuget.I recommend the second option.I am using c# sdk 5.4.1 What is nuget? How to install a package using nuget?
step 3:Now you can add name space facebook to the page
step 4:Insert a login button(simply a button with text login) in login page(say login.aspx).Let it be button1
step 5:On click button redire to another page (let login1.aspx)
here is a sample code for login 1
using Facebook;//
FacebookOAuthClient fb = new FacebookOAuthClient();
UriBuilder red = new UriBuilder("www.example.com/Login1.aspx");
protected void Page_Load(object sender, EventArgs e)
{
string appid = "{your app id}";
string appsecret = "{your app secret}";
string permissions = "publish_stream";
if(Request.QueryString["code"] == null)
{
try
{
Response.Redirect("https://www.facebook.com/dialog/oauth?client_id=" + appid + "&redirect_uri=" + red.Uri.ToString() + "&scope=" + permissions +"&state=djfjfdjj");
}
catch (Exception b)
{
Label1.Text = b.ToString();
}
}
else
{
try
{
FacebookOAuthClient cl = new FacebookOAuthClient();
cl.RedirectUri = red.Uri;
cl.AppId = appid;
cl.AppSecret = appsecret;
dynamic result = cl.ExchangeCodeForAccessToken(Request.QueryString["code"]);
Label1.Text = Convert.ToString(result);
if (result["access_token"] != null)
{
Session["access_token"] = result["access_token"].ToString();//Now you have access token
Response.Redirect("Welcome.aspx");//replace welcome.aspx
}
else
{
Label1.Text = "Unable to authenticate\n Please try again later";
}
}
catch(Exception b)
{
Label1.Text = b.ToString();
}
}
}
Now you have access token saved in session.
for getting basic information of the client
dynamic me=fb.Get("\me");
it in cludes first name, last name ,email address,location,image url etc. of the current user.Now you can use this e-mail or name to verify your user or register new user etc.(its up to you ).
posting on that page is possible but diffiult How can I use the Facebook C# SDK to post on Facebook Pages
You should register an application on Facebook in order to use Facebook log in.navigate to
http://developers.facebook.com
create an appllication.You will get an application id and application secret.Use it as appid,appsecret
We are working on implementing some custom code on a workflow in a Sitecore 6.2 site. Our workflow currently looks something like the following:
Our goal is simple: email the submitter whether their content revision was approved or rejected in the "Awaiting Approval" step along with the comments that the reviewer made. To accomplish this we are adding an action under the "Approve" and "Reject" steps like so:
We are having two big issues in trying to write this code
There doesn't seem to be any easy way to determine which Command was chosen (the workaround would be to pass an argument in the action step but I'd much rather detect which was chosen)
I can't seem to get the comments within this workflow state (I can get them is the next state though)
For further context, here is the code that I have so far:
var contentItem = args.DataItem;
var contentDatabase = contentItem.Database;
var contentWorkflow = contentDatabase.WorkflowProvider.GetWorkflow(contentItem);
var contentHistory = contentWorkflow.GetHistory(contentItem);
//Get the workflow history so that we can email the last person in that chain.
if (contentHistory.Length > 0)
{
//contentWorkflow.GetCommands
var status = contentWorkflow.GetState(contentHistory[contentHistory.Length - 1].NewState);
//submitting user (string)
string lastUser = contentHistory[contentHistory.Length - 1].User;
//approve/reject comments
var message = contentHistory[contentHistory.Length - 1].Text;
//sitecore user (so we can get email address)
var submittingUser = sc.Security.Accounts.User.FromName(lastUser, false);
}
I ended up with the following code. I still see no good way to differentiate between commands but have instead implemented two separate classes (one for approve, one for reject):
public void Process(WorkflowPipelineArgs args)
{
//all variables get initialized
string contentPath = args.DataItem.Paths.ContentPath;
var contentItem = args.DataItem;
var contentWorkflow = contentItem.Database.WorkflowProvider.GetWorkflow(contentItem);
var contentHistory = contentWorkflow.GetHistory(contentItem);
var status = "Approved";
var subject = "Item approved in workflow: ";
var message = "The above item was approved in workflow.";
var comments = args.Comments;
//Get the workflow history so that we can email the last person in that chain.
if (contentHistory.Length > 0)
{
//submitting user (string)
string lastUser = contentHistory[contentHistory.Length - 1].User;
var submittingUser = Sitecore.Security.Accounts.User.FromName(lastUser, false);
//send email however you like (we use postmark, for example)
//submittingUser.Profile.Email
}
}
I have answered a very similar question.
Basically you need to get the Mail Workflow Action and then you need to further extend it to use the original's submitter's email.
Easiest way to get the command item itself is ProcessorItem.InnerItem.Parent
This will give you the GUID for commands like submit, reject etc.
args.CommandItem.ID
This will give you the GUID for states like Draft, approved etc.
args.CommandItem.ParentID