Telegram bot - add unique key to /start command - c#

I'm trying to identify each user by some unique key, which is added to /start command. For each user, I will generate some key, and show URL to the user. This is described step by step in the official documentation https://core.telegram.org/bots#deep-linking
Link for the users is in the format:
https://telegram.me/ExampleBot?start=uniqueKey
It works perfectly in the telegram app. The probem is, that when opened in the browser, only button "Start" is visible. When the user clicks, the uniqueKey is not send to the bot.
How to add a uniqueKey to /start command to make it work in telegram web app too? How should look like the generated URL? So user can just click, and does not need to write the code?

Make your uniqueKey as Base64 and test again...
Based on Telegram documents it is recommended to using base64url to encode parameters with binary and other types of content.

Related

Redirect from successful stripe checkout

I am using Stripes payment gateway with C# .Net. I started with creating a checkout which redirects the user to Stripe's payment gateway (I didnt want the hassle of maintaining the card numbers etc so this way it forwards to Stripe to ask for the card details, process the payment etc) https://stripe.com/docs/payments/checkout/one-time - this was done in code-behind.
I set my success URL as www.example.com/myHandler.ashx (Generic Handler)- this URL sets the order id as successful. My handler code is similar to https://stripe.com/docs/webhooks/build (since im using a Generic Handler i'm using forms and not MVC)
After a successful payment, the payment is recorded to my database.
Considering this is a webhook, how do i display/redirect to a thank you page?
You have more than one way to solve this.
Option 1:
Combine the success page with your webhook. This means it will display the page to the user and update the state of the transaction on the backend.
your url would look like this
SuccessUrl = "https://example.com/success?session_id={CHECKOUT_SESSION_ID}"
Then use the session ID to handle the state change like you would with your webhook but return the html page to the user (Technically this wouldn't be a webhook).
Based on your question it could be that the SuccessUrl gives a session object as body because otherwise your current code shouldn't be working but I'm not sure.
To get the session object based on the Id you can make another call to stripe see:
https://stripe.com/docs/api/checkout/sessions/retrieve#retrieve_checkout_session
Once payment is successful, the Checkout Session will contain a reference to the Customer, and either the successful PaymentIntent or an active Subscription.
Option 2:
Create a webhook separately from your thank you page. This means that the SuccessUrl would be your thank you page.
The webhook needs to be defined separately and globally with stripe. You can look here on how this is done: https://stripe.com/docs/webhooks/configure

How can I create a random unique token and use it to verify an email address for a user in ASP.NET Core?

I have all the logic written for my user registration except for email verification. Via my researched I learned that, simplifyingly, I need to create a random unique token and include that token in a link sent to the email address that is to be verified.
How can I create this random token and what how should I process the request from the activation link?
I don't know about Nuget but you can code yourself for sending an activation link and processing it.
The steps are:
1) Generate random unique token and save it in your database. For generating unique token you can use UUID in Java as
String uniqueID = UUID.randomUUID().toString();
2) Include that token, encrypt it (not necessary though) and send it to the email ID.
example: www.xyz.com/activation?action=a273jsjh2718sjhdj271jgsdjaj28jh
3) When ever the user clicks that link, invoke the method for further processing in your controller. Map the url to your method in your controller.
Here is the example done using Spring Framework. I hope it helps.
PS: I don't know whether it is good practice for production. I just tried to help you.

How to programmaticaly get nest auth PinCode?

Launching a browser session to https://home.nest.com/login/oauth2?client_id={your client id}&state=STATE, click on continue we can get the pin code. As the web page using some binding, it's hard to programmaticaly mini it. I tried post request, but couldn't go further. Does any one have a working (code) example of how to get the PinCode?
To programmatically use the pin code to receiving the nest access token you must use a redirect URI. you can set it up via AWS, an insert the link in the nest developers account under redirect URI in the product you created.
NExt, follow the instructions provided by NEst LAbs in their github account: https://github.com/nestlabs/android-sdk.
good luck.

Which is paypal cancel url response parameter

I am using paypal sandbox account for testing purposes. When any user clicks on cancel and returns to the site, then which parameter will be received in the response?
?
I am trying to change "You'll be able to see your order details before you pay" text to "You will be able to view your order details before you pay".
Can any one have idea, How to it possible?
For the cancel url, you don't get any parameters in the response. The cancel url is the url you set either in your account or in your button using "cancel_return" parameter (documentation)
You cannot change that text, is part of PayPal's site. However, you can contact PayPal and tell them a very good reason for them to change that text.

How to do Auto authentication for automatically login to website?

I need to get automatically login to website from my windows application. I am doing it with HttpWebRequest but what i want is to
Click on the button in my application.
Open the Index page (page after getting login)
Reason : I don't want to enter user name and pasword, i just want to click button and any browser(default browser) open with index page (page after login)
Normal Example :
I open a link " http://mail.yahoo.com " it shows me a page asking my email address and
password.
I enter the email id and password and press Login.
It redirects me to my Mail box page.
What to Do ?
click on the button
Automatically send my email id or user name and password to the website
Open my Mail box page.
Hint :
get cookie from HttpWebRequest.
set it to the browser.
Open browser and pass the credentials to login automatcially
can anyone help me?
I also need to solve the same issue, and the problem is hint point 2 in your list.
ie. how to set a cookie in a browser, without limiting yourself to using a specific broswer.
The conclusion I am coming to, is that I need to use a standard 'Single Sign-On' logic, where we update the web-server to use short term tokens such as mentioned here...
http://msdn.microsoft.com/en-us/library/ms972971.aspx
In this case the steps would be something like:
1. In app - Logon with HttpWebRequest.
2. Get short-term token (the link suggests validity lifetime of just 2 seconds)
3. Open browser with url
http://MyWebsite>/SignNn?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxx
4. Next I need to confirm if the SignOn process can return cookies correctly.
I dont think you can solve this in a generic way.
What usually happens in such scenarios is that the form within the web page is submited to web server, the web server reads the user name / password values from the form and authenticates the user against the underlying user managment repository.
You can write such a solution for specific sites, by analzying with a sniffer the posted form in the authentication pages, and then creating such an http message yourself and sending it to the relevant site.

Categories