2
我有两种方式可供用户检查:paypal和Php?
1.if user input (Amount field < 5(user credit):
do update database the remain amount in my database table.
2.if user input(Amount field) > 5(user credit):
Do paypal transaction with the submit form.
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="payPalForm">
<input type="hidden" name="item_number" value="01 - General Payment to FreelanceSwitch.com">
<input name="item_name" type="hidden" id="item_name" size="45" value="Posting job">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="http://freelanceswitch.com/payment-complete/">
Paying Page:<input name="amount" type="text" id="amount" size="5">
<input type="submit" name="Submit" value="Pay">
</form>
任何人都可以告诉我怎么做与贝宝提交表单的条件?
谢谢。
感谢@Donny天安,现在我已经试过:
编辑::
function compare_user_credit($paying_price, $user_credit){
$db = &JFactory::getDBO();
$user =& JFactory::getUser();
$user_id = $user->get('id');
if ($paying_price <= $user_credit) {
$remain_credit = $user_credit - $paying_price;
//DO UPDATE:enough credit
update_user_credit_after_paying($remain_credit,$user_id);
$action_after_paying = header("Location: index.php?xxxx=5");
}
# Case2 direct to paypal with the submit form.
else if ($paying_price > $user_credit){
//Need submit form to paypal.
$action_after_paying = header("Location: index.php=xxxx&paypal=".$_POST["amount"]);
}
return $action_after_paying;
}
$output = '<form method="POST" > ';
$output .='<h1>Credit:'.get_credit().'</h1>';
$output .= ' Paying Page <input type="text" name="amount" size=3 max_length=5 />';
$output .='<input type="submit" name="pay" value="pay" />' ;
echo $output;
if(isset($_POST["pay"])){
compare_user_credit($_POST["amount"], $user_credit);
}
我怎么能这样做与PayPal案例02
谢谢!可以给我个建议如何在情况下做02(查看我更新的帖子) – kn3l 2010-02-12 02:53:45
好的。它的工作原理,感谢你的班级。 – kn3l 2010-02-12 04:24:27
很高兴听到它的作品,顺便说一句,这不是我的课,信用应该交给Micah;)这个类实际上只是包装了您可以在Paypal开发人员的文档中找到的关于PHP语言IPN的代码示例。 Micah做得很好,把所有这些代码放入一个可以轻松使用的类中。 – 2010-02-12 14:36:16