Hi
I am trying to process transactions using PayPal SDK. I also want to pass php variables to the PayPal code found on their (PayPal) website.
Attached is process1.txt(php) which has the php and the paypal code for a paypal button inside.
Any help will be appreciated.
Thanks.
Attached File(s)
process1.txt ( 5.64k )
Number of downloads: 664
If this is a paypal process script 'process1.txt(php)' then why all the javascript? PHP (server side scripting) can't run javascript, only the browser can (that's why it's called client side scripting). Javascript can call a PHP script but only if you use AJAX.
Do you want the form to submit when the paypal button is clicked?
Or, do you want the form to stay in place when the paypal button is clicked?
Hi
Thanks for that.
When the form is submitted and the PayPal button is clicked, I want the Price, Graphic and url information appearing in the PayPal environment. I might take up your suggestion to use AJAX.
Thanks.
Hi
Thanks for that.
When I include the updated process1.php (txt) file, I get a white screen. I dont know whats happening.
Attached are the relevant files:
yourart1.php -> form1.php -> process1.php.
A 'white screen' normally means there is an error in the PHP section of the page. Do you get any errors? Did you check the PHP error log? I only know what you tell me but you don't tell much at all.
Give me some time to go over your script.
The only thing that I see is a syntax error. This if statement is missing the closing curly brace.
Hi
Thanks for that. There is no error file produced. Sorry for the lack of information.
Hi
Thanks for that. There is no error file produced. Sorry for the lack of information.
What version of PHP do you use? When I upgraded to PHP 7.14 I copied 'php.ini-development' to php.ini and all the errors appear on screen. Since you say there is no error log do you see PHP errors on screen?
php 8.1
Insert this line at the top of your PHP script:
Hi
I have added 3 hidden input tags in process1.php but I am not sure where to put these in process1.php. Do you put these 3 input tags in the php area or outside the php area of the script process1.php?
Thanks.
Hidden inputs are HTML elements. They go inside the form. When submitted they are passed in the POST array, if you have the name attribute set.
Did any of the error reporting methods work for you?
Hi
Sorry for the late reply.
Yes the error reporting works.
Thanks.
Hi
I found this piece of code on the web:
<?php
function shutdown(){
var_dump(error_get_last());
}
register_shutdown_function('shutdown');
?>
I put this code on top of process1.php script and the output was the word NULL.
Need help!
Thanks.
If error reporting is working now then why do you need this? According to the docs, the shutdown process is called after script execution finishes or exit() is called. When error_get_last is called it returns NULL if there is no error to report. I'll look over your file later, when I have more time. Also, error_get_last returns an array when there is an error. So you should test for an array and use print_r.
Hi
Just a quick one. By any chance you had a look at my program?
Thanks.
Exactly what problem are you having? I thought it was about the shutdown part. Describe the problem, what you expect from your code and what the code actually does.
Hi
Thanks for that.
Process1.php (txt) inserts data in a database from a form (form1.php). It also should produce a paypal button for users to pay with paypal. I ran php -l process1.php and found there to be no syntax errors.
The latest version of process1.txt is that I removed the try-catch block to make it simpler (attached).
Any help would be appreciated.
I don't think I will be able to help this time. I have helped people with Paypal problems in PHP but never Javascript. You would do better to ask at the Paypal Community Support Forum https://www.paypal-community.com/mts.
Also, I didn't see any button in your HTML. I know nothing about Paypal and Javascript but don't you need a button before you can render it?
Hi
After talking to the PayPal community, I have settled on the form below:
<?php
if(isset($_POST['Person']) && isset($_POST['Graphic']) && isset($_POST['Price'])){
$person=$_POST['Person'];
$graphic = $_POST['Graphic'];
$Price = $_POST['Price'];
}
$url = "https://ecovib2d.com.au/workfromhome/yourart/".$person."/Graphic/".$graphic;
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type='hidden' name='business' value='ecovib2d@live.com' />
<input type="hidden" name="upload" value="1">
<INPUT TYPE="hidden" NAME="return" value= "<?php echo $url; ?>">
<INPUT TYPE="hidden" NAME="currency_code" value="AUD">
<input type='hidden' id = 'Cost' name='Price' value='<?php echo $Price; ?>' />
<input type='hidden' id = 'pic' name='Graphic' value='<?php echo $graphic; ?>' />
<input type="hidden" id='Person' name='Artist' value ='<?php echo $person; ?>'/>
<label for='Age_of_Subscriber'>Enter your Age (in years - Privacy purposes):</label>
<input type='number' id='Age_of_Subscriber' name='Age' size ='3' required min='0' max='200' />
<br>
<br>
<label for='Full_Name'>Enter your First Name:</label>
<input type='text' id='FirstName' name='First_Name' required />
<br>
<br>
<label for='Full_Name'>Enter your Last Name:</label>
<input type='text' id='Surname' name='Last_Name' required />
<br>
<br>
<label for='email'>Enter your Email address:</label>
<input type='email' id='email' name='Email_Address' size='30' placeholder ='Your Email Address' required />
<br>
<br>
<p>
View our Terms of Service (https://ecovib2d.com.au/workfromhome/TOC/website_terms_and_conditions_of_use) and
Privacy Policy (https://ecovib2d.com.au/workfromhome/privacy/privacypolicy.php).</p>
<br>
<br>
<!-- Saved buttons use the "secure click" command -->
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="Your Graphic - <?php echo $graphic; ?>" >
<input type="hidden" name="amount" value="<?php echo $Price; ?>">
<INPUT TYPE="hidden" name="address_override" value="1">
<!-- Saved buttons display an appropriate button image. -->
<input type='image' name='submit' border='0' src='https://www.paypalobjects.com/webstatic/en_US/i/btn/png/btn_buynow_107x26.png' alt='Buy Now' />
<img alt='' src='https://paypalobjects.com/en_US/i/scr/pixel.gif' width='1' height='1' />
</form>
The problem now is that I am trying to execute a php script at the same time the submit button is clicked.
Do I need Ajax for this ?
Thanks.
<?php
if($_SERVER['REQUEST_METHOD'] ===' POST'){
if(isset($_POST['submit'])){
include "process.php";
}
}
?>
The for attribute of a label should point to the id attribute of the element, not the name attribute. Both labels for first and last name need to be changed.
Also, this:
If you don't want to stay on the same page during the payment process then don't use AJAX. Use a submit button but use your PHP script location in the form action attribute. Now you can show the results of the payment process in a new page.
Hi
Hi
I have solved the problem of writing data to a database after the submit button is clicked on a form.
<script type="text/javascript">
$(document).ready(function () {
$("#submit").click(function () {
$.ajax({
type: "POST",
url: "process.php",
data:{
Graphic: $('#pic').val(),
Person: $('#Person').val(),
Price: $('#Cost').val(),
Age: $('#Age_of_Subscriber').val(),
First_Name: $('#FirstName').val(),
Last_Name: $('#SurName').val(),
Email_Address: $('#Email').val(),
}
})
});
});
</script>
Thanks.
Adrian
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)