Create a Link to a Paypal setting the email address static - c#

I have been researching up creating my own link to PayPal, that when a person is logged in, it will generate a "specified email" in the "To:" text box on the form.
However, I am planning something a tad more ambitious; I'd like to know it is possible to build this link in my code to where the specified email "cannot be edited or changed?" Again, this would coming from my custom-made link:
https://www.paypal.com/us/cgi-bin/webscr?cmd=_send-money&nav=1&email=SomePresetEmail#mail.com
How can I code this to set "SomePresetEmail#mail.com" to be static? Or is that even possible for me to do that, being I am not editing the code on Paypal's server side? My site is currently built using Asp.Net WebForms.

DesignerMind,
I am not sure if I am following you correctly. But this link is displayed on the page to user and you want them to not be able to change the email?
Is it possible to have your link point to an address inside your application that gets redirected to Paypal? When paypal recieves the request, they execute an internal mechanism to hash the request into a secured request variable. This means that when you navigate to the link the user is not seeing the actual link but a hashed version. A sample of the paypal hashed version is.
https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=Itqgb8iQ3mW92FT9ldzgcFmJyRVQLUpE2u9UMqeKbGmvwdMTY80oBEmo0SS&dispatch=5885d80a13c0db1f8e263663d3faee8def8934b92a630e40b7fef61ab7e9fe63
Now you could try to do this such as.
On your aspx.net page.
<asp:HyperLink runat="server" ID="paypalLink" NavigateUrl="~/Paypal.aspx" />
or simply
Paypal
And in the Paypal.Aspx code
static string SecretEmail = "someone#somewhere.com",
PaypalRedirectFormat = "https://www.paypal.com/us/cgi-bin/webscr?cmd=_send-money&nav=1&email={0}";
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect(string.Format(PaypalRedirectFormat, SecretEmail));
}
This is just an idea and actually if this is what you wanted a GenericHandler would do the job quite nicely.
Let me know if this is not what you are looking for.

Related

Blazor page's URL is interfering with component's call to API -- 400-Bad Request

My web-app is .Net 6, VS-2022 Blazor WASM-hosted.
I am having a problem with the URL for the API when being called from a component.
I have three files: page: VehicleList.razor, page: VehicleEdit.Razor and component: CRUD_Vehicle.razor.
The page flow is the user navigates to 'VehicleList' and has the ability to select a vehicle to EDIT via callback function. Once selected, the flow navigates to 'VehicleEdit' where some data needs to be passed to support the embedded sub-component 'CRUD_Vehicle'.
The problem is that URL to the 'VehicleEdit' looks like this with query-string data in a comma-delimited string AND it remains there when the CRUD-component is showing.
https://localhost:7777/vehicleedit/667?par=17,Bigelow,Active
When the user makes editing changes and SUBMITs the component, the HttpClient service gets called and fails with a 400-Bad Request. I am under the impression that the query-string interfers with the api URL. Please see below. Is there a way I could set the URL to not show the query-string and only have the base-address and the UID_VEHICLE like this?
https://localhost:7777/vehicleedit/667
public async Task<Vehicle> UpdateVehicle(Vehicle pVehicle) {
// Save the edited record.
HttpResponseMessage response = await httpClient.PutAsJsonAsync<Vehicle>($"/api/vehicle/{pVehicle.UID_VEHICLE}", pVehicle);
if (!response.IsSuccessStatusCode) {
// problems handling here.
Console.WriteLine($"UpdateVehicle() Error occurred, the status code is: {(int)response.StatusCode}: {response.StatusCode}" );
}
return await response.Content.ReadFromJsonAsync<Vehicle>();
}
I have a similar construction for the editing of the Customer object, but the page that shows the CRUD_Customer component has a simple URL and works perfectly to save data to the DB. The main difference is the URL for the VehicleEdit.razor. Your comments are welcome.
Thanks.
https://localhost:7777/customeredit/17
I downloaded Postman and entered the PUT transaction and the PUT RESULT showed there was an ERROR (based on DataAnnotation for the 'StartDate'-field) that was NOT caught at the client validation code. It turns out that the TITLE text was based on what the possible cause might be. But Postman showed me the exact reason why the PUT call failed.
So, my 'answer' is: Use Postman to simulate the 'httpClient.PutAsJsonAsync'-call to observe the result-details to pinpoint the reason for the '400-Bad Request' return from the service.

.NET Identity Email Confirmed Bool

I want to simply get in my code if the user has his email confirmed or not. Without an async method. Can someone help me please?
Couple of options, if i understood your question correctly:
In your database add another 2 columns "EmailConfirmationID" perhaps of type GUID (UniqueIdentifier) and Verified (bit). When the user registers you can insert a new value into EmailConfirmationID send this link to the user (creating a URL) via email. When they click this link within the email you would have the page handle their request and set Verified to true.
Have a look at this link http://www.asp.net/identity/overview/features-api/account-confirmation-and-password-recovery-with-aspnet-identity

