【发布时间】:2014-01-25 01:08:37
【问题描述】:
我有一个网站,我有一个 Paypal 商业帐户(在英国注册)。贝宝已与我的网站集成,并且运行良好。当用户点击“Proceed To Pay”时,用户将被带到 Paypal 的网站(截图如下)。现在我对这个程序的唯一问题是客户必须先创建一个 Paypal 帐户才能向我付款。我对 Paypal 提供的所有选项(标准、专业、商家等)感到困惑,我不确定我到底做错了什么。
Screenshot http://ascensionnexus.com/Capture.jpg
如果我需要更改代码中的某些内容以让客户直接使用他们的信用卡(在 Paypal 的网站上)付款,而不是要求他们先开设 Paypal 帐户,请建议并解释。
编辑
我的确认订单页面上的 HTML 表单如下。
<form class="paypal" action="payments.php" method="post" id="paypal_form" target="_parent">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="lc" value="US" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest" />
<input type="hidden" name="amount" value="<?php echo $productunit_price * 1.05;?>" />
<input type="hidden" name="quantity" value="<?php echo $product_quantity;?>" />
<input type="hidden" name="first_name" value="<?php echo $customer_first_name;?>" />
<input type="hidden" name="last_name" value="<?php echo $customer_last_name;?>" />
<input type="hidden" name="notify_url" value="http://mywebsite.com/payments.php" />
<input type="hidden" name="payer_email" value="<?php echo $customer_email;?>" />
<input type="hidden" name="item_name" value="<?php echo $service_name;?> (<?php echo $product_name;?>)" / >
<input type="hidden" name="custom" value="<?php echo $orderalias.",".$_SESSION["user_id"];?>" / >
<input type="image" value="Submit Payment" src="imgs/proceed_btn.jpg"/>
</form>
payments.php中的php代码如下:
<?php
// PayPal settings
$paypal_email = 'mypaypalid@gmail.com';
$return_url = 'http://mywebsite.com/thankyou.php?payment=1';
$cancel_url = 'http://mywebsite.com/orders.php';
$notify_url = 'http://mywebsite.com/payments.php';
if (!isset($_POST["txn_id"]) && !isset($_POST["txn_type"])){
// Firstly Append paypal account to querystring
$querystring .= "?business=".urlencode($paypal_email)."&";
//loop for posted values and append to querystring
foreach($_POST as $key => $value){
$value = urlencode(stripslashes($value));
$querystring .= "$key=$value&";
}
// Append paypal return addresses
$querystring .= "return=".urlencode(stripslashes($return_url))."&";
$querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
$querystring .= "notify_url=".urlencode($notify_url);
// Redirect to paypal IPN
header('location:https://www.paypal.com/cgi-bin/webscr'.$querystring);
exit();
}else{
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
$req .= "&$key=$value";
}
// assign posted variables to local variables
$data['item_name'] = $_POST['item_name'];
$data['item_number'] = $_POST['item_number'];
$data['payment_status'] = $_POST['payment_status'];
$data['payment_amount'] = $_POST['mc_gross'] * 0.95;
$data['payment_currency'] = $_POST['mc_currency'];
$data['txn_id'] = $_POST['txn_id'];
$data['receiver_email'] = $_POST['receiver_email'];
$data['payer_email'] = $_POST['payer_email'];
$data['custom'] = $_POST['custom'];
$separatedata = explode(",",$data["custom"]);
$orderalias = $separatedata[0];
$user = $separatedata[1];
if($data['payment_status']=="Completed" ){
// do my stuff here
}else{
// do my stuff here
}
}
?>
【问题讨论】:
标签: php paypal credit-card