I’ve used Paypal in the past as a quick and simple way to add a Pay Now button to a website.
The code for the form on the Pay Now page looked like this
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="client_id">
<input type="hidden" name="lc" value="GB">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="amount" value="<%=Price %>">
<input type="hidden" name="item_name" value="<%=Product %>">
<input type="hidden" name="item_number" value="<%=ProductID %>" />
<input type="hidden" name="rm" value="1">
<input type="hidden" name="return" value="http://www.example.com/payment-complete.asp">
<input type="hidden" name="cancel_return" value="http://www.example.com/take-payment.asp">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynowCC_LG.gif:NonHosted">
<input type="image" src="https://www.example.com/img/pay-now-button.png" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
I was able to pass Price, Product and Product ID to Paypal, pre populating the payment page with my variables. The payment-complete.asp page (sample code below) would receive data from paypal about the transaction:
Dim authToken, txToken
Dim query
Dim objHttp
Dim sQuerystring
Dim sParts, iParts, aParts
Dim sResults, sKey, sValue
Dim i, result
Dim firstName, lastName, itemName, mcGross, mcCurrency
authToken ="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
txToken = Request.Querystring("tx")
query = "cmd=_notify-synch&tx=" & txToken & "&at=" & authToken
set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
objHttp.open "POST", "http://www.paypal.com/cgi-bin/webscr", false
objHttp.Send query
sQuerystring = objHttp.responseText
If Mid(sQuerystring,1,7) = "SUCCESS" Then
Transaction was successfully, perform database update
ELSE
Transaction failed, tell customer
END IF
I’ve now gone to create a new paypal account to create a similar set up for another website and Ive discovered its no longer done this way.
So my question, is there a simple/similar system to this where I can pass a few variables like price, product name etc, and it takes the payment, and returns, if successful to the website
1
The integration method in your question is deprecated, although it may still function it should not be used for new integrations. Possible things to use instead:
- Standard JS SDK + REST API backend integration
- Use some off the shelf pre-integrated solution. Just about all ecommerce options integrate with PayPal so search the web or start with the official PayPal partner directory.
- The new “Pay link or button” solution at http://www.paypal.com/buttons . This does not have much functionality for programmers, no way to pass variables.