I created a basic purchase script where a user enters their desired username and password, then they can purchase the membership on my website. But, when it goes to the return page, the values Username and Password don't show in the url. Here is the code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="CKQH4CYEMYLWW">
<center>
<span id="msgbox" style="display:none;"></span>
<br><br>
<input type="text" id="rusername" name="rusername" placeholder="Desired Username" class="usernamelogin">
<br><br>
<input type="password" id="rpassword" name="rpassword" placeholder="Desired Password" class="passwordlogin">
<br><br>
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" 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>
set cookie variable for each input variable and pass the data accordingly . . and on return from paypal you can simply check the cookie variable and pass the data in the individual input accordingly ..
Paypal Standard gives one variable 'custom' for passing custom data
so you can have a way to pass those values using this variable and getting back.
eg. you can seperate the values using | and get back
<input type="hidden" id="custom" name="custom" value="username|password"/>
you can set the values when your form is going to be submitted
when success page comes you can get the values
list($username,$password) = explode('|',$_POST['custom']);
Related
I am trying to get this line of product info here to pass into PayPal form using the custom varible <input type="hidden" name="custom" value="SansburyTech|Purchase of a ToolCart|Dewalt Roller|SKU:164604646|Cost:163.50"> but its not happening?
Is there something I am doing wrong or overlooking? Here on PayPalDocs it says specifically: The following are pass-through variables: custom or item_number or item_number_x or invoice
Here is my complete HTML Paypal form as an example;
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin:0;padding:0;" target="PayPal">
<input type="hidden" name="business" value="">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="Toolcart">
<input type="hidden" name="item_number" value="Dewalt Roller">
<input
type="hidden"
name="custom"
value="SansburyTech|Purchase of a ToolCart|Dewalt Roller|SKU:164604646|Cost:163.50">
<input type="hidden" name="amount" value="244.50">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="receiver_email" value="">
<input type="hidden" name="return" value="https://toolcart.info/pickup">
<input type="hidden" name="no_note" value="0">
<input type="image" src="/wp-content/themes/toolcart-theme/images/paypal.png" class="img-fluid" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Will be incredibly grateful for any answers!
~ Thank-you!
Converting my comment to an answer (for that sweet sweet karma).
The OP was looking for the custom variable to appear in the PayPal-generated e-mail messages that get sent back to the merchant account-holder (or to the customer). This won't work because PayPal does not include the custom variable in any e-mail messages: it's only included in IPN messages.
Usually the best solution is to pass only a unique identifier and store the rest in own your database.
But if you must pass multiple values in the arbitrary custom field, the pipes in your example seem problematic. Use base64 encoding or a different delimiter--JSON format is a common choice here, then you can simply decode it into an array when receiving the IPN.
I have the following PayPal button set up:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="SN3834XQZMRCW">
<table>
<tr><td><input type="hidden" name="on0" value="Minecraft Username:">Minecraft Username:</td></tr>
<tr><td><input type="text" name="os0" maxlength="200"></td></tr>
<tr><td><input type="hidden" name="on1" value="TeamSpeak UID:">TeamSpeak UID:</td></tr>
<tr><td><input type="text" name="os1" maxlength="200"></td></tr>
</table>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
According to the documentation, the two hidden fields I have simply get passed to PayPal and then back to my PHP script. To get these values, would it be correct to use the following:
$_POST['TeamSpeak UID:'];
Before you ask, I can't seem to send these custom fields using the simulator, unless the fields are encapsulated within the custom field? The documentation and help seems to be lacking here. Thanks for any help.
I have the following form
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="N8Q3XBTNBV8TY">
<table>
<tr><td><input type="hidden" name="on0" value="Team Name">Team Name</td></tr><tr><td><input type="text" name="os0" maxlength="200"></td></tr>
</table>
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
I want to validate (using php) that the team name is at least three characters long before the form is submitted. How would I implement this?
You can't (if you're submitting directly to PayPal, as you are in your code example), using PHP. But you can use javascript.
<script>
// using jQuery, just cuz it's easier for this sort of stuff
$('form[action*="paypal"]').submit(function(event) {
if ($('input[name="on0"]').val().length < 3) {
event.preventDefault();
// alert, or use some other means of displaying an error to the user
alert('Your Team Name must be at least 3 characters long');
return false;
}
});
</script>
I have created a new business account in paypal and created a button but I have these two problems;
1. when I passed the price for service, and user click (pay now) button then user go to paypal page but the price that I put is not showing as a primary price in paypal page.
the item price is empty in paypal. user has to put the price in paypal too.
and the price that has passed is in (Options: service price: 12) which is not counted in the total amount.
this is the code of the button that I insert it in my page:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="3YNEZFSSJNVR4">
<table>
<tr><td><input type="hidden" name="on0" value="service price">service price</td></tr><tr><td><input type="text" name="os0" maxlength="200"></td></tr>
</table>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
the second problem how I can pass the transaction info to my website to record it in my database? is that need special account different than standard (free) account
it's look like you not have pass the amount value to paypal
<input type="hidden" name="amount" value="<?php echo $total; ?>">
Currently, I am working on a site that uses PayPal to Checkout. I would like to enable stripe, as well, so there can be a "checkout with stripe" button at the bottom of the form.
<form method="POST" id="form1" >
<select id="udidSelect" onchange="udidPrice(this)">
<option value="invalid" disabled="disabled">Choose Package</option>
<option value="udid">UDID Registration</option>
<option value="profile">UDID Registration & Free Unlimited Apps (Provisioning Profile)</option>
</select><br />
<br />
<input type="text" placeholder="Name" /><br />
<br />
<input type="email" placeholder="Email" /><br />
<br />
<input type="text" placeholder="UDID (40 Characters Long)" name="os0" /> <br />
<input type="hidden" name="on0" value="UDID">
<br />
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" id="udidbuttonID" value="9PSTCESRS3FSG">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" value="PayPal" onclick="submitForm('https://www.paypal.com/cgi-bin/webscr')" style="float:right;">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Now I would like to have a PayPal Button at the bottom of the form and a Stripe button at the bottom of the form. And if the user clicked the stripe button, it would take them to the next page and PASS ALONG the information entered in this page. I am not sure how to do this, and I am also not sure how to have different post options for the form. (Sorry I am kind of new to this.)
On the stripe checkout page, also, how would I request that information that was passed along, from the previous form. Would it just be something like this?
<input type="hidden" name="somedata" value="<?php echo $_POST['somedata']; ?>" />
<input type="hidden" name="otherdata" value="<?php echo $_POST['otherdata']; ?>" />
If I'm reading your question correctly, you want the form to go to different pages depending on whether the user clicked on Stripe or Paypal.
You can use JavaScript/jQuery to change the action attribute of the form:
<!--HTML-->
<button onClick="setFormAction('stripe')">Stripe</button>
<button onClick="setFormAction('paypal')">Paypal</button>
//Javascript
function setFormAction(which) {
if (which == 'stripe') {
//Change 'stripe.php' to the proper URL
document.getElementById('form1').action = 'stripe.php';
} else {
document.getElementById('form1').action = 'paypal.php'; //Change this also
}
//Finally, submit the form
document.getElementById('form1').submit();
}
Or, more understandably, the jQuery solution:
<!--HTML-->
<button id="stripe">Stripe</button>
<button id="paypal">Paypal</button>
//Javascript
$('button#stripe').click(function() {
$('form#form1')
.attr('action', 'stripe.php') //Change to proper stripe URL
.submit();
});
$('button#paypal').click(function() {
$('form#form1')
.attr('action', 'paypal.php') //Change to paypal URL
.submit();
});
On the next page, you do exactly what you said previously:
<input type="hidden" name="somedata" val="<?php echo $somedata; ?>" />
Always sanitize user-inputted values before echoing them on the page (therefore the variable $somedata rather than $_POST['somedata'].
An alternative to hidden input fields is sessions. Much easier to handle once you get the hang of it.
Add another line as:
test.php is the page where you want to post this form
<input type="button" border="0" value="Pay with Stripe" onclick="submitForm('test.php')">
in test.php you can get the values like this:
<input type="hidden" name="test" value="<?php echo $_REQUEST['test'] ?>">