Just wondering if anyone has a the source code for setting up a PayPal page which allows the customer to:
1. Enter some information (eg. fav colour)
2. Enter some more information (eg. fav number)
3. Back end validates if the colour they entered is a colour and their fav number is in fact a number.
4. If it’s invalid it displays an error message else it takes them to PayPal checkout page where they pay.
5. Upon successful payment, email them “your fav colour is _____ and your fav number is ____”. Doesn’t have to email, I just want their fav colour and number as a variable at the end. Confused how I can get PayPal to send this to the PayPal listener
Obviously this is a mock up scenario
The validation thing was an example. I know exactly how to validate the input (code wise).
I know how to do step 1, 2, 3. From step 4 and 5.
Example
1. John enters red as his fav color
2. John enters 5 as his fav number
3. John clicks submit. However, with PayPal buttons, the action on the form is pointing to paypal's website. So I cannot validate the color and the number.
From this point on I am lost.
Create a null button, add the to it your verification thingy, if it returns True, direct the user to paypal, as in make the code "hit the button", if false, decline
that's just a stupid basic solution
Example
[PAYPAL BUTTON] is X
[NEW BUTTON] is Y
[your verification code] Z
if Z is true
hit X
else cancel
Last edited by Default; 07-11-2019 at 11:03 PM.
Not your average fuckboy
Yea but the thing is when you click on the PayPal button, all the custom fields (color and number) are gone. This is because there is another file which listens to PayPal. So when that file detects a transaction, then it means the transaction was successful. Its not all done in the same script.
make one. paypal is well documented.
google "paypal IPN documentation"
if u need a hand, lmk, i've implemented it several times.
Click Here to visit the official MPGH wiki! Keep up with the latest news and information on games and MPGH! To check out pages dedicated to games, see the links below!
dd/mm/yyyy
Member - 31/01/2015
Premium - 12/09/2016
Call of Duty minion - 05/11/2016 - 05/11/2019
BattleOn minion - 28/02/2017 - 05/11/2019
Battlefield minion - 30/05/2017 - 05/11/2019
Other Semi-Popular First Person Shooter Hacks minion - 21/09/2017 - 17/09/2019
Publicist - 07/11/2017 - 02/08/2018
Cock Sucker - 01/12/2017 - Unknown
Minion+ - 06/03/2018 - 05/11/2019
Fortnite minion - 08/05/2018 - 05/11/2019
Head Publicist - 08/10/2018 - 10/01/2020
Developer Team - 26/10/2019 - 10/01/2020
Former Staff - 10/01/2020
@Allura I think this might be of some help.
What I did is I merged the color and favorite number with the itemname delimited by '@';
You can receive the itemname in your IPN callback and then get back the original values by exploding the string with '@'. That returns an array.
shop.php
PAYPALHCECKOUT.phpCode:<?php $COLORS = array("RED","BLUE"); if(isset($_POST['BUY'])){ //YOUR SHOP LOGIC/, COMPUTE PRICE DETAILS ETC. I JUST HARDCODED THEM. $TOTAL_ORDER_PRICE = "10"; $ITEM_NUMBER = "45678002"; $ITEM_NAME = "MPGH PREMIUM"; $selectedColor = $_POST['COLOR']; $selectedNumber = $_POST['FAVNUMBER']; if (in_array($selectedColor, $COLORS) && is_numeric($selectedNumber)){ include('PAYPALHCECKOUT.php'); } else{ echo "<span style='color:red'>Error with Options</span>"; } } ?> <form method="POST"> Enter Number: <br> <input name="FAVNUMBER" type="number"> Choose Color: <br> <select name="COLOR"> <?php foreach($COLORS as $KEY=>$VALUE) echo '<option value=".$VALUE.">'.$VALUE.'</option>'; ?> </select> <button type="submit" name="BUY">CHECKOUT</button> </form>
Code:<?php $PAYPAL_ACTION = 'https://www.paypal.com/cgi-bin/webscr'; $PAYPAL_EMAIL = "allura@mpgh.net"; //YOUR payment URL $RETURN_URL = 'success.php'; $CANCEL_URL = 'failed.php'; $NOTIFY_URL = 'notify.php'; //YOUR IPN CALLBACK URL //Workaround $ITEM_NAME = $ITEM_NAME."@".$selectedColor."@".$selectedNumber; ?> <html> <head> <title>Please wait - Redirecting</title> <style>@import url('https://fonts.googleapis.com/css?family=Poppins');</style> </head> <body> <center> <h2 style="font-size:6vw; font-family: 'Poppins', sans-serif;">You are being redirected <br> <img src="loader.gif"> <br> <span style='color:green'>CHECKOUT</span></h2><br> <span style="font-family: 'Poppins', sans-serif;">PLEASE DON'T REFRESH OR HIT THE BACK BUTTON</span> </center> <form name="myform" action="<?php echo $PAYPAL_ACTION; ?>" method="post" target="_top"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="cancel_return" value="<?php echo $CANCEL_URL ?>"> <input type="hidden" name="notify_url" value="<?php echo $NOTIFY_URL ?>"> <input type="hidden" name="return" value="<?php echo $RETURN_URL; ?>"> <input type="hidden" name="business" value="<?php echo $PAYPAL_EMAIL; ?>"> <input type="hidden" name="item_name" value="<?php echo $ITEM_NAME; ?>"> <input type="hidden" name="item_number" value="<?php echo $ITEM_NUMBER; ?>"> <input type="hidden" name="amount" value="<?php echo $TOTAL_ORDER_PRICE; ?>"> <input type="hidden" name="button_subtype" value="services"> <input type="hidden" name="no_note" value="0"> </form> <script type="text/javascript"> document.myform.submit(); </script> </body> </html> exit();
notify.php
Code:<?php $raw_post_data = file_get_contents('php://input'); $raw_post_array = explode('&', $raw_post_data); $myPost = array(); foreach ($raw_post_array as $keyval) { $keyval = explode ('=', $keyval); if (count($keyval) == 2) $myPost[$keyval[0]] = urldecode($keyval[1]); } // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' $req = 'cmd=_notify-validate'; if (function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($myPost as $key => $value) { if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= "&$key=$value"; } // Step 2: POST IPN data back to PayPal to validate $ch = curl_init('https://ipnpb.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));; if ( !($res = curl_exec($ch)) ) { curl_close($ch); exit; } curl_close($ch); $item_number=$myPost['item_number']; $item_name=$myPost['item_name']; //itemname@color@number $payment_gross=$myPost['payment_gross']; $txn_id=$myPost['txn_id']; //Your Original Details Back $CUSTOM_ITEM_DETAILS = explode("@",$item_name); //break the string at intervals of delimiter '@' $REAL_ITEM_NAME = $CUSTOM_ITEM_DETAILS[0]; $selectedColor = $CUSTOM_ITEM_DETAILS[1]; $selectedNumber = $CUSTOM_ITEM_DETAILS[2]; ?>
Last edited by hackinet7; 07-14-2019 at 04:24 AM.
Allura (07-14-2019)
Click Here to visit the official MPGH wiki! Keep up with the latest news and information on games and MPGH! To check out pages dedicated to games, see the links below!
dd/mm/yyyy
Member - 31/01/2015
Premium - 12/09/2016
Call of Duty minion - 05/11/2016 - 05/11/2019
BattleOn minion - 28/02/2017 - 05/11/2019
Battlefield minion - 30/05/2017 - 05/11/2019
Other Semi-Popular First Person Shooter Hacks minion - 21/09/2017 - 17/09/2019
Publicist - 07/11/2017 - 02/08/2018
Cock Sucker - 01/12/2017 - Unknown
Minion+ - 06/03/2018 - 05/11/2019
Fortnite minion - 08/05/2018 - 05/11/2019
Head Publicist - 08/10/2018 - 10/01/2020
Developer Team - 26/10/2019 - 10/01/2020
Former Staff - 10/01/2020
Scrooge McDuck (07-14-2019),Silent (07-14-2019),Ticherhaz (07-14-2019)
Nothing, persay, it's just extremely oversimplified. There are countless IPN responses from PayPal, with conditional variables that may never be sent. The code he sent is a bad example.
Take a look at PayPal's ****** account, they offer examples.
https://******.com/paypal/PayPal-PHP-SDK
Click Here to visit the official MPGH wiki! Keep up with the latest news and information on games and MPGH! To check out pages dedicated to games, see the links below!
dd/mm/yyyy
Member - 31/01/2015
Premium - 12/09/2016
Call of Duty minion - 05/11/2016 - 05/11/2019
BattleOn minion - 28/02/2017 - 05/11/2019
Battlefield minion - 30/05/2017 - 05/11/2019
Other Semi-Popular First Person Shooter Hacks minion - 21/09/2017 - 17/09/2019
Publicist - 07/11/2017 - 02/08/2018
Cock Sucker - 01/12/2017 - Unknown
Minion+ - 06/03/2018 - 05/11/2019
Fortnite minion - 08/05/2018 - 05/11/2019
Head Publicist - 08/10/2018 - 10/01/2020
Developer Team - 26/10/2019 - 10/01/2020
Former Staff - 10/01/2020
Yes, Silent is correct. It might vary. But I am not integrating the SDK. Just using the classic PayPal form, so...the responses would remain the same. Here's the sample IPN Code on their site: https://developer.paypal.com/docs/classic/ipn/ht-ipn/
their responses vary depending on many factors, ranging from payment method (card, bank, balance), to security reasons (paypal may hold money whilst they investigate shit). They also may send multiple IPN's for transactions, for example, a pending stage.
Point is, don't use a PayPal integration unless you're willing to invest the time to read documentation.
@Allura, as much as I hate recommending CMS's, just use one. They're easy, free, and they got a tonne of support.
Click Here to visit the official MPGH wiki! Keep up with the latest news and information on games and MPGH! To check out pages dedicated to games, see the links below!
dd/mm/yyyy
Member - 31/01/2015
Premium - 12/09/2016
Call of Duty minion - 05/11/2016 - 05/11/2019
BattleOn minion - 28/02/2017 - 05/11/2019
Battlefield minion - 30/05/2017 - 05/11/2019
Other Semi-Popular First Person Shooter Hacks minion - 21/09/2017 - 17/09/2019
Publicist - 07/11/2017 - 02/08/2018
Cock Sucker - 01/12/2017 - Unknown
Minion+ - 06/03/2018 - 05/11/2019
Fortnite minion - 08/05/2018 - 05/11/2019
Head Publicist - 08/10/2018 - 10/01/2020
Developer Team - 26/10/2019 - 10/01/2020
Former Staff - 10/01/2020