public function __construct() { self::$paymentLog = R::dispense('payment_log'); if (!isset($_GET['amount']) || !isset($_GET['title']) || !isset($_GET['auth']) || !isset($_GET['country']) || !isset($_GET['currency']) || !isset($_GET['function'])) { self::error(99); } $this->amount = $_GET['amount']; $this->title = $_GET['title']; $this->auth = $_GET['auth']; $this->country = $_GET['country']; $this->currency = $_GET['currency']; $this->function = $_GET['function']; $call = 'action_' . ucfirst($this->function); self::$paymentLog->amount = $this->amount; self::$paymentLog->title = $this->title; self::$paymentLog->auth = $this->auth; self::$paymentLog->country = $this->country; self::$paymentLog->currency = $this->currency; self::$paymentLog->function = $this->function; // check if valid ip $this->checkIP(); // loadup prices $this->prices = Config::getConfig('premium_price'); // valid callback function? if (!method_exists($this, $call)) { self::error(1); } // valid item? $parts = explode("_", $this->title); if (count($parts) != 3) { self::error(2); } if ($parts[0] != "pa" || !is_numeric($parts[1]) || !is_numeric($parts[2])) { self::error(3); } $this->premiumPoints = $parts[1]; $this->userID = $parts[2]; if (!isset($this->prices[$this->premiumPoints])) { self::error(4); } $this->{$call}(); }
public static function finalizeOrder($orderID) { $modelOrder = Order::model()->findByPk((int) $orderID); if (!$modelOrder) { return false; } //Check status $modelAttempt = new Attempt(); $modelAttempt->getLastOrderAttempt($modelOrder->order_id, Attempt::DEBIT_TYPE); if (in_array($modelAttempt->status, array(Attempt::SUCCESS_STATUS, Attempt::DECLINED_STATUS))) { return true; } $payment = new PaymentAPI(); $response = $payment->updateStatusAttempt($modelAttempt); if ($response->attemptStatus == 'success') { $modelOrder->status = Order::STATUS_OK; $modelOrder->removeFlags(Order::FlAG_PAY); $modelOrder->addFlags(Order::FlAG_PAID); $modelOrder->payment_total = $modelAttempt->amount; $modelOrder->save(); Event::setEvents($modelOrder->order_id, 8, false); //update recurring_next $sql = "UPDATE `orders_products`\n JOIN `products` USING(`product_id`)\n SET `orders_products`.`recurring_next` = DATE_ADD(NOW(), INTERVAL `products`.`subscription_days` DAY)\n WHERE FIND_IN_SET('recurring', `orders_products`.`flags`)>0\n AND `orders_products`.`order_id`=?i"; self::$_msql->query($sql, $modelOrder->order_id); if ($modelOrder->billing_cycle == 0) { // Delete order prospect Prospects::deleteProspectOkOrder($modelOrder->order_id); Orders::createAttachedOrders($modelOrder); // Fire Pixel $cloneOrder = clone $modelOrder; Pixel::firePixelPb($cloneOrder); unset($cloneOrder); } } elseif ($response->attemptStatus == 'declined') { $modelOrder->status = Order::STATUS_ERROR; $modelOrder->removeFlags(Order::FlAG_PAY); $modelOrder->save(); // Delete order prospect Prospects::deleteProspectOkOrder($modelOrder->order_id); } }
<?php include_once '../settings/autoload.php'; $msql = SafeMySQL::getInstance(); while ($model = Wr1Order::getOneNewModel()) { $payment = new PaymentAPI(); $payment->getOrderStatus($model->order, true); $model->delete(); }
<?php @(include_once '../settings/autoload.php'); /* @include_once '../../ws/class/lib.class.php'; @include_once '../../ws/class/ipayment.class.php'; @include_once '../../ws/class/payment.class.php'; @include_once '../../ws/class/raven_config_demo.php'; @include_once '../../ws/class/ravenrequest.class.php'; @include_once '../../ws/class/payment_'.$orderModel->payment_type.'.class.php'; */ $orders = array('1081612'); $ordersRefund = array(); $countRefunded = '6.99'; foreach ($orders as $orderID) { $orderModel = Order::model()->findByPk($orderID); $paymentAPI = new PaymentAPI(); $response = $paymentAPI->refundOrder($orderModel, $countRefunded); if ($response->status = PaymentAPIResponse::SUCCESS_STATUS && ($response->attemptStatus = Attempt::SUCCESS_STATUS)) { $orderModel->payment_total -= $countRefunded; $orderModel->amount_refunded = $countRefunded; $orderModel->save(); $ordersRefund[] = $orderModel->order_id; } } echo '<pre>'; print_r($ordersRefund); echo '</pre>'; die;
* User: Anton Antonov * 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?
<?php @(include_once 'settings/autoload.php'); /* $r='FBiv4rtILU3NbVeyWhOb5oiHEYXW1jWSpyYjspWAI3XMqcl5oszQ5wIR9qBgVHOPgqojNugZcay/lRtjn0sdTIcJJZKutwYKXGDxOh4mBwm0rsIvzgi/bycHrP1kQ3cVrWjgtBDbZ58zdP2EqRjWbrsFu0VrarGL+YKv'; $t=NoteBase64::decode($r); echo $t; die; */ $payment = new PaymentAPI(); // Create new order //$modelOrder=Order::model()->findByPk(2155137); //$modelOrder=WebService::createTestOrder(); //$request=$payment->payOrder($modelOrder->order_id, $modelOrder->payment_total); // Refund order //$modelOrder=Order::model()->findByPk('2155336'); //$request=$payment->refundOrder($modelOrder, '1.00'); //void //$modelOrder=Order::model()->findByPk('2155336'); //$request=$payment->voidOrder($modelOrder); //attempt $attemptModel = Attempt::model()->findByPk('119822'); $request = $payment->updateStatusAttempt($attemptModel); echo '<pre>'; print_r($request); echo '</pre>'; die; //echo '<a target="_blank" href="'.$request->redirectUrl.'">link</a>'; //http://test.dragonpay.ph/Pay.aspx?txnid=79123&amount=11000&ccy=USD&description=Dragonpay&email=3561_email%40gmail.com&digest=6a8083fe136fe93fad96c6c0c6746ac0621e3070 //https://gw.dragonpay.ph/Pay.aspx?merchantid=ABC&txnid=12345678&amount=1000.00& ccy=PHP&description=Box+of+Chocolates&digest=a4b3d08462......
public function payReturn() { $paymentAPI = new PaymentAPI(); //get Attempt $attemptModel = $paymentAPI->getReturnAttempt(); if (!$attemptModel) { return false; } $this->order = clone $attemptModel->order; // get attempt results from GC $paymentAPI->updateStatusAttempt($attemptModel); //fb($paymentAPI); //fb($attemptModel); $paymentResponse = $paymentAPI->getPaymentResponse(); if ($paymentResponse->getstatus() != 'error') { // Successful attempt, but did the payment fully go through? if ($attemptModel->status == 'success') { $this->order->status = 'ok'; $this->order->removeFlags('salvage'); $this->order->addFlags('paid'); $this->order->payment_total = $this->order->amount_product + $this->order->amount_shipping; $this->order->save(); $this->finalizeOrder(); } // else == 'submitted' $url = $this->order->campaign->return_url . '?' . $this->order->getUrlParams(); } else { $msg = $this->declinedOrder($paymentResponse); $url = $this->order->campaign->url . '?error=' . $msg; } header('Location: ' . "https://" . $url); exit; }
function ajaxAction() { if (!isset($_POST['ajax'])) { throw new AFHttpException(404, 'page_not_found'); } if ($this->access->actionAccess('update')) { /* DEPRECATED BECAUSE ITS UPDATED ON SPECIFIC PAGES if(isset($_POST['update_customer_information'])) { if(isset($_POST['CustomerModel'])) { $customerModel=new Customer(); $customerModel->fillFromArray($_POST['CustomerModel'], false); $customerModel->model_uset_id = $this->user->user_id; $customerModel->save(false); } if(isset($_POST['ShippingAddress'])) { $sAddressModel=new Address(); $sAddressModel->fillFromArray($_POST['ShippingAddress'], false); $sAddressModel->model_uset_id = $this->user->user_id; $sAddressModel->save(false); } if(isset($_POST['BillingAddress']) && $_POST['ShippingAddress']['address_id']!=$_POST['BillingAddress']['address_id']) { $bAddressModel=new Address(); $bAddressModel->fillFromArray($_POST['BillingAddress'], false); $bAddressModel->model_uset_id = $this->user->user_id; $bAddressModel->save(false); } OrderLog::createLog($this->user->user_id, $_POST['order_id'], 2); Message::echoJsonSuccess(__('customer_information_updated')); } */ if (isset($_POST['order_set_chargeback_amount'])) { $orderID = (int) AF::get($_POST, 'order_id', 0); $amount = AF::get($_POST, 'amount', 0); $type = (int) AF::get($_POST, 'type', 0); $modelOrder = Order::model()->findByPk($orderID); $new_amount = $modelOrder->chargeBackSet($amount, $type, $this->user->user_id); if ($new_amount) { Message::echoJsonSuccess(array('answer' => __('order_chargeback_amount_updated'), 'new_amount' => $new_amount)); } else { $msg = $amount > $modelOrder->maxAmountChargeback ? __('order_chargeback_amount_exceeded') : __('order_chargeback_amount_no_updated'); Message::echoJsonError($msg); } die; /*// we need to make sure the chargeback flag is set. if not, set flag and log it if(!$modelOrder->isFlag('chargeback')) { $modelOrder->addFlags('chargeback'); $modelOrder->save(false); $orderProducts=OrderProducts::getProductsByOrderID($orderID); foreach($orderProducts as $orderProduct) { $orderProduct->removeFlags('recurring'); $orderProduct->save(); } OrderLog::createLog($this->user->user_id, $orderID, 11, 'chargeback'); } if( $modelOrder && in_array($type, array(29, 30)) && $amount <= $modelOrder->maxAmountChargeback && $orderID) { $notes = ($amount) ? $amount : null; OrderLog::createLog($this->user->user_id, $orderID, $type, $notes, $amount); Message::echoJsonSuccess(array('answer'=>__('order_chargeback_amount_updated'), 'new_amount'=>$modelOrder->maxAmountChargeback)); } else { $msg = ($amount > $modelOrder->maxAmountChargeback) ? __('order_chargeback_amount_exceeded') :__('order_chargeback_amount_no_updated') ; Message::echoJsonError($msg); } die;*/ } if (isset($_POST['rma_code'])) { $orderModel = new Order(); $orderModel->order_id = (int) AF::get($_POST, 'order_id', 0); $orderModel->rma_code = (int) AF::get($_POST, 'rma_code', 0); $orderModel->setRMA($this->user->user_id); Message::echoJsonSuccess($orderModel->rma_number); die; } if (isset($_POST['order_refund']) && $this->access->actionAccess('order_refund')) { $orderID = AF::get($_POST, 'order_id'); $amountRefunded = AF::get($_POST, 'amount_refunded', 0); $model = Order::model()->findByPk($orderID); $model->refunded($amountRefunded); if (!$model->errors) { $paymentAPI = new PaymentAPI(); $response = $paymentAPI->refundOrder($model, $amountRefunded); if ($response->status == 'success') { if ($amountRefunded == $model->max_refund) { $op = OrderProduct::model(); //new OrderProducts('OrderProduct'); $op->cancelRecurring($model->order_id); unset($op); $model->status = 'void'; } $model->amount_refunded = number_format($amountRefunded + $model->amount_refunded, 2); $model->payment_total = number_format($model->payment_total - $amountRefunded, 2); if (!$model->save()) { fb($model->getErrors()); } OrderLog::createLog($this->user->user_id, $model->order_id, 13, $amountRefunded); Event::setEvents($model->order_id, 7); Message::echoJsonSuccess(__('order_is_refunded')); } else { Message::echoJsonError(__('order_not_refunded') . ' ' . $response->alerts2string . ' ' . $response->errors2string); } } else { Message::echoJson('error', array('errors' => $model->errors, 'message' => $model->errors2string)); } } if (isset($_POST['order_void']) && $this->access->actionAccess('order_refund')) { $orderLogsModel = new OrderLog(); $orderLogsModel->user_id = $this->user->user_id; $orderLogsModel->action = 3; if (!$orderLogsModel->canVoid()) { Message::echoJsonSuccess(__('you_cant_do_void')); } $orderID = AF::get($_POST, 'order_id'); $model = Order::model()->findByPk($orderID); if ($model->status == 'void') { Message::echoJsonSuccess(__('order_is_voided')); } $paymentAPI = new PaymentAPI(); $response = $paymentAPI->voidOrder($model); if ($response->status == 'success') { // unset recurring products $orderProducts = new OrderProducts('OrderProduct'); $orderProducts->cancelRecurring($model->order_id); unset($orderProducts); $model->status = 'void'; $model->amount_refunded = $model->payment_total; $model->payment_total = '0'; $model->save(); OrderLog::createLog($this->user->user_id, $model->order_id, 3, __('success') . ' ' . $model->amount_refunded); Event::setEvents($this->order->order_id, 6); Message::echoJsonSuccess(__('order_is_voided')); } else { OrderLog::createLog($this->user->user_id, $model->order_id, 3, __('failed') . ' ' . $model->max_refund); Message::echoJsonError(__('order_not_void') . ' ' . $response->alerts2string . ' ' . $response->errors2string); } } if (isset($_POST['rebill_now']) && $this->access->actionAccess('order_rebill_now')) { $orderID = AF::get($_POST, 'order_id'); $productID = AF::get($_POST, 'product_id'); if (!$orderID || !$productID) { Message::echoJsonSuccess(__('invalid_request')); } $newOrderID = Order::rebillNow($orderID, $productID); if ($newOrderID) { $orderModel = Order::model()->findByPk($newOrderID); $paymentAPI = new PaymentAPI(); $response = $paymentAPI->payOrder($orderModel, $orderModel->amount); if ($response->status == 'success') { $orderModel->status = 'ok'; $orderModel->removeFlags('pay'); $orderModel->addFlags('paid'); $orderModel->payment_total = $response->attemptModel->amount; $orderModel->save(); //update recurring_next $msql = SafeMySQL::getInstance(); $sql = "UPDATE `orders_products`\n JOIN `products` USING(`product_id`)\n SET `orders_products`.`recurring_next` = DATE_ADD(NOW(), INTERVAL `products`.`subscription_days` DAY)\n WHERE FIND_IN_SET('recurring', `orders_products`.`flags`)>0\n AND `orders_products`.`order_id`=?i"; $msql->query($sql, $orderModel->order_id); // log action on parent order for visibility OrderLog::createLog($this->user->user_id, $orderID, 27, __('success') . ' ' . $orderModel->payment_total . ' - Child Order ' . $orderID); OrderLog::createLog($this->user->user_id, $orderModel->order_id, 27, __('success') . ' ' . $orderModel->payment_total); Event::setEvents($orderModel->order_id, 6); Message::echoJsonSuccess(__('order_is_rebill')); } else { $orderModel->status = 'error'; //delete the pay flag $orderModel->removeFlags('pay'); if ($orderModel->billing_cycle > 0) { $orderModel->addFlags('retry'); } $orderModel->save(); // log failed attempt on parent order OrderLog::createLog($this->user->user_id, $orderID, 27, __('failed') . ' ' . $orderModel->amount . ' - Child Order ' . $orderID); OrderLog::createLog($this->user->user_id, $orderModel->order_id, 27, __('failed') . ' ' . $orderModel->amount); Message::echoJsonError(__('order_not_rebill') . ' ' . $response->alerts2string . ' ' . $response->errors2string); } } else { Message::echoJsonSuccess(__('order_rebill_now_error')); } //$orderLogsModel=new OrderLog(); //$orderLogsModel->user_id=$this->user->user_id; //$orderLogsModel->action=27; /* $orderLogsModel=new OrderLog(); $orderLogsModel->user_id=$this->user->user_id; $orderLogsModel->action=3; if(!$orderLogsModel->canVoid()) Message::echoJsonSuccess(__('you_cant_do_void')); $orderID = AF::get($_POST, 'order_id'); $model=Order::model()->findByPk($orderID); if($model->status=='void') Message::echoJsonSuccess(__('order_is_voided')); $paymentAPI=new PaymentAPI(); $response=$paymentAPI->voidOrder($model); if($response->status=='success') { // unset recurring products $orderProducts = new OrderProducts('OrderProduct'); $orderProducts->cancelRecurring($model->order_id); unset($orderProducts); $model->status = 'void'; $model->amount_refunded = $response->attemptModel->amount; $model->save(); OrderLog::createLog($this->user->user_id, $model->order_id, 3, __('success').' '.$model->amount_refunded); Event::setEvents($this->order->order_id, 6); Message::echoJsonSuccess(__('order_is_voided')); } else { OrderLog::createLog($this->user->user_id, $model->order_id, 3, __('failed').' '.$model->max_refund); Message::echoJsonError(__('order_not_void').' '.$response->alerts2string.' '.$response->errors2string); } */ } } die; }