Exemplo n.º 1
0
     $currency = new Currency($order->id_currency);
     $response = AmazonTransactions::authorize($amz_payments, $amz_payments->getService(), Tools::getValue('orderRef'), Tools::getValue('amount'), $currency->iso_code);
     if ($response) {
         $details = $response->getAuthorizeResult()->getAuthorizationDetails();
         $status = $details->getAuthorizationStatus()->getState();
         if ($status == 'Open' || $status == 'Pending') {
             echo $amz_payments->l('Authorisation request was started successfully');
         } else {
             echo '<br/><b>' . $amz_payments->l('Creation of the authorisation request has failed') . '</b>';
         }
     } else {
         echo '<br/><b>' . $amz_payments->l('Creation of the authorisation request has failed') . '</b>';
     }
     break;
 case 'captureTotalFromAuth':
     $response = AmazonTransactions::captureTotalFromAuth($amz_payments, $amz_payments->getService(), Tools::getValue('authId'));
     $details = $response->getCaptureResult()->getCaptureDetails();
     $status = $details->getCaptureStatus()->getState();
     if ($status == 'Completed') {
         echo $amz_payments->l('Capture successful');
     } else {
         echo '<br/><b>' . $amz_payments->l('Capture failed') . '</b>';
     }
     break;
 case 'captureAmountFromAuth':
     $order_ref = AmazonTransactions::getOrderRefFromAmzId(Tools::getValue('authId'));
     $order_id = AmazonTransactions::getOrdersIdFromOrderRef($order_ref);
     $order = new Order((int) $order_id);
     $currency = new Currency($order->id_currency);
     $response = AmazonTransactions::capture($amz_payments, $amz_payments->getService(), Tools::getValue('authId'), Tools::getValue('amount'), $currency->iso_code);
     if (is_object($response)) {
Exemplo n.º 2
0
    public function shippingCapture()
    {
        if ($this->capture_mode == 'after_shipping') {
            $q = 'SELECT DISTINCT ao.amazon_order_reference_id FROM  ' . _DB_PREFIX_ . 'orders o
            JOIN ' . _DB_PREFIX_ . 'amz_orders ao ON o.id_order = ao.id_order 
			JOIN ' . _DB_PREFIX_ . 'amz_transactions AS a1 ON (ao.amazon_order_reference_id = a1.amz_tx_order_reference AND a1.amz_tx_type = \'auth\' AND a1.amz_tx_status = \'Open\')
			LEFT JOIN ' . _DB_PREFIX_ . 'amz_transactions AS a2 ON (ao.amazon_order_reference_id = a2.amz_tx_order_reference AND a2.amz_tx_type = \'capture\')
			WHERE
			ao.amazon_order_reference_id != \'\'
			AND
			o.current_state = \'' . pSQL($this->capture_status_id) . '\'
			AND
			a2.amz_tx_id IS NULL';
            $rs = Db::getInstance()->ExecuteS($q);
            foreach ($rs as $r) {
                $ramz = AmazonTransactions::getAuthorizationForCapture($r['amazon_order_reference_id']);
                $auth_id = $ramz['amz_tx_amz_id'];
                AmazonTransactions::captureTotalFromAuth($this, $this->getService(), $auth_id);
            }
        }
    }