Paypal Website Payments Pro Integration Using C#?
Nov 27, 2010I need to implement checkout process using paypal website payments pro. I need solution/sample code for website payment pro with ASP.net/C#.
View 2 RepliesI need to implement checkout process using paypal website payments pro. I need solution/sample code for website payment pro with ASP.net/C#.
View 2 RepliesI am completing a website on which a single object is sold. I want to put the simplest PayPal button. I created the code of the button using the instructions on pp19 to 21 of "Website Payments Standard Integration Guide".
The code that was created was :
<code>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="123456789">
<input type="image" src="https://www.paypal.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
</code>
(I have altered the value value just for this post)
The HTML of the payment page is :
<code>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Page05.aspx.vb" Inherits="Page05" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Page05</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /><link href="Eng05.css" type="text/css" rel="Stylesheet" />
</head>
<body>
<form id="Form5" method="post" runat="server">
<a id="ankera-p5"></a>
<div id="container">
<div id="inner_container">
<p>THE "ANY SMALL AD" WEB SITE</p>
<p>How to pay</p>
xxxxxxxx
<p><a href="Page11.aspx#ankera-p11" >Back to Services page</a></p>
<p><a href="Default.aspx#ankera-p1" >Back to home page</a></p>
<p></p>
</div> <!-- End of inner container -->
</div> <!-- End of container -->
</form>
</body>
</html>
</code>
I pasted in the button code where I have put "xxxxx", but it's all a mess and I can't seem to get the button to appear.
We are working on a system with a paypal integrated system. but i'm having doubts, should we Host our site first? or can we do our paypal integration even though it is on a trial mode. or just using the local server.
View 2 RepliesAre there already created code in C # (which is fully operational) to be included on my site? I would only change this information, and should normally work?
View 1 RepliesI am developing a website with online payment. Payment is done using Paypal NVP Api. There is need of a facility to store customers credit card details(not in database) once they register to Website.There onwards whenever they order these details will be fetched, Customer need not enter their card details for every order. So is there any facility to create a profile n store credit card details of customer, as it is there for recurring payments?
View 1 RepliesI'm trying to get PayPal's ExpressCheckout working with Recurring Payments. I've got the first two stages (the calls to SetExpressCheckout and GetExpressCheckoutDetails) but CreateRecurringPaymentsProfile fails with the error below. I'm using a modified version of Paypal's sample code, but I suspect I'm (not) setting an encoder value. Anyone used this before? The error:
// TIMESTAMP: 2010-10-27T09:57:47Z
// CORRELATIONID: ad2b2da33c672
// ACK: Failure
// VERSION: 51.0
// BUILD: 1553277
// L_ERRORCODE0: 11502
// L_SHORTMESSAGE0: Invalid Token
// L_LONGMESSAGE0: The token is invalid
// L_SEVERITYCODE0: Error
The code I'm using is:
/// This returns true
public bool SetExpressCheckout(string amt, ref string token, ref string retMsg)
{
string host = "www.paypal.com";
if (bSandbox) {
pendpointurl = "https://api-3t.sandbox.paypal.com/nvp";
host = "www.sandbox.paypal.com";
}
string baseUrl = "http://" + HttpContext.Current.Request.Url.Authority;
string[] returnUrlParts = WebConfigurationManager.AppSettings["PaypalReturnUrl"].Split('?'),
cancelUrlParts = WebConfigurationManager.AppSettings["PaypalCancelUrl"].Split('?');
string returnURL = baseUrl + VirtualPathUtility.ToAbsolute(returnUrlParts[0]) + (returnUrlParts.Length > 1 ? '?' + returnUrlParts.Skip(1).Aggregate((itms, itm) => itms + itm) : string.Empty),
cancelURL = baseUrl + VirtualPathUtility.ToAbsolute(cancelUrlParts[0]) + (cancelUrlParts.Length > 1 ? '?' + cancelUrlParts.Skip(1).Aggregate((itms, itm) => itms + itm) : string.Empty);
NVPCodec encoder = new NVPCodec();
encoder["METHOD"] = "SetExpressCheckout";
encoder["RETURNURL"] = returnURL;
encoder["CANCELURL"] = cancelURL;
encoder["AMT"] = amt;
//encoder["PAYMENTACTION"] = "SALE";
encoder["CURRENCYCODE"] = "GBP";
encoder["NOSHIPPING"] = "1";
encoder["L_BILLINGTYPE0"] = "RecurringPayments";
encoder["L_BILLINGAGREEMENTDESCRIPTION0"] = "Subscription for MySite";
string pStrrequestforNvp = encoder.Encode();
string pStresponsenvp = HttpCall(pStrrequestforNvp);
NVPCodec decoder = new NVPCodec();
decoder.Decode(pStresponsenvp);
string strAck = decoder["ACK"].ToLower();
if (strAck != null && (strAck == "success" || strAck == "successwithwarning")) {
token = decoder["TOKEN"];
string ECURL = "https://" + host + "/cgi-bin/webscr?cmd=_express-checkout" + "&token=" + token;
retMsg = ECURL;
return true;
} else {
retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" +
"Desc=" + decoder["L_SHORTMESSAGE0"] + "&" +
"Desc2=" + decoder["L_LONGMESSAGE0"];
return false;
}
}
/// This returns true
public bool GetExpressCheckoutDetails(string token, ref string PayerId, ref string retMsg)
{
if (bSandbox) {
pendpointurl = "https://api-3t.sandbox.paypal.com/nvp";
}
NVPCodec encoder = new NVPCodec();
encoder["METHOD"] = "GetExpressCheckoutDetails";
encoder["TOKEN"] = token;
string pStrrequestforNvp = encoder.Encode();
string pStresponsenvp = HttpCall(pStrrequestforNvp);
NVPCodec decoder = new NVPCodec();
decoder.Decode(pStresponsenvp);
string strAck = decoder["ACK"].ToLower();
if (strAck != null && (strAck == "success" || strAck == "successwithwarning")) {
return true;
} else {
retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" +
"Desc=" + decoder["L_SHORTMESSAGE0"] + "&" +
"Desc2=" + decoder["L_LONGMESSAGE0"];
return false;
}
}
// This fails and returns false with the following in the decoder result
// TIMESTAMP: 2010-10-27T09:57:47Z
// CORRELATIONID: ad2b2da33c672
// ACK: Failure
// VERSION: 51.0
// BUILD: 1553277
// L_ERRORCODE0: 11502
// L_SHORTMESSAGE0: Invalid Token
// L_LONGMESSAGE0: The token is invalid
// L_SEVERITYCODE0: Error
public bool CreateRecurringPaymentsProfileCode(string token, string amount, string profileDate, string billingPeriod, string billingFrequency, ref string retMsg)
{
NVPCallerServices caller = new NVPCallerServices();
IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
profile.APIUsername = this.APIUsername;
profile.APIPassword = this.APIPassword;
profile.APISignature = this.APISignature;
profile.Environment = "sandbox";
caller.APIProfile = profile;
string host = "www.paypal.com";
if (bSandbox) {
pendpointurl = "https://api-3t.sandbox.paypal.com/nvp";
host = "www.sandbox.paypal.com";
}
NVPCodec encoder = new NVPCodec();
encoder["VERSION"] = "51.0";
// Add request-specific fields to the request.
encoder["METHOD"] = "CreateRecurringPaymentsProfile";
encoder["TOKEN"] = token;
encoder["AMT"] = amount;
encoder["PROFILESTARTDATE"] = profileDate; //Date format from server expects Ex: 2006-9-6T0:0:0
encoder["BILLINGPERIOD"] = billingPeriod;
encoder["BILLINGFREQUENCY"] = billingFrequency;
encoder["L_BILLINGTYPE0"] = "RecurringPayments";
encoder["DESC"] = "Subscription for MySite";
// Execute the API operation and obtain the response.
string pStrrequestforNvp = encoder.Encode();
string pStresponsenvp = caller.Call(pStrrequestforNvp);
NVPCodec decoder = new NVPCodec();
decoder.Decode(pStresponsenvp);
//return decoder["ACK"];
string strAck = decoder["ACK"];
bool success = false;
if (strAck != null && (strAck == "Success" || strAck == "SuccessWithWarning")) {
success = true; // check decoder["result"]
} else {
success = false;
}
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < decoder.Keys.Count; i++) {
buffer.AppendFormat("{0}: {1}", decoder.Keys[i], decoder.GetValues(i).Aggregate((vals, val) => vals + "----" + val));
}
retMsg = buffer.ToString();
return success;// returns false
}
If it helps, the code which is calling it is :
NVPAPICaller ppapi = new NVPAPICaller();
NVPCodec decoder = new NVPCodec();
string retMsg = string.Empty,
token = Convert.ToString(Session["token"]),
finalPaymentAmount = "15",
payerId = Convert.ToString(Session["payerId"] ?? string.Empty); // set from SetExpressCheckout
bool shippingSuccess = ppapi.GetExpressCheckoutDetails(token, ref payerId, ref retMsg);
if (shippingSuccess) {
payerId = Session["payerId"].ToString();
btnConfirm.Enabled = false;
bool paymentSuccess = ppapi.CreateRecurringPaymentsProfileCode(token, finalPaymentAmount, DateTime.Now.ToString("yyyy-M-DTH:m:s"), "Year", "1", ref retMsg);
// but paymentSuccess is false
I have PayPal Web Payment standard successfully integrated in an ecomerce solution I'm developing. My problem is this, I want to store details of the order being placed before it is sent to PayPal but only if it is sent and not if the just fill in everything in the shopping cart and then leave the page. There are 3 ways I can think of how this might be acheived but I'm not sure how to implement them.
1. Put some code in the page_unload that stores the data fi the page the browser is being transferred to is the paypal site. However I don't a way to determine what the next page is going to be.
2. Submit the the information to PayPal from the code behind. I'm sure this should be possible but I don't know how to do it and haven't managed to find a good articles on it.
3. Assign a javascript function to the onclick on PayPal submit button that calls a servside function using PageMethods. However this just seems like a bit a bodge introduces a whole array of other problems.
I am creating my first e-commerce site.I have a nonprogramming ?; Does Paypal accept credit card payments or should i use a third party gateway to accept credit card payments?
View 2 RepliesWe set up a paypal gateway on our site using paypal NVP API: Our IIS web server is set up for SSL, though I just created a cert on the locally machine. When we load HTTPS the browser gives a warning about security before the page will load. I know a local cert won't cut it for SSL, so I think we need a verisign cert? [URL] Is this correct? How can I know that the cert I am getting will get along with paypal and elimante any security warnings for the user.
View 1 RepliesI am looking for some aticle which explains the integration of PayPal PDT feature with ASP.NET MVC model.So Far I am able to direct the user to pay pal with the payment information but I am need help with processing the returned url from paypal and sending the information back to paypal for verification.
View 3 RepliesI'm currently trying my luck to integrate PayPal in ASP.NET (I'm just starting to know more about PayPal, okay?)
PayPal Integration Wizard. Hmmm. Does this even work?
In my shopping website..... I had integrated Paypal. Using the Developer / SandBox Version I had already tested the site from my local machine. It is working fine.
But after uploading the files in shared web-Server, whenever I am trying to call the Paypal, then always it is showing me the following error. The operation has timed out Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The operation has timed out
Source Error:
[Code]....
Line 32: End If
Line 33: Catch ex As Exception
Line 34: Throw ex
Line 35:
Line 36: Finally
Source
File: D:whbSites29519Webexpresscheckout.aspx.vb Line: 34
Stack Trace:
[Code]....
[WebException: The operation has timed out]
expresscheckout.expresscheckout_Load(Object sender, EventArgs e) in D:whbSites29519Webexpresscheckout.aspx.vb:34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
I have an Add to Cart button on a Content Page. It works perfectly well.
I HAD a View Cart button on the Content Page, also. It worked perfectly well.
Problem...
As the View Cart button isn't linked to any specific page/product, I moved it to my Master page and the code behind to my MasterPage.aspx.vb file. Upin doing that, Visual Studio complained: "Name 'ClientScript' is not declared".
I know noting about JavaScript and have been working with code copied and pasted from these forums for months but now in adjusting my code so it works from the Master Page.
Here is code: first for the Add to Cart button in the Content Page, then for the View Cart button in the Mater Page (just the code behind)...
[Code]....
I've got the forum setup on my ASP.net website fine, works great!I want to use their membership system as my central user system on my site though.I basically want to be able to tell if a user is logged in or not. IE, best case scenario, on my custom Master page I just have a:
if(UserIsLoggedIn){
Response.Write(LoggedInUserName);
}
I have an exiting ASP.NET website that already has user accounts in it. I would now like to simplify logon and considering the use of Janrain. Is this a recommended product? Any alternatives you have used? What do I do with my existing users (I assume I need to extend my membership db to select between them and Janrain tokens)?
View 3 RepliesI have seen you Facebook Integration Code, Importing Facebook profile, Login Via Facebook.
I want the same thing for LinkedIn.
i need to integrate paypal with my asp.net ecommerce site but i need to upload details of multiple products to paypal and also the customer and shipping info.
View 3 RepliesI am developing a web-site where user can purchase items and pay through PAYPAL.
Its working fine on test and all the payment processing is working well. But aI want to update my database after succesful payment and for that I have created one THANKS.ASPX page where I fetch the response and if it is verified that update the database and also it working fine.
After redirect to paypal and successful patment I received page from Paypal site for successful payment where transaction ID and other information are displayed.
There is a link in paypal page called "Return to Merchant Test Score" and when user click on the link it redirects to my Thanks.aspx where I fetch the response and if verified the update the database.
But my problem is that If after successful paymet user not click the "Return to Merchat Test Score" and directly close the browser then it not update my database.
How can we integtate twitter(contact,id,twitt) in our own website.......
View 1 RepliesDoes anyone know of a good tutorial regarding integrating paypal subscriptions with a .NET website. I have searched online and most of the articles I've found are 2+ years old, so I'm unsure how accurate these would still be.
View 1 RepliesAsp.net How can i get the transaction history of paypal account on my website using paypal email id and password.As I want to Import the Paypal transaction logs in my website for financial management on my site...
View 1 Replies I was having trouble getting my shopping cart to connect to paypal. So I wrote a simple webform that has one button and one label. If I comment out the response.redirect(url) and look at the content that get written to Lable1.Text it looks find. Also, if I copy the content of the label and paste it into my web browser it goes to Paypal and displays correctly.
However, if I uncomment the response.redirect(url) I get the following error: ERROR: Unable to Send to PayPal - Thread was being aborted.
I am testing from localhost??? Should I be able to test this from localhost?
I have put ??? where my Sandbox email address is.....I don't know if letting other see that or not is an issue....otherwise I would have left it in for someone to try this code.
[Code]....
This is what displays in the lable1.text when response.redirect is commented out
[URL]
I create paypal payment Getway when on local machine i check transaction using paypal sandbox In this way I get all data from paypal site when Return url send me back to my site at Paysuccess page after tansaction over
But when I try same page Online It working well, but Data not save in my database.
is it possible to modify paypal sandbox test store name and image logo when customer is redirected to the paypal site. I am using express checkout workflow.
View 1 Replieshttps://www.x.com/community/ppx/code_samples
The sample code returns ACK, but where is the proper response?
For example
Getbalance, sample code returns ACK
https://cms.paypal.com/cms_content/US/en_US/files/developer/nvp_GetBalance_cs.txt
but the document shows it returns other values?
https://www.x.com/docs/DOC-1186