Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 07-14-2017, 03:09 PM   #1
Smack dat
So Fucking Banned
 
Industry Role:
Join Date: Jul 2016
Posts: 4,613
Help with some Javascript PayPal related.

I accept PayPal on my website and I would like to provide a coupon code for certain persons. As I understand it PayPal don't offer this directly through their website but it is possible.

I found this website https://www.paypal-knowledge.com/inf...1512&actp=LIST

Which says you can add the following code into the custom field (on PayPal)
Code:
<script type="text/javascript">
<!--
var discnt = 0; // no default percent discount

var coupons = new Array ( // place to put coupon codes
"coup1", // 1st coupon value - comma seperated
"coup2", // 2nd coupon value - add all you want
"coup3" // 3rd coupon value
);
var coupdc = new Array ( // place to put discounts for coupon vals
5,
10,
15
);
var coupval = "(blanket)"; // what user entered as coupon code

function ChkCoup () { // check user coupon entry
var i;
discnt = 0; // assume the worst
for (i=0; i<coupons.length; i++) {
if (coupval == coupons[i]) {
discnt = coupdc[i]; // remember the discount amt
alert ("Valid coupon number! \n\n" + discnt +
"% discount now in effect.");
return;
}
}
alert ("'" + coupval + "' is not a valid code!");
}

function Dollar (val) { // force to valid dollar amount
var str,pos,rnd=0;
if (val < .995) rnd = 1; // for old Netscape browsers
str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape
pos = str.indexOf (".");
if (pos > 0) str = str.substring (rnd, pos + 3);
return str;
}

function ReadForm (obj1) { // apply the discount
var amt,des;
amt = obj1.baseamt.value*1.0; // base amount
des = obj1.basedes.value; // base description

if (discnt > 0) { // only if discount is active
amt = Dollar (amt - (amt * discnt/100.0));
des = des + ", " + discnt + "% dis, COUP = " + coupval;
}

obj1.amount.value = Dollar (amt);
obj1.item_name.value = des;
}
//-->
</script>
It then say you would add the following code to your website
Code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="this.target = 'paypal';
return ReadForm (this);">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="your_email_goes_here@your_site.com" />
<input type="hidden" name="item_name" value="2nd Item" />
<input type="hidden" name="amount" value="20.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="baseamt" value="20.00" />
<input type="hidden" name="basedes" value="2nd Item @20.00" />

Enter Coupon code [coup1] &gt;
<input type = "text"
size = "10"
name = "coupcode"; />

<input type="button" value="Check It"
onclick="coupval = this.form.coupcode.value;
ChkCoup();" />

Input quantity &gt;
<input type="text" name="quantity" value="1" size="4" />

<input type="image" src="addcart.gif" name="submit" alt="cart add" />
</form>
I haven't tried this but just need a simple "Pay Now" button that offers people the chance to input a code into a text field for a discount to be applied.
I tried the code in an online HTM viewer and it looked naff.

Anyone tell me if this is at all suitable for 2017 or can give me a better suggestion / code.

Last edited by Smack dat; 07-14-2017 at 03:16 PM.. Reason: Changed from business to Tech for moar VIEWS!!!!!!!!!!!!
Smack dat is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
code, website, paypal, field, add, coupon, input, pay, discount, simple, people, chance, offers, button, text, viewer, suitable, suggestion, applied, online, htm, naff, looked, custom, persons



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.