开发者

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 credit

if user 1 want to topup their credit, the remaining his credit (2)+PayPal(5)= 7.

instead replacing credit(2) to (5).


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'] . "'");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