Paypal API and IPN

I've got a Paypal IPN script that works fine with a normal Paypal transaction where the buyers logs into their PP acct and pays that way.

I'm trying to connect the IPN script to a PP API seamless credit card transaction where the buyer never leaves my site. The transaction processes OK but not all the data I need is sent to the IPN. I get first and last name but no address, city state or zip.

Should the NVPs be different on a credit card API transaction then on a normal transaction?

What am I missing here?

I'm using classic ASP.
webdorkAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nanharbisonCommented:
Why don't you collect the address, city, state, zip on your form?
0
webdorkAuthor Commented:
I am.
' DoDirectPaymentReceipt.asp

' Submits a credit card transaction to PayPal using a
' DoDirectPayment request.

' The code collects transaction parameters from the form
' displayed by DoDirectPayment.asp then constructs and sends
' the DoDirectPayment request string to the PayPal server.
' The paymentType variable becomes the PAYMENTACTION parameter
' of the request string.

' After the PayPal server returns the response, the code
' displays the API request and response in the browser.
' If the response from PayPal was a success, it displays the
' response parameters. If the response was an error, it
' displays the errors.

' Called by DoDirectPayment.asp.

' Calls CallerService.asp and APIError.asp.

'-----------------------------------------------------------------------------
	Dim firstName
	Dim lastName
	Dim creditCardType
	Dim creditCardNumber
	Dim expDateMonth
	Dim expDateYear
	Dim padDate
	Dim cvv2Number
	Dim address1
	Dim address2
	Dim city
	Dim state
	Dim zip
	Dim amount
	Dim currencyCode
	Dim paymentType
	Dim nvpstr
	Dim resArray
	Dim ack
	Dim message
      Dim gv_APIUserName
	Dim gv_APIPassword
	Dim gv_APISignature
	Dim gv_Version
      Dim gv_SUBJECT
      


	firstName			= Request.Form("firstName")
	lastName			= Request.Form("lastName")
	creditCardType		= Request.Form("creditCardType")
	creditCardNumber	      = Request.Form("creditCardNumber")
	expDateMonth		= Request.Form("expDateMonth")
	expDateYear			= Request.Form("expDateYear")
	padDate			= expDateMonth&expDateYear
	cvv2Number			= Request.Form("cvv2Number")
	address1			= Request.Form("address1")
	address2			= Request.Form("address2")
	city				= Request.Form("city")
	state				= Request.Form("state")
	zip				= Request.Form("zip")
	amount			= Request.Form("amount")
	'currencyCode		=Request.Form("currency")
	currencyCode		= "USD"
	paymentType			=Request.Form("paymentType")
      gv_APIUserName	      = API_USERNAME
	gv_APIPassword	      = API_PASSWORD
	gv_APISignature         = API_SIGNATURE
	gv_Version		      = API_VERSION
	gv_SUBJECT              = SUBJECT
      

'-----------------------------------------------------------------------------
' Construct the request string that will be sent to PayPal.
' The variable $nvpstr contains all the variables and is a
' name value pair string with &as a delimiter
'-----------------------------------------------------------------------------
	nvpstr	=	"&PAYMENTACTION=" &paymentType & _
				"&AMT="&amount &_
				"&CREDITCARDTYPE="&creditCardType &_
				"&ACCT="&creditCardNumber & _
				"&EXPDATE=" & padDate &_
				"&CVV2=" & cvv2Number &_
				"&FIRSTNAME=" & firstName &_
				"&LASTNAME=" & lastName &_
				"&STREET=" & address1 &_
				"&CITY=" & city &_
				"&STATE=" & state &_
				"&ZIP=" &zip &_
				"&COUNTRYCODE=US" &_
				"&CURRENCYCODE=" & currencyCode
                       
     nvpstr	=	URLEncode(nvpstr)

     If IsEmpty(gv_SUBJECT) Then
      
     nvpStr =nvpstr&"&USER=" & gv_APIUserName &_
                              "&PWD=" &gv_APIPassword &_
                              "&SIGNATURE=" & gv_APISignature &_
                              "&VERSION=" & gv_Version

     ElseIf IsEmpty(gv_APIUserName )and IsEmpty(gv_APIPassword) and IsEmpty(gv_APISignature) Then

     nvpStr =nvpstr&"&SUBJECT=" & gv_SUBJECT &_
                              "&VERSION=" & gv_Version

     Else
     
     nvpStr =nvpstr&"&USER=" & gv_APIUserName &_
                              "&PWD=" &gv_APIPassword &_
                              "&SIGNATURE=" & gv_APISignature &_
                              "&VERSION=" & gv_Version &_
                              "&SUBJECT=" & gv_SUBJECT 
     End If
'-----------------------------------------------------------------------------
' Make the API call to PayPal,using API signature.
' The API response is stored in an associative array called gv_resArray
'-----------------------------------------------------------------------------
	Set resArray	= hash_call("doDirectPayment",nvpstr)
	ack = UCase(resArray("ACK"))
'----------------------------------------------------------------------------------
' Display the API request and API response back to the browser.
' If the response from PayPal was a success, display the response parameters
' If the response was an error, display the errors received
'----------------------------------------------------------------------------------
	If ack="SUCCESS" Then
		message="Thank you for your payment!"

      ElseIf ack="SUCCESSWITHWARNING" Then
           message="Thank you for your payment!"
	Else
		 Set SESSION("nvpErrorResArray") = resArray
		 Response.Redirect "APIError.asp"
	End If

Open in new window

0
Gary DavisDir Internet SvcsCommented:
You are sending the billing address to PayPal so it can verify the address matches the credit card. This is not always the same as the shipping information you would need to send the product so it is your responsibility to collect the shipping info and save it to the database and when the IPN comes in saying the payment is complete, you can then fulfill the order.

Usually, you will use the INVOICE or CUSTOM fields in the transaction to hold your database order ID to tie the database record together with the PayPal transaction. These fields will come in on the IPN. Using INVOICE is handy to help prevent duplicate orders since PayPal will not accept a second transaction with the same INVOICE value.

Gary Davis
Webguild.com
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Gary DavisDir Internet SvcsCommented:
Also, this statement looks wrong:

   nvpstr      =      URLEncode(nvpstr)

You are encoding the entire sting which will also encode the = and & which should not be encoded or else PayPal will not see the individual keyword/value pairs. Instead, URLEncode just the values that may have special characters like the name and address:

   "&FIRSTNAME=" & URLEncode(firstName) &_

Gary
0
Scott MadeiraCommented:
If you look at the PayPal documentation for DoDirectPayment, you will see the limited info that you get back.  It doesn't return the stuff you are asking about.  Here is a link:

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoDirectPayment 

Go down to the section on DoDirectPayment Response fields to see what you will get.  I've never used this function but it looks like the response is only a good  / bad kind of response with some of the details as to why it is good or bad.
0
webdorkAuthor Commented:
thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.