Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
How to integrate paypal credit card in asp.net
Posted 29-Nov-12 23:38pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

 
 
<%-- --%>
 
 


<asp:linkbutton id="lnkFillInfo" runat="server" text="Fill Information" onclick="lnkFillInfo_Click" xmlns:asp="#unknown"> <asp:linkbutton id="lnkClearInfo" runat="server" text="Clear Info" onclick="lnkClearInfo_Click" xmlns:asp="#unknown">
First Name* : <asp:textbox id="txtFirstName" runat="server" xmlns:asp="#unknown">
<asp:requiredfieldvalidator id="RequiredFieldValidator4" runat="server" errormessage="Required !" validationgroup="reqpay" controltovalidate="txtFirstName" cssclass="ErrorMes" xmlns:asp="#unknown">
Last Name* : <asp:textbox id="txtLastName" runat="server" xmlns:asp="#unknown">
<asp:requiredfieldvalidator id="RequiredFieldValidator5" runat="server" errormessage="Required !" validationgroup="reqpay" controltovalidate="txtLastName" cssclass="ErrorMes" xmlns:asp="#unknown">
Card Type* : <asp:dropdownlist id="ddlCardType" runat="server" xmlns:asp="#unknown">
<asp:listitem value="Visa" text="Visa" selected="True">
<asp:listitem value="MASTERCARD" text="MASTERCARD">
<asp:listitem value="AMERICAN EXPRESS" text="AMERICAN EXPRESS">

Card Number* : <asp:textbox id="txtCardNumber" runat="server" xmlns:asp="#unknown">
<asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" errormessage="Required !" validationgroup="reqpay" controltovalidate="txtCardNumber" cssclass="ErrorMes" xmlns:asp="#unknown">
Name on Card* : <asp:textbox id="txtCardOnName" runat="server" xmlns:asp="#unknown">
<asp:requiredfieldvalidator id="RF1" runat="server" errormessage="Required !" validationgroup="reqpay" controltovalidate="txtCardOnName" cssclass="ErrorMes" xmlns:asp="#unknown">
Expiration* : <asp:dropdownlist id="ddlMonth" runat="server" xmlns:asp="#unknown">
 <asp:dropdownlist id="ddlYear" runat="server" xmlns:asp="#unknown"> (MM/YYYY)
CCV Code* : <asp:textbox id="txtCCVCode" runat="server" xmlns:asp="#unknown">
<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" errormessage="Required !" validationgroup="reqpay" controltovalidate="txtCCVCode" cssclass="ErrorMes" xmlns:asp="#unknown">
Amount* : <asp:textbox id="txtAmount" runat="server" xmlns:asp="#unknown">
<asp:requiredfieldvalidator id="RequiredFieldValidator3" runat="server" errormessage="Required !" validationgroup="reqpay" controltovalidate="txtAmount" cssclass="ErrorMes" xmlns:asp="#unknown">
<asp:button id="btnSubmit" runat="server" validationgroup="reqpay" onclick="btnSubmit_Click" text="Pay" xmlns:asp="#unknown" />
<asp:label id="lblMessage" runat="server" cssclass="ErrorMes" xmlns:asp="#unknown">
 

ASPX.CS PAGE
-------------
 
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillMonth();
FillYear();
}

}
protected void btnSubmit_Click(object sender, EventArgs e)
{
CRCardPaymentProcess();
}
 
public void FillMonth()
{
for (int index = 01; index <= 12; index++)
{
ddlMonth.Items.Add(new ListItem(Convert.ToString(index).PadLeft(2, '0'), Convert.ToString(index).PadLeft(2, '0')));
}
}
public void FillYear()
{
int startyear = System.DateTime.Now.AddYears(-15).Year;
int endyear = System.DateTime.Now.AddYears(10).Year;
for (; startyear <= endyear;)
{
ddlYear.Items.Add(new ListItem(Convert.ToString(startyear), Convert.ToString(startyear)));
startyear++;
}
}
 
