예제 #1
0
if (!$fp) {
    sleep(3);
}
$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
if (!$fp) {
    sleep(3);
}
$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
if (!$fp) {
    log_log("paypal_billing", "Could not connect to paypal");
    // HTTP ERROR
} else {
    fputs($fp, $header . $req);
    while (!feof($fp)) {
        $res = fgets($fp, 1024);
        if (strcmp($res, "VERIFIED") == 0) {
            paymentDetail::process_paypal($_POST);
            // check the payment_status is Completed
            // check that txn_id has not been previously processed
            // check that receiver_email is your Primary PayPal email
            // check that payment_amount/payment_currency are correct
            // process payment
        } else {
            if (strcmp($res, "INVALID") == 0) {
                // log for manual investigation
                log_log("paypal_billing", "Fake confirmation " . var_export($_POST, true));
            }
        }
    }
    fclose($fp);
}
예제 #2
0
 static function process_paypal($list)
 {
     initProgram('admin');
     $sq = new Sqlite(null, 'paymentdetail');
     $r = paymentdetail__paypal::createPaymentDetail($list);
     if (self::checkIftransactionExists($r['transactionid'])) {
         log_log("paypal_billing", "Transactionid {$r['transactionid']} already exists\n");
         return;
     }
     $i = 0;
     while (true) {
         $r['nname'] = implode("___", array($r['client'], $r['month'], $i));
         if (!$sq->getRowsWhere("nname = '{$r['nname']}'")) {
             break;
         }
         $i++;
     }
     $r['parent_clname'] = createParentName('client', $r['client']);
     $cl = new Client(null, null, $r['client']);
     $cl->get();
     if (!$cl->isOn('status')) {
         $cl->updateEnable(null);
         $cl->was();
     }
     $payp = new paymentDetail(null, null, $r['nname']);
     $r['complete_detail'] = $list;
     $r['paymentgw'] = 'paypal';
     $payp->create($r);
     $payp->write();
     log_log("paypal_billing", "saved the payment detail {$p->nname}");
 }