(OAuthException) (#200) User must have accepted TOS on C# - Facebook

Well, I am trying make a app to write comments to facebook in C#.
Searching in google I know that I need an Application (I did it) and I need select the permissions. I did it..
Now I wrote my code in C#:
private string MyAppId = "XXX";
private string MyAppSecret = "XXX";
private void button1_Click(object sender, EventArgs e)
{
FacebookClient FB = new FacebookClient(MyAppId, MyAppSecret);
Dictionary<string,string> data = new Dictionary<string,string>();
data.Add("message","test");
FB.Post("OBJECT_ID/comments", data);
}
But when I click the button I get this error:
(OAuthException) (#200) User must have accepted TOS
I am getting crazy! Please help me =(
It doesn't look like you're actually using the users access token.
You need to go through the OAuth workflow, where the user is redirected to facebook.com and grants your application permission. Once that happens, you'll get an Access Token that you use to make requests on behalf of the user.
There's an overload for the FacebookClient class that will take an access token.
Since you didn't really expand on the type of app you're writing, the Facebook C# Github page has a collection of samples, for WinForms, ASP.NET, and Windows 8 Metro. This example should show you how to do client-side authentication.
You're also trying to post to OBJECT_ID, which isn't a valid user/post/page.

How does one login with a url command(Test Handle), rather than entering in each step?

So, the scenario is to login to said website using a formatted url, rather than doing something like what is below. Upon reading documentation regarding Selenium etc i read that this is bad practice (Excluding a login test case). I understand that the method i am inquiring about is not to be used on production level.
Does the url method pull the login information from a database?
//ENTER AGENT LOGIN ID
IWebElement LoadAgentLoginID2 = selenium.FindElement(By.Id("MainContent_txtAgentID"));
LoadAgentLoginID2.Click();
LoadAgentLoginID2.SendKeys(AgentLoginIDs[0]);
//ENTER ARC NUMBER
IWebElement LoadARCnumber2 = selenium.FindElement(By.Id("MainContent_txtArcNbr"));
LoadARCnumber2.Click();
LoadARCnumber2.SendKeys(System.String.Format("{0}", ARCnumbers[1]));
//ENTER PASSWORD
IWebElement LoadPassword2 = selenium.FindElement(By.Id("MainContent_txtPassword"));
LoadPassword2.Click();
LoadPassword2.SendKeys(AgentPasswords[0]);
Any help is greatly appreciated. Cheers!
The url method needs to be supported by the web application. If this is supported, then it would simply be something like this:
driver.get("http://www.mywebapp.com?username=JohnP&password=ABCD");
If the web app does not support this, then you should just try to encapsulate your login logic above into a separate and reusable method.

Facebook "fan gate" with C#/asp.net

The problem is that 1) Facebook seems so fluid with how it allows developers to interact with it (FBML, iFrame, different versions of SDKs) and 2) Everything I find is either PHP or Javascript and I have NO experience with those. What I am trying to do seems sooo simple, and I can't believe there isn't an easy way to do this.
What I have:
I used Visual Studio 2010 to create a simple web application (asp.net/C#) that asks the user for some info (first name, last name, email, etc.). I have a button on there called "Submit" that, when clicked, saves the entered data into a database. I have this hosted on GoDaddy (I know, I know...heh) and it works just fine. No problem here.
I created a "Facebook App" that uses the iFrame thingy so that basically I have a new tab on Facebook that displays my web app mentioned above. This works fine too. The tab is there, the web app is there, and users can enter the data and it is saved to the database. No problem here.
What I WANT:
I want the web app (the thing displayed by the facebook app) to only show the data entry part if the user currently "likes" the facebook entity. I DO NOT want to have to ask permission. I just want to know if they are a fan of the company's facebook "page" that has this app. So I need two things here, shown in my pseudo code below:
Part 1 (check if user is already a fan):
If (user is fan)
{
Show data entry area (unhide it)
}
else
{
Show "Click the like button to see more options"
}
Part 2 (listen for "like" event)
WhenLikeButtonPressed()
{
Show data entry area (unhide it)
}
I've seen stuff about "visible to connection", C# sdk, edge.create, etc. but I just can't make heads or tails of it. I don't mind putting in Javascript or PHP if someone could please give me exact, "Fan Gate for Dummies" steps. Please, I'm going crazy over here :-(
The key is is the signed_request that Facebook posts to your app when the user accesses the page. It contains the data on whether or not the user likes the page. You shouldn't need to worry about catching edge events on an actual tab FB page as it get's reloaded when the user likes/unlikes the page.
You'll need to decode the signed request with your app secret to get the like info. There are examples provided for PHP but I'm sure with a little google help you can find decode info for the signed_request for asp.net/c#.
Here's the php decode for reference:
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
// decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}
// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
and the link https://developers.facebook.com/docs/authentication/signed_request/ the like info will be contained in the page variable

Categories

Resources