C# - PayPal - ExpressCheckout And Recurring Payments

Oct 27, 2010

I'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

View 1 Replies


Similar Messages:

Web Forms :: Add Paypal Recurring In Web Side

Aug 14, 2010

i want to add paypal recurrring in my webside. how it is possible

View 3 Replies

Online Payments Using Paypal NVP Api

Jan 17, 2011

I 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 Replies

Paypal Website Payments Pro Integration Using C#?

Nov 27, 2010

I 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 Replies

Web Forms :: PayPal Web Payments Standard Submission?

Feb 21, 2011

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.

View 4 Replies

Paypal Accept Credit Card Payments?

Feb 17, 2010

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 Replies

SSL Certificate Type Required For PayPal HTTPS Web Service (Payments Pro SOAP / NVP)

Feb 25, 2011

We 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 Replies

Put The Simplest PayPal Button / "Website Payments Standard Integration Guide"?

Jan 12, 2010

I 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.

View 2 Replies

PayPal Test Example Is Not Working - Getting Error / Unable To Send To PayPal

Nov 1, 2010

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]

View 2 Replies

C# - Paypal API And Paypal's Sample Code?

Oct 30, 2010

https://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

View 1 Replies

Find Recurring Errors In A Log File

Mar 23, 2011

I have a log file with huge volume of errors logged. Now I want to · Screen the log file and find the recurrent errors that are logged. · Give the count of recurrent errors and their text.

View 2 Replies

DataSource Controls :: Recurring Events - Database Setup?

Mar 9, 2010

I would like to create a webform in asp.net that allows you add events to a overall application, anyone then can go search that event by a specific date and if that event falls under that recurrence day you will see it. This would be similar to Outlook where you can say it recurs every Monday, Tuesday, Wednesday,... or every third Monday, ...Specifc day of the month, etc. I have created the webform but now I have the problem of how the database works. I have been reading for the past couple days about this but I cannot figure this out. I found some posts that say you can create a seperate table aside from your main table that holds the eventid and the dates of the recurrenecs. The problem is this table could amount to thousands of lines from just a few events input. My question is, is there a formula out there that can do this without creating a crazy big recurrence table? .... If not, how many lines can a MS SQL database hold before it has performance problems?

Here's a link to another forum I found with my same question but I do not understand the answer:

[URL]

View 5 Replies

How To Process Credit Card Payments

Aug 22, 2010

i have a web app.. and need to process credit card payments. recommend the best payment gateway provider that is easy to implement?

View 3 Replies

C# - How To Receive Payments From NopCommerce Shop

Jul 7, 2010

The setup was incredibly easy. The shop was up and running (Local server, for now!) But then I am confused. When the user will purchase a product from my shop, how will I receive the payment?

I searched a lot in order to setup my credit card/accounnt/paypal information in the Admin area, but I couldnt find anything...

View 3 Replies

Process Payments And Receive Amounts For Purchase The Store Has Made?

Jun 2, 2010

I am building a website for a small store. I want to know the concepts of payment methods.

I mean how to process payments and receive amounts for purchase the store has made.

View 4 Replies

Web Forms :: Events / Task Calendar - Recurring Events / Tasks Design / Finding Proper Example

Jan 11, 2010

I have been tasked with designing a scheduling system to fit into an existing application. At present I have a SQL Table - Tasks which have a StartDate and EndDate column.

I have a requirement to set the Task as a recurring task i.e. Replace server backup tapes every day, or, Order more stationary once a month.

I am lost on how to design this. I can't seem to find a proper example on the net. can someone point me in the right direction.

View 1 Replies

Trying To Use IIS For Paypal Purpose?

Jul 5, 2010

what i want to do is to get the current ip i have (with a site as, http://whatismyip.com/) and send it to paypal sandbox so i can get a response (of course i haven't started the paypal code but i first need to be able to get a communication from paypal,non?)Ok the problem is that if i start a new web site on IIS, hit the current ip, i get my router administration console as a response.I have tried to change the port on a new site to 81 or 82 or 83 but i get a page not found.

View 11 Replies

MVC :: PayPal PDT Integration With MVC?

Jan 20, 2010

I 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 Replies

C# - Get Details From Paypal?

May 12, 2010

Is it possible to have a user sign into mywebsite via paypal and have the website retrieve the user's paypal postal address?

View 1 Replies

PayPal Integration Wizard?

May 5, 2010

I'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?

View 1 Replies

How To Use Express Checkout Using PayPal API

Jun 29, 2010

How to use express checkout using PayPal API in ASP.NET

View 1 Replies

Integrating PayPal Subscription With C#.Net 2.0?

Aug 4, 2010

I am having a problem of integrating paypal with my site. All the process works great i.e., site successfully redirects to paypal and the users can successfully subscibe, but the problem is the "notify_Url" variable redirects the paypal to my site page but when I send a request from that page to validate the payment process the paypal always send the response as "Invalid". I am using a Subscribe button of paypal.

View 1 Replies

Paypal And IPN.. How To Automate Payment ?

Jul 6, 2010

i'm trying to integrate Paypal in an asp.net app. It works fine, the last thing i would like to do is to automize payment notify.

In particular, how does it works IPN ? I would like to set a field to 1 when a user buy a service... How can i do with ipn ?
I'm asking here to avoid to read all 120 pages of paypal IPN documentation... ;)

View 1 Replies

To Change The Paypal Web Reference?

Mar 10, 2011

I have a site in asp.net and I use paypal sandboox what I need to do now ? (if I need to change the web referfnce what is url ? at sandbox is Works fine .

View 1 Replies

How To Integrate Paypal With Ecommerce Website

Jan 22, 2010

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 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved