Paypal Mod
Paypal Mod
Has anyone gotten the paypal mod to work. I have tried everything and am still getting nowhere.
Mike
Mike
Re: Paypal Mod
I have it working now in a sql version.
-
- Posts: 59
- Joined: Thu Sep 05, 2013 3:21 pm
Re: Paypal Mod
How did you get this to work. I have had no luck
Re: Paypal Mod
Mike,
Do you have the code for SQL version of PayPal? I sure could use a copy. Thanks
Do you have the code for SQL version of PayPal? I sure could use a copy. Thanks
Re: Paypal Mod
I have it working in the access version.
Re: Paypal Mod
Did you set up the IPN settings in your paypal account?
Re: Paypal Mod
My code for the paymentnotify.asp page.
You need to make sure you have the ipn settings set up to direct to this page on your server.
My header and connection files are most likely different than yours.
<%@ LANGUAGE="VBScript" %>
<!-- #include file="connection/connection.asp" -->
<!-- #include file="header2014.asp" -->
<!-- #include file="includes/encryption.asp" -->
<!-- #include file="includes/payments.asp" -->
<% 'Get the posted data and append the validate command parameter.
dim postData
postData = Request.Form & "&cmd=_notify-validate"
'Validate the notification.
dim xmlHttp, validateResponse
set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlHttp.open "POST", PAYPAL_VERIFY_URL, false
xmlHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
xmlHttp.Send(postData)
validateResponse = xmlHttp.responseText
'Open the database.
call OpenDb()
'Log the notification data.
dim sql
dim data
data = Encrypt(Request.Form)
sql = "INSERT INTO PaymentNotifications" _
& " ([Timestamp], Data, Response)" _
& " VALUES('" & GetCurrentDateTime() & "'," _
& " '" & data & "'," _
& " '" & validateResponse & "')"
call DbConn.Execute(sql)
'If valid, process the data.
dim txn, invoice, payment, handling, username, description, amount
if validateResponse = "VERIFIED" then
'For completed payments and refunds, update the user's account.
if Request.Form("payment_status") = "Completed" or _
Request.Form("payment_status") = "Refunded" then
'Get the payment data.
txn = Request.Form("txn_id")
invoice = Request.Form("invoice")
payment = Request.Form("payment_gross")
handling = Request.Form("handling_amount")
username = Request.Form("custom")
description = "Payment"
if Request.Form("payment_status") = "Refunded" then
description = "Refund"
handling = -handling
end if
description = description & " (PayPal: INV# " & invoice & ", TXN# " & txn & ")"
amount = Round(payment - handling, 2)
'Create and insert the payment record.
sql = "INSERT INTO Credits" _
& " (Username, [Timestamp], Description, Amount)" _
& " VALUES('" & Sqlstring(username) & "'," _
& " '" & GetCurrentDateTime() & "'," _
& " '" & Sqlstring(description) & "'," _
& " " & amount & ")"
call DbConn.Execute(sql)
end if
end if %>
Also, on the makepayment.asp page, I think you need to have these lines set up this way.
<form id="paypalForm" action="<% = PAYPAL_PAYMENT_URL %>" method="post">
<div>
<input type="hidden" name="amount" value="" />
<input type="hidden" name="business" value="<% = PAYPAL_BUSINESS %>" />
<input type="hidden" name="cancel_return" value="yoursitename/Paymentcanceled.asp" />
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="custom" value="<% = Session(SESSION_USERNAME_KEY) %>" />
<input type="hidden" name="handling" value="" />
<input type="hidden" name="invoice" value="" />
<input type="hidden" name="item_name" value="<% = PAYPAL_ITEM_NAME %>" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="notify_url" value="yoursitename/paymentNotify.asp">
<input type="hidden" name="return" value="yoursitename/paymentComplete.asp" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="tax" value="0" />
</div>
</form>
You need to make sure you have the ipn settings set up to direct to this page on your server.
My header and connection files are most likely different than yours.
<%@ LANGUAGE="VBScript" %>
<!-- #include file="connection/connection.asp" -->
<!-- #include file="header2014.asp" -->
<!-- #include file="includes/encryption.asp" -->
<!-- #include file="includes/payments.asp" -->
<% 'Get the posted data and append the validate command parameter.
dim postData
postData = Request.Form & "&cmd=_notify-validate"
'Validate the notification.
dim xmlHttp, validateResponse
set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlHttp.open "POST", PAYPAL_VERIFY_URL, false
xmlHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
xmlHttp.Send(postData)
validateResponse = xmlHttp.responseText
'Open the database.
call OpenDb()
'Log the notification data.
dim sql
dim data
data = Encrypt(Request.Form)
sql = "INSERT INTO PaymentNotifications" _
& " ([Timestamp], Data, Response)" _
& " VALUES('" & GetCurrentDateTime() & "'," _
& " '" & data & "'," _
& " '" & validateResponse & "')"
call DbConn.Execute(sql)
'If valid, process the data.
dim txn, invoice, payment, handling, username, description, amount
if validateResponse = "VERIFIED" then
'For completed payments and refunds, update the user's account.
if Request.Form("payment_status") = "Completed" or _
Request.Form("payment_status") = "Refunded" then
'Get the payment data.
txn = Request.Form("txn_id")
invoice = Request.Form("invoice")
payment = Request.Form("payment_gross")
handling = Request.Form("handling_amount")
username = Request.Form("custom")
description = "Payment"
if Request.Form("payment_status") = "Refunded" then
description = "Refund"
handling = -handling
end if
description = description & " (PayPal: INV# " & invoice & ", TXN# " & txn & ")"
amount = Round(payment - handling, 2)
'Create and insert the payment record.
sql = "INSERT INTO Credits" _
& " (Username, [Timestamp], Description, Amount)" _
& " VALUES('" & Sqlstring(username) & "'," _
& " '" & GetCurrentDateTime() & "'," _
& " '" & Sqlstring(description) & "'," _
& " " & amount & ")"
call DbConn.Execute(sql)
end if
end if %>
Also, on the makepayment.asp page, I think you need to have these lines set up this way.
<form id="paypalForm" action="<% = PAYPAL_PAYMENT_URL %>" method="post">
<div>
<input type="hidden" name="amount" value="" />
<input type="hidden" name="business" value="<% = PAYPAL_BUSINESS %>" />
<input type="hidden" name="cancel_return" value="yoursitename/Paymentcanceled.asp" />
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="custom" value="<% = Session(SESSION_USERNAME_KEY) %>" />
<input type="hidden" name="handling" value="" />
<input type="hidden" name="invoice" value="" />
<input type="hidden" name="item_name" value="<% = PAYPAL_ITEM_NAME %>" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="notify_url" value="yoursitename/paymentNotify.asp">
<input type="hidden" name="return" value="yoursitename/paymentComplete.asp" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="tax" value="0" />
</div>
</form>
Re: Paypal Mod
The IPN settings set up in my selling tools in Paypal, sorry.