TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Paypal Silent Transaction in ASP.NET
Kumar Bhimsen
Jan 04
2016
Code
1.3
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
using
System;
using
System.Net;
using
System.Text;
using
System.IO;
public
partial
class
PayPal
{
public
void
DoDirect()
{
//API Credentials (3-token)
string
strUsername =
"Your userName"
;
string
strPassword =
"QFZCWN5HZM8VBG7Q"
;
string
strSignature =
"A21eW1ch..NEqJJ-glaLhqkBMlzeAsWqX0ycck-CTc0tKI4pa1u.rgNF"
;
string
strCredentials =
"USER="
+ strUsername +
"&PWD="
+ strPassword +
"&SIGNATURE="
+ strSignature;
string
strNVPSandboxServer =
"https://api-3t.sandbox.paypal.com/nvp"
;
string
strNVPLiveServer =
"https://api-3t.paypal.com/nvp"
;
string
strAPIVersion =
"2.3"
string
strNVP = strCredentials +
"&METHOD=DoDirectPayment&CREDITCARDTYPE=VISA&ACCT=XXXXXXXXXXXXXXXXX&EXPDATE=092007&CVV2=808&AMT=212.95&FIRSTNAME=Designer&LASTNAME=Fotos&IPADDRESS=255.55.167.002&STREET=1234+Easy+Street&CITY=San+Jose&STATE=CA&COUNTRY=United+States&ZIP=95110&COUNTRYCODE=US&PAYMENTACTION=Sale&VERSION="
+ strAPIVersion;
//Create web request and web response objects, make sure you using the correct server (sandbox/live)
HttpWebRequest wrWebRequest = (HttpWebRequest) WebRequest.Create(strNVPSandboxServer);
//Set WebRequest Properties
wrWebRequest.Method =
"POST"
;
// write the form values into the request message
StreamWriter requestWriter =
new
StreamWriter(wrWebRequest.GetRequestStream());
requestWriter.Write(strNVP);
requestWriter.Close();
// Get the response.
HttpWebResponse hwrWebResponse = (HttpWebResponse) wrWebRequest.GetResponse();
StreamReader responseReader =
new
StreamReader(wrWebRequest.GetResponse().GetResponseStream());
// and read the response
string
responseData = responseReader.ReadToEnd();
responseReader.Close();
string
result = Server.UrlDecode(responseData);
}
}
ASP.NET
C#
Paypal silent transaction