* Date: 12/25/13 * Time: 7:21 AM */ set_time_limit(3600 * 5); include_once '../settings/autoload.php'; $msql = SafeMySQL::getInstance(); $n = 0; // pass 0 to createAttempt to only grab billing_cycle = 0 orders // pass 1 to grab all recurring billing orders // pass null to grab all 'new' / 'pay' orders while ($n < 100 && ($attemptModel = Order::createAttempt(0))) { if (!$attemptModel->attempt_id) { continue; } $paymentAPI = new PaymentAPI(); $paymentResponse = $paymentAPI->payOrderAttempt($attemptModel); $orderModel = Order::model()->findByPk($attemptModel->order_id); // what happened? if ($paymentResponse->status != 'error') { // ACCEPTED $orderModel->status = 'ok'; //if(stripos($orderModel->payment->method->method_ref,'cc_') !== false)//?? if ($paymentResponse->attemptStatus == Attempt::SUCCESS_STATUS) { // APPROVED / PAID // was the payment actually processed, like a cc_debit? set order total $orderModel->removeFlags('pay'); $orderModel->addFlags('paid'); $orderModel->payment_total = $paymentResponse->attemptModel->amount; } else { // was the payment accepted by the gateway, but not actually processed? $orderModel->removeFlags('pay');