示例#1
0
<?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......
示例#2
0
 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);
     }
 }
示例#3
0
 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;
 }