コード例 #1
0
 public function hookActionProductCancel($params)
 {
     include_once _PS_MODULE_DIR_ . '/bluepay/bluepay_orders.php';
     if ($params['order']->module != $this->name || !($order = $params['order']) || !Validate::isLoadedObject($order)) {
         return false;
     } elseif (!$order->hasBeenPaid()) {
         return false;
     }
     $order_detail = new OrderDetail((int) $params['id_order_detail']);
     if (!$order_detail || !Validate::isLoadedObject($order_detail)) {
         return false;
     }
     $bluepay_order = BluePayOrder::getOrderById((int) Tools::getValue('id_order'));
     if (!$bluepay_order) {
         return false;
     }
     $products = $order->getProducts();
     $cancel_quantity = Tools::getValue('cancelQuantity');
     $amount = (double) $products[(int) $order_detail->id]['product_price_wt'] * (int) $cancel_quantity[(int) $order_detail->id];
     $refund = $this->processRefund($bluepay_order['transaction_id'], (int) $order->id, $amount);
     parse_str($refund, $post_response);
     $message = $post_response['MESSAGE'];
     $this->addNewPrivateMessage(Tools::getValue('id_order'), $message);
 }
コード例 #2
0
     if ($message != 'DUPLICATE') {
         $transaction = array('customer_id' => $customer->id, 'transaction_id' => $transaction_id, 'payment_status' => 'Approved', 'payment_type' => $params['PAYMENT_TYPE'], 'payment_date' => date('Y-m-d H:i:s'), 'invoice_id' => Tools::getValue('invoice_id'), 'total_paid' => number_format((double) $cart->getOrderTotal(true, 3), 2, '.', ''), 'transaction_type' => $params['TRANS_TYPE'] == 'SALE' ? Configuration::get('PS_OS_PAYMENT') : Configuration::get('BP_OS_AUTHORIZATION'), 'name' => $params['NAME1'] . ' ' . $params['NAME2'], 'email' => $params['EMAIL'], 'payment_account' => $payment_account_mask, 'card_type' => $card_type, 'expiration_date' => $params['CARD_EXPIRE']);
         /**
          * Check if amount processed through BluePay matches the cart total.
          * If amounts do not match, send the customer back
          * to the payment page.
          */
         if ($bluepay->validate($transaction['transaction_id'], $transaction['invoice_id']) != $transaction['total_paid']) {
             $message = 'Amounts do not match. The order was not created successfully; please try again.';
             $url = 'index.php?controller=order&step=3&error=' . $message;
             Tools::redirect($url);
             exit;
         }
         $bluepay->validateOrder((int) $cart->id, $transaction['transaction_type'], $transaction['total_paid'], $bluepay->displayName, $message, $transaction, null, false, $customer->secure_key);
         $order_id = Order::getOrderByCartId((int) $cart->id);
         BluePayOrder::saveOrder((int) $order_id, $transaction);
         if (Tools::getValue('save_payment_information') == 'Yes') {
             BluePayCustomer::saveCustomer($transaction);
         }
         break;
     } else {
         $url = 'index.php?controller=order&step=3&error=Duplicate Transaction';
         Tools::redirect($url);
         break;
     }
     /**
      * Transaction declined
      */
 /**
  * Transaction declined
  */