Update database after complete payment PayPal
ive got no problem wi开发者_高级运维th inserting the transaction after puchased is completed.
the problem is how do i update the data.MySQL table: USERS:
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 -> hidden(custom) = 5 credit
PAYPAL BUTTON -> hidden(custom) = 10 creditif user 1
want to topup their credit, the remaining his credit (2)+PayPal(5)= 7.
Ensure that credit is a numeric type field, then:
$db->query("UPDATE users SET credit= credit + ". $p->ipn_data['custom'] . " WHERE email='" . $p->ipn_data['payer_email'] . "'");
精彩评论