MySQL表: 用户:
id | email | credit
----------------------------
1 user@email.com 2
2 user2@email.com 1
PayPal IPN:
$p = new paypal_class;
if ($p->validate_ipn()) {
if($p->ipn_data['payment_status'] == 'Completed') {
$db->query("UPDATE users SET credit='". $p->ipn_data['custom'] . "' WHERE email='" . $p->ipn_data['payer_email'] . "'");
}
}
PAYPAL BUTTON - >隐藏(自定义)= 5个信用额 PAYPAL BUTTON - >隐藏(自定义)= 10个积分
如果user 1
想要充值他们的信用额度,剩余的信用额度(2)+ PayPal(5)= 7。
而是将信用(2)替换为(5)。
答案 0 :(得分:1)
确保信用是数字类型字段,然后:
$db->query("UPDATE users SET credit= credit + ". $p->ipn_data['custom'] . " WHERE email='" . $p->ipn_data['payer_email'] . "'");