Page 1 of 1

Paypal Mod

Posted: Sat Aug 01, 2015 9:36 am
by hedpe_23
Has anyone gotten the paypal mod to work. I have tried everything and am still getting nowhere.

Mike

Re: Paypal Mod

Posted: Mon Aug 03, 2015 7:02 pm
by hedpe_23
I have it working now in a sql version.

Re: Paypal Mod

Posted: Tue Aug 04, 2015 10:28 am
by kingmullet
How did you get this to work. I have had no luck

Re: Paypal Mod

Posted: Wed Aug 05, 2015 4:59 pm
by HZass
Mike,
Do you have the code for SQL version of PayPal? I sure could use a copy. Thanks

Re: Paypal Mod

Posted: Thu Aug 06, 2015 7:58 pm
by jhronesz
I have it working in the access version.

Re: Paypal Mod

Posted: Sun Aug 09, 2015 4:04 pm
by hedpe_23
Did you set up the IPN settings in your paypal account?

Re: Paypal Mod

Posted: Mon Aug 10, 2015 5:06 pm
by hedpe_23
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>

Re: Paypal Mod

Posted: Mon Aug 10, 2015 5:07 pm
by hedpe_23
The IPN settings set up in my selling tools in Paypal, sorry.