public void FillInfo()
{
txtFirstName.Text = "James";
txtLastName.Text = "Smith";
txtCardNumber.Text = "4641631486853053";
ddlMonth.SelectedValue = "04";
ddlYear.SelectedValue = "2017";
txtCCVCode.Text = "123";
txtAmount.Text = "120";
}
public void ClearInfo()
{
txtFirstName.Text = string.Empty;
txtLastName.Text = string.Empty;
txtCardNumber.Text = string.Empty;
ddlMonth.SelectedIndex = 0;
ddlYear.SelectedIndex = 0;
txtCCVCode.Text = string.Empty;
txtAmount.Text = string.Empty;
}
 
public void CRCardPaymentProcess()
{
string strNVPSandboxServer = "https://api-3t.sandbox.paypal.com/nvp";
string strAPIVersion = "2.3";
 
string strUsername = "merchant id";
string strPassword = "merchant password";
string strSignature = "merchant signature";
string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword + "&SIGNATURE=" + strSignature;
 

string strNVP = strCredentials + "&METHOD=DoDirectPayment" +
"&CREDITCARDTYPE=" + ddlCardType.SelectedValue +
"&ACCT=" + txtCardNumber.Text +
"&EXPDATE=" + ddlMonth.SelectedValue + ddlYear.SelectedValue +
"&CVV2=" + txtCCVCode.Text +
"&AMT=" + txtAmount.Text +
"&FIRSTNAME=" + txtFirstName.Text +
"&LASTNAME=" + txtLastName.Text +
"&IPADDRESS=" + Request.UserHostAddress.ToString() +
//"&IPADDRESS=" + "127.0.0.1" +
//"&STREET=" + "1 Main St" +
//"&CITY=" + "San Jose" +
//"&STATE=" + "CA" +
//"&COUNTRY=" + "United States" +
//"&ZIP=95110" + "95131" +
//"&COUNTRYCODE=US" +
"&PAYMENTACTION=Authorization" +
"&VERSION=" + strAPIVersion;
 
try
{
//Create web request and web response objects, make sure you using the correct server (sandbox/live)
HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer);
wrWebRequest.Method = "POST";
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);
 
string[] arrResult = result.Split('&');
Hashtable htResponse = new Hashtable();
string[] responseItemArray;
foreach (string responseItem in arrResult)
{
responseItemArray = responseItem.Split('=');
htResponse.Add(responseItemArray[0], responseItemArray[1]);
}

string strAck = htResponse["ACK"].ToString();
if (strAck == "Success" || strAck == "SuccessWithWarning")
{
string strAmt = htResponse["AMT"].ToString();
string strCcy = htResponse["CURRENCYCODE"].ToString();
string strTransactionID = htResponse["TRANSACTIONID"].ToString();
string strSuccess = string.Format("Thank you,
Your order for: $ {0} has been processed.
Your transaction code is : {1}", strAmt, strTransactionID);// "Thank you,
Your order for: $" + strAmt + " " + strCcy + " has been processed.";
lblMessage.Text = strSuccess;
}
else
{
string strErr = "Error: " + htResponse["L_LONGMESSAGE0"].ToString();
string strErrcode = "Error code: " + htResponse["L_ERRORCODE0"].ToString();
lblMessage.Text = string.Format("{0}
{1}", strErr, strErrcode);
return;
}
}
catch (Exception ex)
{
// do something to catch the error, like write to a log file.
Response.Write("error processing");
}
 
}
protected void lnkFillInfo_Click(object sender, EventArgs e)
{
FillInfo();
}
protected void lnkClearInfo_Click(object sender, EventArgs e)
{
ClearInfo();
}
  Permalink  
Comments
viral1986 at 2-Apr-13 8:11am
   
Can any one give me some information or sample code about chained payment in Paypal with multiple Recievers... thanks in Advance
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hello,
Use the following link I think this is useful to you.
http://www.dotnetspider.com/resources/43962-How-integrate-PayPal-ASP.NET.aspx[^]
 
Thanks
Abhimanyu Rawat
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 530
1 Sergey Alexandrovich Kryukov 340
2 BillWoodruff 259
3 PIEBALDconsult 230
4 CPallini 220
0 Sergey Alexandrovich Kryukov 10,615
1 Maciej Los 5,354
2 OriginalGriff 5,254
3 CPallini 3,719
4 BillWoodruff 3,476


Advertise | Privacy | Mobile
Web04 | 2.8.141029.1 | Last Updated 30 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100