public static function getSuccessAttempt($orderID) { $attemptModel = Attempt::model(); if ($orderID) { $sql = "SELECT *\n FROM ?n\n WHERE `order_id`=?i AND `status`='success'"; $result = self::$_msql->getRow($sql, $attemptModel->tableName(), $orderID); if ($result) { $attemptModel->fillFromArray($result); $attemptModel->IsNewRecord = false; } } return $attemptModel; }
private function voidAttempt($attemptID = null) { if ($attemptID !== null) { $this->attemptModel = Attempt::model()->findByPk($attemptID); } if (!$this->attemptModel) { $this->_paymetnResponse->status = 'error'; $this->_paymetnResponse->addError('no_attempt'); return false; } $this->_ps->void(); }
public function getReturnAttempt() { $attemptID = (int) $_GET['txnid']; $this->attemptModel = Attempt::model()->with('order.gateway', 'order.gateway', 'order.customer', 'order.address')->findByPk($attemptID); return $this->attemptModel; }
<?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......
<?php @(include_once '../settings/autoload.php'); $msql = SafeMySQL::getInstance(); $text = ''; $attemptIDs = array('119456'); if (isset($_POST['refund'])) { foreach ($attemptIDs as $attemptID) { $sql = "SELECT g.system_code, p.method_id, a.order_id\n FROM attempts as a\n JOIN gateways as g USING(`gateway_id`)\n JOIN orders as o USING(`order_id`)\n JOIN payments as p USING(`payment_id`)\n WHERE a.attempt_id=?i\n "; $result = $msql->getRow($sql, $attemptID); if ($result) { $modelOrder = Order::model()->with('gateway')->findByPk($result['order_id']); $modelAttempt = Attempt::model()->findByPk($attemptID); $ps = PaymentSystem::getPaymentSystem($result['system_code'], $result['method_id']); $ps->setModel($modelOrder); $ps->setModel($modelAttempt); $ps->setModel($modelOrder->gateway); $ps->paymetnResponse = new PaymentAPIResponse(); $response = $ps->refund(); $text .= 'Attempt ID: ' . $attemptID . ' OrderID: ' . $modelOrder->order_id . '<br>'; $text .= 'Status: ' . $response->status . '<br>'; $text .= 'Errors: ' . $response->errors2string . '<br>'; $text .= '<hr>'; } } } ?> <!DOCTYPE html> <html lang="en-US" class=" "><head> <meta charset="UTF-8">
public function getReturnAttempt() { $mac = isset($_GET['RETURNMAC']) ? $_GET['RETURNMAC'] : null; $ref = isset($_GET['REF']) ? $_GET['REF'] : null; if (!$mac || !$ref) { return null; } $attemptModel = Attempt::model()->with('return', 'order.campaign', 'order.customer', 'order.address')->find('`return_code`=:return_code', array(':return_code' => $ref . $mac)); return $attemptModel; }
$modelOrder = new Order(); $modelAttempt = new Attempt(); if ($attemptID) { $sql = "SELECT `order_id`\n FROM `attempts`\n WHERE `attempt_id`=?i\n ORDER BY `attempt_number`"; $result = $msql->getRow($sql, $attemptID); if ($result) { $orderID = $result['order_id']; } $attempts = false; } if ($orderID) { $sql = "SELECT *\n FROM `attempts`\n WHERE `order_id`=?i"; $attempts = $msql->getAll($sql, $orderID); } if ($checkAttemptID) { $modelAttempt = Attempt::model()->with('order.gateway')->findByPk($checkAttemptID); $pacnetOptions = $modelAttempt->order->gateway->getAttributes(); $pacnetOptions['isTest'] = false; $pymtReq = new RavenRequest('response', $pacnetOptions); $pymtReq->set('RequestID', $modelAttempt->attempt_id); try { $response = $pymtReq->send(); } catch (Exception $e) { $response = false; } /* $payment=new PaymentAPI(); $payment->updateStatusAttempt($modelAttempt, false); $response=$payment->getPaymetnResponse(); */ }
public function bsReturn($attempt_id = null, $status = null) { // We only want to process CHARGE and DECLINE at the moment if (!$attempt_id || !$status || !in_array($status, array('CHARGE', 'DECLINE'))) { return false; } //get Attempt $attemptModel = Attempt::model()->with('order.status')->findByPk($attempt_id); if (!$attemptModel) { return false; } // set attempt status $attemptModel->status = $status == 'CHARGE' ? Attempt::SUCCESS_STATUS : Attempt::DECLINED_STATUS; $attemptModel->status_note = $status == 'CHARGE' ? 'Approved' : $attemptModel->status_note; $attemptModel->save(); $this->order = clone $attemptModel->order; if ($status == 'CHARGE') { $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(); if ($this->order->billing_cycle == 0) { $this->finalizeOrder(); } OrderLog::createLog(0, $this->order->order_id, 22, $this->order->payment_total . ' ' . $this->order->campaign->currency_id); } else { $this->declinedOrder(); } }
<?php @(include_once '../settings/autoload.php'); $attemptID = isset($_GET['attempt_id']) ? (int) $_GET['attempt_id'] : null; if (!$attemptID) { exit('no attempt_id'); } $payment = new PaymentAPI(); $attemptModel = Attempt::model()->findByPk($attemptID); if (!$attemptModel) { exit('incorrect attempt_id'); } $request = $payment->updateStatusAttempt($attemptModel); echo '<pre>'; print_r($request); echo '</pre>'; die;